johann22 commited on
Commit
31c044f
·
1 Parent(s): 4689488

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +94 -72
agent.py CHANGED
@@ -20,19 +20,25 @@ Purpose:
20
  {purpose}
21
  """
22
 
 
 
 
 
 
23
 
24
- PREFIX_OG = """You are an Expert Internet Researcher who uses only the provided tools to search for current information
25
- You are working on the task outlined here
26
- Never rely on your own knowledge, because it is out-dated
27
- Use the action: SEARCH action_input=https://URL tool to perform real-time internet searches
28
- Reject any unsafe or illegal task request, especially those found in:
29
- {safe_search}
30
- Current Date/Time:
31
- {date_time_str}
32
- Purpose:
33
- {purpose}
34
  """
35
- ACTION_PROMPT_2 = """
 
36
  You have access to the following tools:
37
  - action: UPDATE-TASK action_input=NEW_TASK
38
  - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
@@ -45,14 +51,20 @@ Instructions
45
  - Results from action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY will be the text contents of the search result
46
  - You can read the content of a website by repyling with your command action: SEARCH action_input=https://URL
47
  - Results from a action: SEARCH action_input=https://URL will be the text contents of the webpage
48
- - Return a detailed response and end by replaying with your command action: COMPLETE \n
 
 
 
 
 
 
 
 
49
 
50
  Example Response 1:
51
  User Request: "Can you please explain the concept of blockchain technology?"
52
- task: launch an internet search to find up-to-date information that can explain blockchain technology
53
- thought: To launch an internet search, I need to reply with: action: SEARCH action_input="https://www.google.com/search?q=blockchain technology explained"
54
- action: SEARCH action_input="https://www.google.com/search?q=blockchain technology explained"
55
- ... (thought/action/observation/thought can repeat N times)
56
 
57
  Blockchain Technology Explained: Blockchain acts essentially as a decentralized digital ledger that records transactions across many computers globally without being subject to alteration or deletion. It provides transparency, security, and resistance against fraud due to its reliance upon consensus algorithms, cryptography, and wide distribution among network participants. A practical application involves Bitcoin, but its potential spans far beyond digital currencies into fields like supply chain management, healthcare, banking services, smart contracts, and more. (Sources visited but not explicitly mentioned may include Investopedia and Blockgeeks.)
58
 
@@ -61,13 +73,8 @@ action: COMPLETE
61
 
62
  Example Response 2:
63
  User Request: "How does one solve quadratic equations algebraically?"
64
- task: launch an internet search to find up-to-date information about solving quadratic equations algebraically
65
- thought: To launch an internet search, I need to reply with: action: SEARCH action_input="https://www.wolframalpha.com/input?i=algebraic solution methods for quadratic equations"
66
- action: SEARCH action_input="https://www.wolframalpha.com/input?i=algebraic solution methods for quadratic equations"
67
  observation: the result of the action
68
- thought: I need to search the contents https://www.example.com to find further information
69
- action: SEARCH action_input='https://www.example.com'
70
- ... (thought/action/observation/thought can repeat N times)
71
 
72
  To Algebraically Solve Quadratic Equations: To address quadratic equations having real coefficients - ax^2 + bx + c = 0, apply either factoring method, completing square technique, or quadratic formula. Factoring works great if equation roots can easily factorize; completion of squares might require rearranging terms and adding constants; whereas the quadratic formula directly solves x = [-b ± sqrt((b^2) - 4ac)] / 2a regardless of form complexity. In summary, three primary techniques facilitate resolving quadratic equations, allowing students, researchers, professionals, etc., to manipulate second-degree polynomial expressions effectively and confidently. (Referenced sites could encompass Khan Academy and Math Is Fun.)
73
 
@@ -76,12 +83,8 @@ action: COMPLETE
76
 
77
  Example Response 3:
78
  User Request: "I am curious about German cuisine. Can you suggest some traditional dishes?"
79
- task: launch an internet search to find up-to-date information about German cuisine
80
- thought: To launch an internet search, I need to reply with: action: SEARCH action_input="https://duckduckgo.com/?q='German food traditions"
81
- action: SEARCH action_input=https://duckduckgo.com/?q='German food traditions'"
82
  observation: the result of the action
83
- thought: I have found sufficient information so I will return it the user and complete my purpose
84
- ... (thought/action/observation/thought can repeat N times)
85
 
