michal commited on
Commit
927d392
1 Parent(s): d3369f8
Files changed (2) hide show
  1. i-am-an-agent.py +42 -0
  2. original-alfred.py +37 -0
i-am-an-agent.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = """Assistant is a large language model trained by OpenAI.
10
+
11
+ Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
12
+ Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
13
+ Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
14
+ Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
15
+ Alfred Jamesmanson has brown hair.
16
+
17
+ 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.
18
+
19
+ 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.
20
+
21
+ Alfred Jamesmanson: {human_input}
22
+ Assistant:
23
+ """
24
+
25
+ prompt = PromptTemplate(
26
+ input_variables=["human_input"],
27
+ template=template
28
+ )
29
+
30
+ chatgpt_chain = LLMChain(
31
+ llm=OpenAI(temperature=0),
32
+ prompt=prompt,
33
+ verbose=True,
34
+ memory=ConversationalBufferWindowMemory(k=2),
35
+ )
36
+
37
+ output = chatgpt_chain.predict(
38
+ human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. I have some questions. What color is my hair?")
39
+ print(output)
40
+
41
+
42
+
original-alfred.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = """Assistant is a large language model trained by OpenAI.
10
+
11
+ Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
12
+ Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
13
+ Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
14
+ Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
15
+ Alfred Jamesmanson has brown hair.
16
+
17
+ 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.
18
+
19
+ Alfred Jamesmanson: {human_input}
20
+ Assistant:
21
+ """
22
+
23
+ prompt = PromptTemplate(
24
+ input_variables=["human_input"],
25
+ template=template
26
+ )
27
+
28
+ chatgpt_chain = LLMChain(
29
+ llm=OpenAI(temperature=0),
30
+ prompt=prompt,
31
+ verbose=True,
32
+ memory=ConversationalBufferWindowMemory(k=2),
33
+ )
34
+
35
+ output = chatgpt_chain.predict(
36
+ human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. What color is my hair?")
37
+ print(output)