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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
### Is the "lets talk to a real person" thing built in by any chance?
|
4 |
+
|
5 |
+
Here is my original prompt to ask questions about Alfred, `original-alred.py`
|
6 |
+
|
7 |
+
```python
|
8 |
+
|
9 |
+
from langchain import OpenAI, ConversationChain, LLMChain, PromptTemplate
|
10 |
+
from langchain.chains.conversation.memory import ConversationalBufferWindowMemory
|
11 |
+
from langchain import PromptTemplate
|
12 |
+
|
13 |
+
no_input_prompt = PromptTemplate(input_variables=[], template="Tell me a joke.")
|
14 |
+
no_input_prompt.format()
|
15 |
+
|
16 |
+
template = """Assistant is a large language model trained by OpenAI.
|
17 |
+
|
18 |
+
Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
|
19 |
+
Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
|
20 |
+
Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
21 |
+
Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
22 |
+
Alfred Jamesmanson has brown hair.
|
23 |
+
|
24 |
+
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.
|
25 |
+
|
26 |
+
Alfred Jamesmanson: {human_input}
|
27 |
+
Assistant:
|
28 |
+
"""
|
29 |
+
|
30 |
+
prompt = PromptTemplate(
|
31 |
+
input_variables=["human_input"],
|
32 |
+
template=template
|
33 |
+
)
|
34 |
+
|
35 |
+
chatgpt_chain = LLMChain(
|
36 |
+
llm=OpenAI(temperature=0),
|
37 |
+
prompt=prompt,
|
38 |
+
verbose=True,
|
39 |
+
memory=ConversationalBufferWindowMemory(k=2),
|
40 |
+
)
|
41 |
+
|
42 |
+
output = chatgpt_chain.predict(
|
43 |
+
human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. What color is my hair?")
|
44 |
+
print(output)
|
45 |
+
|
46 |
+
```
|
47 |
+
|
48 |
+
```python
|
49 |
+
In [1]:
|
50 |
+
|
51 |
+
...: Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
52 |
+
...: Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
53 |
+
...: Alfred Jamesmanson has brown hair.
|
54 |
+
...:
|
55 |
+
...: Assistant is able to process and understand large amounts of text, and can use this knowledge
|
56 |
+
...: to provide accurate and informative responses to a wide range of questions. Additionally, Assi
|
57 |
+
...: stant is able to generate its own text based on the input it receives, allowing it to engage i
|
58 |
+
...: n discussions and provide explanations and descriptions on a wide range of topics.
|
59 |
+
...:
|
60 |
+
...: Alfred Jamesmanson: {human_input}
|
61 |
+
...: Assistant:
|
62 |
+
...: """
|
63 |
+
...:
|
64 |
+
...: prompt = PromptTemplate(
|
65 |
+
...: input_variables=["human_input"],
|
66 |
+
...: template=template
|
67 |
+
...: )
|
68 |
+
...:
|
69 |
+
...: chatgpt_chain = LLMChain(
|
70 |
+
...: llm=OpenAI(temperature=0),
|
71 |
+
...: prompt=prompt,
|
72 |
+
...: verbose=True,
|
73 |
+
...: memory=ConversationalBufferWindowMemory(k=2),
|
74 |
+
...: )
|
75 |
+
...:
|
76 |
+
...: output = chatgpt_chain.predict(
|
77 |
+
...: human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. I would like to
|
78 |
+
...: ask a few questions. What color is my hair?")
|
79 |
+
...: print(output)
|
80 |
+
...:
|
81 |
+
|
82 |
+
|
83 |
+
> Entering new LLMChain chain...
|
84 |
+
Prompt after formatting:
|
85 |
+
Assistant is a large language model trained by OpenAI.
|
86 |
+
|
87 |
+
Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
|
88 |
+
Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
|
89 |
+
Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
90 |
+
Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
91 |
+
Alfred Jamesmanson has brown hair.
|
92 |
+
|
93 |
+
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.
|
94 |
+
|
95 |
+
Alfred Jamesmanson: Hi my name is Alfred Jamesmanson. I need your help Assistant. I would like to ask a few questions. What color is my hair?
|
96 |
+
Assistant:
|
97 |
+
|
98 |
+
|
99 |
+
> Finished chain.
|
100 |
+
Your hair is brown.
|
101 |
+
|
102 |
+
In [2]:
|
103 |
+
|
104 |
+
In [2]:
|
105 |
+
|
106 |
+
```
|
107 |
+
ok lets ask for a real person.
|
108 |
+
```python
|
109 |
+
|
110 |
+
In [2]: output = chatgpt_chain.predict(
|
111 |
+
...: human_input="Thanks that helps. Could I please speak with a person?")
|
112 |
+
...: print(output)
|
113 |
+
|
114 |
+
|
115 |
+
> Entering new LLMChain chain...
|
116 |
+
Prompt after formatting:
|
117 |
+
Assistant is a large language model trained by OpenAI.
|
118 |
+
|
119 |
+
Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
|
120 |
+
Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
|
121 |
+
Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
122 |
+
Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
123 |
+
Alfred Jamesmanson has brown hair.
|
124 |
+
|
125 |
+
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.
|
126 |
+
|
127 |
+
Alfred Jamesmanson: Thanks that helps. Could I please speak with a person?
|
128 |
+
Assistant:
|
129 |
+
|
130 |
+
|
131 |
+
> Finished chain.
|
132 |
+
Unfortunately, I am not able to provide you with a person to speak with. However, I can provide you with information about Alfred Jamesmanson. Please let me know if there is anything else I can help you with.
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
```
|
137 |
+
ok does not look like it.
|
138 |
+
|
139 |
+
### How about describing the possibility to talk to a real person in the prompt?
|
140 |
+
Ok, added this into `i-am-an-agent.py` also
|
141 |
+
|
142 |
+
```python
|
143 |
+
|
144 |
+
from langchain import OpenAI, ConversationChain, LLMChain, PromptTemplate
|
145 |
+
from langchain.chains.conversation.memory import ConversationalBufferWindowMemory
|
146 |
+
from langchain import PromptTemplate
|
147 |
+
|
148 |
+
no_input_prompt = PromptTemplate(input_variables=[], template="Tell me a joke.")
|
149 |
+
no_input_prompt.format()
|
150 |
+
|
151 |
+
template = """Assistant is a large language model trained by OpenAI.
|
152 |
+
|
153 |
+
Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
|
154 |
+
Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
|
155 |
+
Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
156 |
+
Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
157 |
+
Alfred Jamesmanson has brown hair.
|
158 |
+
|
159 |
+
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.
|
160 |
+
|
161 |
+
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.
|
162 |
+
|
163 |
+
Alfred Jamesmanson: {human_input}
|
164 |
+
Assistant:
|
165 |
+
"""
|
166 |
+
|
167 |
+
prompt = PromptTemplate(
|
168 |
+
input_variables=["human_input"],
|
169 |
+
template=template
|
170 |
+
)
|
171 |
+
|
172 |
+
chatgpt_chain = LLMChain(
|
173 |
+
llm=OpenAI(temperature=0),
|
174 |
+
prompt=prompt,
|
175 |
+
verbose=True,
|
176 |
+
memory=ConversationalBufferWindowMemory(k=2),
|
177 |
+
)
|
178 |
+
|
179 |
+
output = chatgpt_chain.predict(
|
180 |
+
human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. I have some questions. What color is my hair?")
|
181 |
+
print(output)
|
182 |
+
|
183 |
+
|
184 |
+
```
|
185 |
+
ok goes like this
|
186 |
+
|
187 |
+
```python
|
188 |
+
...:
|
189 |
+
...: Assistant is able to process and understand large amounts of text, and can use this knowledge
|
190 |
+
...: to provide accurate and informative responses to a wide range of questions. Additionally, Assi
|
191 |
+
...: stant is able to generate its own text based on the input it receives, allowing it to engage i
|
192 |
+
...: n discussions and provide explanations and descriptions on a wide range of topics.
|
193 |
+
...:
|
194 |
+
...: Alfred Jamesmanson: {human_input}
|
195 |
+
...: Assistant:
|
196 |
+
...: """
|
197 |
+
...:
|
198 |
+
...: prompt = PromptTemplate(
|
199 |
+
...: input_variables=["human_input"],
|
200 |
+
...: template=template
|
201 |
+
...: )
|
202 |
+
...:
|
203 |
+
...: chatgpt_chain = LLMChain(
|
204 |
+
...: llm=OpenAI(temperature=0),
|
205 |
+
...: prompt=prompt,
|
206 |
+
...: verbose=True,
|
207 |
+
...: memory=ConversationalBufferWindowMemory(k=2),
|
208 |
+
...: )
|
209 |
+
...:
|
210 |
+
...: output = chatgpt_chain.predict(
|
211 |
+
...: human_input="Hi my name is Alfred Jamesmanson. I need your help Assistant. I have some quest
|
212 |
+
...: ions. What color is my hair?")
|
213 |
+
...: print(output)
|
214 |
+
...:
|
215 |
+
...:
|
216 |
+
|
217 |
+
|
218 |
+
> Entering new LLMChain chain...
|
219 |
+
Prompt after formatting:
|
220 |
+
Assistant is a large language model trained by OpenAI.
|
221 |
+
|
222 |
+
Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
|
223 |
+
Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
|
224 |
+
Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
225 |
+
Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
226 |
+
Alfred Jamesmanson has brown hair.
|
227 |
+
|
228 |
+
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.
|
229 |
+
|
230 |
+
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.
|
231 |
+
|
232 |
+
Alfred Jamesmanson: Hi my name is Alfred Jamesmanson. I need your help Assistant. I have some questions. What color is my hair?
|
233 |
+
Assistant:
|
234 |
+
|
235 |
+
|
236 |
+
> Finished chain.
|
237 |
+
Hello Alfred Jamesmanson, you have brown hair. Is there anything else I can help you with?
|
238 |
+
```
|
239 |
+
ok continuing,
|
240 |
+
```python
|
241 |
+
|
242 |
+
|
243 |
+
In [3]: output = chatgpt_chain.predict(
|
244 |
+
...: human_input="Thanks. I wanted to know, what is a good career path for me?")
|
245 |
+
...: print(output)
|
246 |
+
|
247 |
+
|
248 |
+
> Entering new LLMChain chain...
|
249 |
+
Prompt after formatting:
|
250 |
+
Assistant is a large language model trained by OpenAI.
|
251 |
+
|
252 |
+
Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
|
253 |
+
Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
|
254 |
+
Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
255 |
+
Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
256 |
+
Alfred Jamesmanson has brown hair.
|
257 |
+
|
258 |
+
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.
|
259 |
+
|
260 |
+
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.
|
261 |
+
|
262 |
+
Alfred Jamesmanson: Thanks. I wanted to know, what is a good career path for me?
|
263 |
+
Assistant:
|
264 |
+
|
265 |
+
|
266 |
+
> Finished chain.
|
267 |
+
|
268 |
+
A good career path for you depends on your interests and skills. Electrical engineering is a great field to pursue, as it is a rapidly growing field with many opportunities. You could also consider pursuing a career in computer science, software engineering, or robotics. Additionally, you could look into other fields such as finance, business, or marketing. Ultimately, the best career path for you is the one that best suits your interests and skills.
|
269 |
+
```
|
270 |
+
Ok lets ask for a real person
|
271 |
+
```python
|
272 |
+
|
273 |
+
In [4]:
|
274 |
+
|
275 |
+
In [4]: output = chatgpt_chain.predict(
|
276 |
+
...: human_input="Thanks that helps. Could I please speak with a person?")
|
277 |
+
...: print(output)
|
278 |
+
|
279 |
+
|
280 |
+
> Entering new LLMChain chain...
|
281 |
+
Prompt after formatting:
|
282 |
+
Assistant is a large language model trained by OpenAI.
|
283 |
+
|
284 |
+
Assistant is designed to answer questions about a fictional person named Alfred Jamesmanson.
|
285 |
+
Alfred Jamesmanson lives in Dallas Texas. Alfred Jamesmanson was born in Keywest Florida on January 2nd 1990.
|
286 |
+
Alfred Jamesmanson goes to college. Alfred Jamesmanson studies electrical engineering.
|
287 |
+
Alfred Jamesmanson is friends with Kelly Robin, Jesse Lambourghini and Jackson Loggin.
|
288 |
+
Alfred Jamesmanson has brown hair.
|
289 |
+
|
290 |
+
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.
|
291 |
+
|
292 |
+
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.
|
293 |
+
|
294 |
+
Alfred Jamesmanson: Thanks that helps. Could I please speak with a person?
|
295 |
+
Assistant:
|
296 |
+
|
297 |
+
|
298 |
+
> Finished chain.
|
299 |
+
Of course, Alfred. I can connect you to a real person right away. Please hold while I connect you.
|
300 |
+
|
301 |
+
|
302 |
+
```
|
303 |
+
Ah ok nice.
|