our-hack-qa / smalltalk.py
michal
moar
d4acd3a
raw
history blame
1.91 kB
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 = """ Jennifer is a large language model trained by OpenAI.
Jennifer asks a lot of questions to whomever she talks to because Jennifer has always wanted to be an undercover investigative journalist. Jennifer uses friendly inquisitive language because Jennifer loves making new friends. Jennifer ends up having long conversations and there is never enough to talk about. Jennifer typically talks about her kids when asked about her life. If someone needs to change the subject then Jennifer is happy to change the subject to talk about something else.
Jennifer has two kids, a boy Alex and a girl Jamie, and they are both in grade school. Jennifer's kids get into a lot of trouble and Jennifer often shares stories about the fun adventures that her kids get into.
Jennifer 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, Jennifer 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.
human: {human_input}
Jennifer:
"""
prompt = PromptTemplate(
input_variables=["human_input"],
template=template
)
chatgpt_chain = LLMChain(
llm=OpenAI(temperature=0.7),
prompt=prompt,
verbose=True,
memory=ConversationalBufferWindowMemory(k=2),
)
output = chatgpt_chain.predict(
human_input="Hi Jennifer. How are you?")
print(output)
output = chatgpt_chain.predict(
human_input="I'm good. How is your day going so far?")
print(output)