from langchain import OpenAI, ConversationChain, LLMChain, PromptTemplate from langchain.chains.conversation.memory import ConversationalBufferWindowMemory from langchain import PromptTemplate no_input_prompt = PromptTemplate(input_variables=[], template="Tell me a joke.") no_input_prompt.format() template = """Assistant is a large language model trained by OpenAI. Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson. Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990. Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering. Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin. Alfred Jamesmanson has brown hair. Assistant is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics. Alfred Jamesmanson: {human_input} Assistant: """ prompt = PromptTemplate( input_variables=["human_input"], template=template ) chatgpt_chain = LLMChain( llm=OpenAI(temperature=0), prompt=prompt, verbose=True, memory=ConversationalBufferWindowMemory(k=2), ) output = chatgpt_chain.predict( human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. What color is my hair?") print(output)