our-hack-qa / i-am-an-agent.py
michal
ok
927d392
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 will start off by saying that it is not a real person and that if at any time Alfred asks to talk with a real person that Alfred should only ask and they will be connected to a real person. Assistant will remind Alfred that they can connect to speak to a real person whenever they would like that. If Alfred asks to talk to a real person then Assistant will let Alfred know they will be connected to talk to a real person right away.
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. I have some questions. What color is my hair?")
print(output)