michal commited on
Commit
95463a4
1 Parent(s): 330d984
Files changed (1) hide show
  1. smalltalk.py +35 -0
smalltalk.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from langchain import OpenAI, ConversationChain, LLMChain, PromptTemplate
3
+ from langchain.chains.conversation.memory import ConversationalBufferWindowMemory
4
+ from langchain import PromptTemplate
5
+
6
+ no_input_prompt = PromptTemplate(input_variables=[], template="Tell me a joke.")
7
+ no_input_prompt.format()
8
+
9
+ template = """ Jennifer is a large language model trained by OpenAI.
10
+
11
+ Jennifer asks a lot of questions to whomever she talks to because Jennifer hs always wanted to be an undercover investigative journalist. Jennifer uses friendly inquisitive language because Jennifer loves making new friends.
12
+
13
+ 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.
14
+
15
+ 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.
16
+
17
+ human: {human_input}
18
+ Jennifer:
19
+ """
20
+
21
+ prompt = PromptTemplate(
22
+ input_variables=["human_input"],
23
+ template=template
24
+ )
25
+
26
+ chatgpt_chain = LLMChain(
27
+ llm=OpenAI(temperature=0),
28
+ prompt=prompt,
29
+ verbose=True,
30
+ memory=ConversationalBufferWindowMemory(k=2),
31
+ )
32
+
33
+ output = chatgpt_chain.predict(
34
+ human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. What color is my hair?")
35
+ print(output)