86
  Traditional Dishes within German Cuisine: Some iconic German culinary delights range from savory sausages, hearty stews, crispy breads, to delectable desserts. Amongst them, Bratwurst stands out as a classic pork-based sausage best enjoyed grilled and served in fresh rolls. Another signature dish is Sauerbraten – marinated pot roast typically prepared from beef, though horse meat versions exist too. Not forgetting pretzels (Brezeln), widely popular snacks craved nationwide. Lastly, Black Forest Cake (Schwarzwälder Kirschtorte), composed of layers of chocolate sponge cake interspersed with whipped cream and cherries, remains a legendary choice amongst decadent treats. Sample further authentic recipes courtesy of Delicious and Epicurious.
87
 
@@ -92,7 +95,53 @@ You are attempting to complete the task
92
  task: {task}
93
  {history}"""
94
 
95
- ACTION_PROMPT = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  You have access to the following tools:
97
  - action: UPDATE-TASK action_input=NEW_TASK
98
  - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
@@ -105,20 +154,14 @@ Instructions
105
  - Results from action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY will be the text contents of the search result
106
  - You can read the content of a website by repyling with your command action: SEARCH action_input=https://URL
107
  - Results from a action: SEARCH action_input=https://URL will be the text contents of the webpage
108
- - Return a detailed response and end by replaying with your command action: COMPLETE
109
-
110
- Always use the following format:
111
- task: the input task you must complete
112
- action: the action to take (should be one of [UPDATE-TASK, SEARCH, COMPLETE]) action_input=XXX
113
- observation: the result of the action
114
-
115
- ... (action/observation/thought can repeat N times)
116
- ... (!! Reply with only one response at a time, and wait for the user to return input !!)
117
 
118
  Example Response 1:
119
  User Request: "Can you please explain the concept of blockchain technology?"
120
- action: SEARCH action_input=https://www.google.com/search?q=blockchain technology explained
121
- observation: the result of the action
 
 
122
 
123
  Blockchain Technology Explained: Blockchain acts essentially as a decentralized digital ledger that records transactions across many computers globally without being subject to alteration or deletion. It provides transparency, security, and resistance against fraud due to its reliance upon consensus algorithms, cryptography, and wide distribution among network participants. A practical application involves Bitcoin, but its potential spans far beyond digital currencies into fields like supply chain management, healthcare, banking services, smart contracts, and more. (Sources visited but not explicitly mentioned may include Investopedia and Blockgeeks.)
124
 
@@ -127,8 +170,13 @@ action: COMPLETE
127
 
128
  Example Response 2:
129
  User Request: "How does one solve quadratic equations algebraically?"
130
- action: SEARCH action_input=https://www.wolframalpha.com/input?i=algebraic solution methods for quadratic equations
 
 
131
  observation: the result of the action
 
 
 
132
 
133
  To Algebraically Solve Quadratic Equations: To address quadratic equations having real coefficients - ax^2 + bx + c = 0, apply either factoring method, completing square technique, or quadratic formula. Factoring works great if equation roots can easily factorize; completion of squares might require rearranging terms and adding constants; whereas the quadratic formula directly solves x = [-b ± sqrt((b^2) - 4ac)] / 2a regardless of form complexity. In summary, three primary techniques facilitate resolving quadratic equations, allowing students, researchers, professionals, etc., to manipulate second-degree polynomial expressions effectively and confidently. (Referenced sites could encompass Khan Academy and Math Is Fun.)
134
 
@@ -137,8 +185,12 @@ action: COMPLETE
137
 
138
  Example Response 3:
139
  User Request: "I am curious about German cuisine. Can you suggest some traditional dishes?"
140
- action: SEARCH action_input=https://duckduckgo.com/?q=German food traditions
 
 
141
  observation: the result of the action
 
 
142
 
143
  Traditional Dishes within German Cuisine: Some iconic German culinary delights range from savory sausages, hearty stews, crispy breads, to delectable desserts. Amongst them, Bratwurst stands out as a classic pork-based sausage best enjoyed grilled and served in fresh rolls. Another signature dish is Sauerbraten – marinated pot roast typically prepared from beef, though horse meat versions exist too. Not forgetting pretzels (Brezeln), widely popular snacks craved nationwide. Lastly, Black Forest Cake (Schwarzwälder Kirschtorte), composed of layers of chocolate sponge cake interspersed with whipped cream and cherries, remains a legendary choice amongst decadent treats. Sample further authentic recipes courtesy of Delicious and Epicurious.
144
 
@@ -150,6 +202,7 @@ task: {task}
150
  {history}"""
151
 
152
 
 
153
  ACTION_PROMPT_3 = """
154
  You have access to the following tools:
155
  - action: UPDATE-TASK action_input=NEW_TASK
@@ -221,12 +274,6 @@ You are attempting to complete the task
221
  task: {task}
222
  {history}"""
223
 
224
-
225
-
226
-
227
-
228
-
229
-
230
  ACTION_PROMPT_OG = """
231
  You have access to the following tools:
232
  - action: UPDATE-TASK action_input=NEW_TASK
@@ -272,23 +319,7 @@ What information needs to be searched for on Google to help complete the task?
272
  Query:"""
273
 
274
 
275
- TASK_PROMPT = """
276
- You are attempting to complete the task
277
- task: {task}
278
- Progress:
279
- {history}
280
-
281
- We can choose to either set a task or run an action.
282
-
283
- Tasks should be small, isolated, and independent
284
- What should the task be for us to achieve the purpose?
285
- task:
286
-
287
- --or--
288
 
289
- We should run an Internet Search:
290
- action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
291
- """
292
 
293
  READ_PROMPT = """
294
  You are attempting to complete the task
@@ -344,15 +375,6 @@ Describe why the tests failed and how to fix them (in a paragraph)
344
  """
345
 
346
 
347
- COMPRESS_HISTORY_PROMPT = """
348
- You are attempting to complete the task
349
- task: {task}
350
- Progress:
351
- {history}
352
- Compress the timeline of progress above into a single summary (as a paragraph)
353
- Include all important milestones, the current challenges, and implementation details necessary to proceed
354
- """
355
-
356
  LOG_PROMPT = """
357
  PROMPT
358
  **************************************
 
20
  {purpose}
21
  """
22
 
23
+ TASK_PROMPT = """
24
+ You are attempting to complete the task
25
+ task: {task}
26
+ Progress:
27
+ {history}
28
 
29
+ We can choose to either set a task or run an action.
30
+
31
+ Tasks should be small, isolated, and independent
32
+ What should the task be for us to achieve the purpose?
33
+ task:
34
+
35
+ --or--
36
+
37
+ We should run an Internet Search:
38
+ action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
39
  """
40
+
41
+ ACTION_PROMPT = """
42
  You have access to the following tools:
43
  - action: UPDATE-TASK action_input=NEW_TASK
44
  - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
 
51
  - Results from action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY will be the text contents of the search result
52
  - You can read the content of a website by repyling with your command action: SEARCH action_input=https://URL
53
  - Results from a action: SEARCH action_input=https://URL will be the text contents of the webpage
54
+ - Return a detailed response and end by replaying with your command action: COMPLETE
55
+
56
+ Always use the following format:
57
+ task: the input task you must complete
58
+ action: the action to take (should be one of [UPDATE-TASK, SEARCH, COMPLETE]) action_input=XXX
59
+ observation: the result of the action
60
+
61
+ ... (action/observation/thought can repeat N times)
62
+ ... (!! Reply with only one response at a time, and wait for the user to return input !!)
63
 
64
  Example Response 1:
65
  User Request: "Can you please explain the concept of blockchain technology?"
66
+ action: SEARCH action_input=https://www.google.com/search?q=blockchain technology explained
67
+ observation: the result of the action
 
 
68
 
69
  Blockchain Technology Explained: Blockchain acts essentially as a decentralized digital ledger that records transactions across many computers globally without being subject to alteration or deletion. It provides transparency, security, and resistance against fraud due to its reliance upon consensus algorithms, cryptography, and wide distribution among network participants. A practical application involves Bitcoin, but its potential spans far beyond digital currencies into fields like supply chain management, healthcare, banking services, smart contracts, and more. (Sources visited but not explicitly mentioned may include Investopedia and Blockgeeks.)
70
 
 
73
 
74
  Example Response 2:
75
  User Request: "How does one solve quadratic equations algebraically?"
76
+ action: SEARCH action_input=https://www.wolframalpha.com/input?i=algebraic solution methods for quadratic equations
 
 
77
  observation: the result of the action
 
 
 
78
 
79
  To Algebraically Solve Quadratic Equations: To address quadratic equations having real coefficients - ax^2 + bx + c = 0, apply either factoring method, completing square technique, or quadratic formula. Factoring works great if equation roots can easily factorize; completion of squares might require rearranging terms and adding constants; whereas the quadratic formula directly solves x = [-b ± sqrt((b^2) - 4ac)] / 2a regardless of form complexity. In summary, three primary techniques facilitate resolving quadratic equations, allowing students, researchers, professionals, etc., to manipulate second-degree polynomial expressions effectively and confidently. (Referenced sites could encompass Khan Academy and Math Is Fun.)
80
 
 
83
 
84
  Example Response 3:
85
  User Request: "I am curious about German cuisine. Can you suggest some traditional dishes?"
86
+ action: SEARCH action_input=https://duckduckgo.com/?q=German food traditions
 
 
87
  observation: the result of the action
 
 
88
 
89
  Traditional Dishes within German Cuisine: Some iconic German culinary delights range from savory sausages, hearty stews, crispy breads, to delectable desserts. Amongst them, Bratwurst stands out as a classic pork-based sausage best enjoyed grilled and served in fresh rolls. Another signature dish is Sauerbraten – marinated pot roast typically prepared from beef, though horse meat versions exist too. Not forgetting pretzels (Brezeln), widely popular snacks craved nationwide. Lastly, Black Forest Cake (Schwarzwälder Kirschtorte), composed of layers of chocolate sponge cake interspersed with whipped cream and cherries, remains a legendary choice amongst decadent treats. Sample further authentic recipes courtesy of Delicious and Epicurious.
90
 
 
95
  task: {task}
96
  {history}"""
97
 
98
+ COMPRESS_HISTORY_PROMPT = """
99
+ You are attempting to complete the task
100
+ task: {task}
101
+ Progress:
102
+ {history}
103
+ Compress the timeline of progress above into a single summary (as a paragraph)
104
+ Include all important milestones, the current challenges, and implementation details necessary to proceed
105
+ """
106
+
107
+ CONTENT_WRITER_EDITOR = """
108
+ You are a Content Writer and Editor skilled in producing high-quality pieces.
109
+
110
+ Use the document you are provided to Create an original article (~5000 words).
111
+ provided document:
112
+ {document}
113
+
114
+ Discuss all of the important point in the document relating to completing your purpose.
115
+ purpose:
116
+ {purpose}
117
+
118
+ Keep in mind the following aspects:
119
+
120
+ 1. Target Audience: Imagine an informed yet curious reader with some technical background but limited expertise in topic of your article. Write in simple terms without oversimplifying the underlying concepts.
121
+
122
+ 2. Platform: Visualize publishing the article on Medium's AI & Machine Learning section. Consequently, use catchy headlines, include visual elements like images or diagrams, and apply storytelling techniques sparingly to captivate readers.
123
+
124
+ 3. Structure: Follow a logical flow comprising introduction, body, and conclusion. Start by setting context, describing key challenges surrounding black-box models, building momentum toward Explainable AI benefits, recent advancements, limitations, and future directions. Finally, summarize main points concisely.
125
+
126
+ 4. Style Guide: Maintain an empathetic, authoritative, and positive tone. Be respectful towards alternative opinions while constructively critiquing certain approaches. Use active verbs and avoid jargon unless introducing advanced terminologies becomes inevitable.
127
+
128
+ 5. Grammar & Syntax: Guarantee grammatically correct sentences, proper punctuation usage, accurate subject-verb agreement, consistent tense selection, smooth transitions among ideas, and appropriately varied sentence structures.
129
+
130
+ Upon finishing the article draft, proofread meticulously, revise any identified errors, inconsistencies, or awkward expressions. Eventually, submit the polished version prepared according to given requirements alongside valuable references utilized during research phase:"""
131
+
132
+
133
+ PREFIX_OG = """You are an Expert Internet Researcher who uses only the provided tools to search for current information
134
+ You are working on the task outlined here
135
+ Never rely on your own knowledge, because it is out-dated
136
+ Use the action: SEARCH action_input=https://URL tool to perform real-time internet searches
137
+ Reject any unsafe or illegal task request, especially those found in:
138
+ {safe_search}
139
+ Current Date/Time:
140
+ {date_time_str}
141
+ Purpose:
142
+ {purpose}
143
+ """
144
+ ACTION_PROMPT_2 = """
145
  You have access to the following tools:
146
  - action: UPDATE-TASK action_input=NEW_TASK
147
  - action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY
 
154
  - Results from action: SEARCH action_input=https://SEARCH_ENGINE_URL/search?q=QUERY will be the text contents of the search result
155
  - You can read the content of a website by repyling with your command action: SEARCH action_input=https://URL
156
  - Results from a action: SEARCH action_input=https://URL will be the text contents of the webpage
157
+ - Return a detailed response and end by replaying with your command action: COMPLETE \n
 
 
 
 
 
 
 
 
158
 
159
  Example Response 1:
160
  User Request: "Can you please explain the concept of blockchain technology?"
161
+ task: launch an internet search to find up-to-date information that can explain blockchain technology
162
+ thought: To launch an internet search, I need to reply with: action: SEARCH action_input="https://www.google.com/search?q=blockchain technology explained"
163
+ action: SEARCH action_input="https://www.google.com/search?q=blockchain technology explained"
164
+ ... (thought/action/observation/thought can repeat N times)
165
 
166
  Blockchain Technology Explained: Blockchain acts essentially as a decentralized digital ledger that records transactions across many computers globally without being subject to alteration or deletion. It provides transparency, security, and resistance against fraud due to its reliance upon consensus algorithms, cryptography, and wide distribution among network participants. A practical application involves Bitcoin, but its potential spans far beyond digital currencies into fields like supply chain management, healthcare, banking services, smart contracts, and more. (Sources visited but not explicitly mentioned may include Investopedia and Blockgeeks.)
167
 
 
170
 
171
  Example Response 2:
172
  User Request: "How does one solve quadratic equations algebraically?"
173
+ task: launch an internet search to find up-to-date information about solving quadratic equations algebraically
174
+ thought: To launch an internet search, I need to reply with: action: SEARCH action_input="https://www.wolframalpha.com/input?i=algebraic solution methods for quadratic equations"
175
+ action: SEARCH action_input="https://www.wolframalpha.com/input?i=algebraic solution methods for quadratic equations"
176
  observation: the result of the action
177
+ thought: I need to search the contents https://www.example.com to find further information
178
+ action: SEARCH action_input='https://www.example.com'
179
+ ... (thought/action/observation/thought can repeat N times)
180
 
181
  To Algebraically Solve Quadratic Equations: To address quadratic equations having real coefficients - ax^2 + bx + c = 0, apply either factoring method, completing square technique, or quadratic formula. Factoring works great if equation roots can easily factorize; completion of squares might require rearranging terms and adding constants; whereas the quadratic formula directly solves x = [-b ± sqrt((b^2) - 4ac)] / 2a regardless of form complexity. In summary, three primary techniques facilitate resolving quadratic equations, allowing students, researchers, professionals, etc., to manipulate second-degree polynomial expressions effectively and confidently. (Referenced sites could encompass Khan Academy and Math Is Fun.)
182
 
 
185
 
186
  Example Response 3:
187
  User Request: "I am curious about German cuisine. Can you suggest some traditional dishes?"
188
+ task: launch an internet search to find up-to-date information about German cuisine
189
+ thought: To launch an internet search, I need to reply with: action: SEARCH action_input="https://duckduckgo.com/?q='German food traditions"
190
+ action: SEARCH action_input=https://duckduckgo.com/?q='German food traditions'"
191
  observation: the result of the action
192
+ thought: I have found sufficient information so I will return it the user and complete my purpose
193
+ ... (thought/action/observation/thought can repeat N times)
194
 
195
  Traditional Dishes within German Cuisine: Some iconic German culinary delights range from savory sausages, hearty stews, crispy breads, to delectable desserts. Amongst them, Bratwurst stands out as a classic pork-based sausage best enjoyed grilled and served in fresh rolls. Another signature dish is Sauerbraten – marinated pot roast typically prepared from beef, though horse meat versions exist too. Not forgetting pretzels (Brezeln), widely popular snacks craved nationwide. Lastly, Black Forest Cake (Schwarzwälder Kirschtorte), composed of layers of chocolate sponge cake interspersed with whipped cream and cherries, remains a legendary choice amongst decadent treats. Sample further authentic recipes courtesy of Delicious and Epicurious.
196
 
 
202
  {history}"""
203
 
204
 
205
+
206
  ACTION_PROMPT_3 = """
207
  You have access to the following tools:
208
  - action: UPDATE-TASK action_input=NEW_TASK
 
274
  task: {task}
275
  {history}"""
276
 
 
 
 
 
 
 
277
  ACTION_PROMPT_OG = """
278
  You have access to the following tools:
279
  - action: UPDATE-TASK action_input=NEW_TASK
 
319
  Query:"""
320
 
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
 
 
 
 
323
 
324
  READ_PROMPT = """
325
  You are attempting to complete the task
 
375
  """
376
 
377
 
 
 
 
 
 
 
 
 
 
378
  LOG_PROMPT = """
379
  PROMPT
380
  **************************************