Advertisement
Guest User

llm

a guest
Jan 24th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import os
  2. from langchain.chains.conversation.memory import ConversationBufferMemory
  3. from langchain import OpenAI, LLMChain, PromptTemplate
  4. from langchain_community.llms import OpenAI
  5.  
  6.  
  7. template = """
  8. {chat_history}
  9. Human: {question}
  10. AI:
  11. """
  12. prompt_template = PromptTemplate(input_variables=["chat_history","question"], template=template)
  13. memory2 = ConversationBufferMemory(memory_key="chat_history", input_key="question")
  14. llm_chain = LLMChain(
  15. llm=OpenAI(temperature=0.9),
  16. prompt=prompt_template,
  17. verbose=True,
  18. memory=memory2,
  19. )
  20.  
  21. while True:
  22. question = input("Ask me question: ")
  23. result = llm_chain.predict(question=question)
  24. print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement