Spaces:
Runtime error
Runtime error
DylanonWic
commited on
Commit
•
391ea44
1
Parent(s):
6f3689a
Upload 17 files
Browse files- chatbot_multiagent.ipynb +25 -15
- chatbot_multiagent.py +1 -1
chatbot_multiagent.ipynb
CHANGED
@@ -205,7 +205,7 @@
|
|
205 |
" workflow.add_conditional_edges(\n",
|
206 |
" meta[\"name\"],\n",
|
207 |
" router,\n",
|
208 |
-
" {\"continue\": meta['continue'], \"call_tool\": \"call_tool\", \"__end__\": END},\n",
|
209 |
" )\n",
|
210 |
"\n",
|
211 |
"workflow.add_conditional_edges(\n",
|
@@ -249,45 +249,55 @@
|
|
249 |
},
|
250 |
{
|
251 |
"cell_type": "code",
|
252 |
-
"execution_count":
|
253 |
"metadata": {},
|
254 |
"outputs": [
|
255 |
{
|
256 |
"name": "stdout",
|
257 |
"output_type": "stream",
|
258 |
"text": [
|
259 |
-
"{'analyst': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"location\":\"นวมินทร์ 71\"}', 'name': 'find_place_from_text'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 335, 'total_tokens': 357}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': '
|
260 |
"----\n",
|
261 |
-
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"location\":\"นวมินทร์ 71
|
262 |
"----\n",
|
263 |
-
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"
|
264 |
"----\n",
|
265 |
-
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"
|
266 |
"----\n",
|
267 |
-
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"
|
268 |
"----\n",
|
269 |
-
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"
|
270 |
"----\n",
|
271 |
-
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"
|
272 |
"----\n",
|
273 |
-
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"
|
274 |
"----\n",
|
275 |
-
"{'reporter': {'messages': [AIMessage(content='
|
276 |
"----\n",
|
277 |
-
"{'data collector': {'messages': [AIMessage(content='
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
"----\n"
|
279 |
]
|
280 |
},
|
281 |
{
|
282 |
"ename": "GraphRecursionError",
|
283 |
-
"evalue": "Recursion limit of
|
284 |
"output_type": "error",
|
285 |
"traceback": [
|
286 |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
287 |
"\u001b[0;31mGraphRecursionError\u001b[0m Traceback (most recent call last)",
|
288 |
-
"Cell \u001b[0;32mIn[
|
289 |
"File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langgraph/pregel/__init__.py:1038\u001b[0m, in \u001b[0;36mPregel.stream\u001b[0;34m(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug)\u001b[0m\n\u001b[1;32m 1036\u001b[0m \u001b[38;5;66;03m# handle exit\u001b[39;00m\n\u001b[1;32m 1037\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m loop\u001b[38;5;241m.\u001b[39mstatus \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mout_of_steps\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m-> 1038\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m GraphRecursionError(\n\u001b[1;32m 1039\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRecursion limit of \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mconfig[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrecursion_limit\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m reached \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1040\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mwithout hitting a stop condition. You can increase the \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1041\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlimit by setting the `recursion_limit` config key.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1042\u001b[0m )\n\u001b[1;32m 1043\u001b[0m \u001b[38;5;66;03m# set final channel values as run output\u001b[39;00m\n\u001b[1;32m 1044\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_chain_end(read_channels(loop\u001b[38;5;241m.\u001b[39mchannels, output_keys))\n",
|
290 |
-
"\u001b[0;31mGraphRecursionError\u001b[0m: Recursion limit of
|
291 |
]
|
292 |
}
|
293 |
],
|
|
|
205 |
" workflow.add_conditional_edges(\n",
|
206 |
" meta[\"name\"],\n",
|
207 |
" router,\n",
|
208 |
+
" {\"continue\": meta['continue'], \"call_tool\": \"call_tool\", \"__end__\": END} if meta[\"name\"]==\"data collector\" else {\"continue\": meta['continue'], \"__end__\": END},\n",
|
209 |
" )\n",
|
210 |
"\n",
|
211 |
"workflow.add_conditional_edges(\n",
|
|
|
249 |
},
|
250 |
{
|
251 |
"cell_type": "code",
|
252 |
+
"execution_count": 9,
|
253 |
"metadata": {},
|
254 |
"outputs": [
|
255 |
{
|
256 |
"name": "stdout",
|
257 |
"output_type": "stream",
|
258 |
"text": [
|
259 |
+
"{'analyst': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"location\":\"นวมินทร์ 71\"}', 'name': 'find_place_from_text'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 335, 'total_tokens': 357}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='analyst', id='run-258145dd-989c-47e8-b808-9605a218a7c9-0')], 'sender': 'analyst'}}\n",
|
260 |
"----\n",
|
261 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"location\":\"นวมินทร์ 71\"}', 'name': 'find_place_from_text'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 333, 'total_tokens': 355}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_507c9469a1', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-a6d8ab7d-108c-4e55-acb3-f0efddd3c08b-0')], 'sender': 'data collector'}}\n",
|
262 |
"----\n",
|
263 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"ร้านอาหาร\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 40, 'prompt_tokens': 408, 'total_tokens': 448}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-dbbb13d7-b770-4f99-9117-05908d44103b-0')], 'sender': 'reporter'}}\n",
|
264 |
"----\n",
|
265 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 401, 'total_tokens': 440}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-b3e48624-f692-4261-ad56-c01e0429afde-0')], 'sender': 'data collector'}}\n",
|
266 |
"----\n",
|
267 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 493, 'total_tokens': 532}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-5fbf68b6-e2e0-42f2-b978-9f3cde178693-0')], 'sender': 'reporter'}}\n",
|
268 |
"----\n",
|
269 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 485, 'total_tokens': 524}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-099fb223-8be9-48f5-bf6f-af3a697172e0-0')], 'sender': 'data collector'}}\n",
|
270 |
"----\n",
|
271 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 577, 'total_tokens': 616}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-2a83ea1e-5777-48aa-82bc-57c601e29a4b-0')], 'sender': 'reporter'}}\n",
|
272 |
"----\n",
|
273 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 569, 'total_tokens': 608}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-e836fa27-c007-4741-90f2-bd8acdf1cd01-0')], 'sender': 'data collector'}}\n",
|
274 |
"----\n",
|
275 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"ร้านอาหาร\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 40, 'prompt_tokens': 661, 'total_tokens': 701}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-ae137b63-1be4-4859-9f9f-4315632b99e7-0')], 'sender': 'reporter'}}\n",
|
276 |
"----\n",
|
277 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":500,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 39, 'prompt_tokens': 654, 'total_tokens': 693}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-cc93ad4f-888e-466f-a29e-03653a7709a7-0')], 'sender': 'data collector'}}\n",
|
278 |
+
"----\n",
|
279 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"ร้านอาหาร\",\"location_name\":\"นวมินทร์ 71\",\"radius\":1000,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 746, 'total_tokens': 787}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-2be60a63-ce04-4f94-8ba9-29969b6f6b4f-0')], 'sender': 'reporter'}}\n",
|
280 |
+
"----\n",
|
281 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":1000,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 40, 'prompt_tokens': 740, 'total_tokens': 780}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-f0783436-107b-4513-bebc-f59ff1028878-0')], 'sender': 'data collector'}}\n",
|
282 |
+
"----\n",
|
283 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"ร้านอาหาร\",\"location_name\":\"นวมินทร์ 71\",\"radius\":1000,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 833, 'total_tokens': 874}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-bc595713-4ab3-4b26-a9fa-ab2a73f66f86-0')], 'sender': 'reporter'}}\n",
|
284 |
+
"----\n",
|
285 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"restaurant\",\"location_name\":\"นวมินทร์ 71\",\"radius\":1000,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 40, 'prompt_tokens': 827, 'total_tokens': 867}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-5ae4ab19-ae02-4d06-ab74-20f06c34f6fb-0')], 'sender': 'data collector'}}\n",
|
286 |
+
"----\n",
|
287 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"input_dict\":{\"keyword\":\"ร้านอาหาร\",\"location_name\":\"นวมินทร์ 71\",\"radius\":1000,\"place_type\":\"restaurant\"}}', 'name': 'nearby_search'}}, response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 920, 'total_tokens': 961}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_507c9469a1', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-8287ca4f-d479-4ec8-b4ef-57188ebb2d3a-0')], 'sender': 'reporter'}}\n",
|
288 |
"----\n"
|
289 |
]
|
290 |
},
|
291 |
{
|
292 |
"ename": "GraphRecursionError",
|
293 |
+
"evalue": "Recursion limit of 15 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.",
|
294 |
"output_type": "error",
|
295 |
"traceback": [
|
296 |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
297 |
"\u001b[0;31mGraphRecursionError\u001b[0m Traceback (most recent call last)",
|
298 |
+
"Cell \u001b[0;32mIn[9], line 14\u001b[0m\n\u001b[1;32m 1\u001b[0m graph \u001b[38;5;241m=\u001b[39m workflow\u001b[38;5;241m.\u001b[39mcompile()\n\u001b[1;32m 3\u001b[0m events \u001b[38;5;241m=\u001b[39m graph\u001b[38;5;241m.\u001b[39mstream(\n\u001b[1;32m 4\u001b[0m {\n\u001b[1;32m 5\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmessages\u001b[39m\u001b[38;5;124m\"\u001b[39m: [\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 12\u001b[0m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrecursion_limit\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;241m15\u001b[39m},\n\u001b[1;32m 13\u001b[0m )\n\u001b[0;32m---> 14\u001b[0m \u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43ms\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mevents\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 15\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mprint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 16\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mprint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m----\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
299 |
"File \u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langgraph/pregel/__init__.py:1038\u001b[0m, in \u001b[0;36mPregel.stream\u001b[0;34m(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug)\u001b[0m\n\u001b[1;32m 1036\u001b[0m \u001b[38;5;66;03m# handle exit\u001b[39;00m\n\u001b[1;32m 1037\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m loop\u001b[38;5;241m.\u001b[39mstatus \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mout_of_steps\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m-> 1038\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m GraphRecursionError(\n\u001b[1;32m 1039\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRecursion limit of \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mconfig[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrecursion_limit\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m reached \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1040\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mwithout hitting a stop condition. You can increase the \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1041\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlimit by setting the `recursion_limit` config key.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 1042\u001b[0m )\n\u001b[1;32m 1043\u001b[0m \u001b[38;5;66;03m# set final channel values as run output\u001b[39;00m\n\u001b[1;32m 1044\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_chain_end(read_channels(loop\u001b[38;5;241m.\u001b[39mchannels, output_keys))\n",
|
300 |
+
"\u001b[0;31mGraphRecursionError\u001b[0m: Recursion limit of 15 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key."
|
301 |
]
|
302 |
}
|
303 |
],
|
chatbot_multiagent.py
CHANGED
@@ -181,7 +181,7 @@ for meta in agent_meta:
|
|
181 |
workflow.add_conditional_edges(
|
182 |
meta["name"],
|
183 |
router,
|
184 |
-
{"continue": meta['continue'], "call_tool": "call_tool", "__end__": END},
|
185 |
)
|
186 |
|
187 |
workflow.add_conditional_edges(
|
|
|
181 |
workflow.add_conditional_edges(
|
182 |
meta["name"],
|
183 |
router,
|
184 |
+
{"continue": meta['continue'], "call_tool": "call_tool", "__end__": END} if meta["name"]=="data collector" else {"continue": meta['continue'], "__end__": END},
|
185 |
)
|
186 |
|
187 |
workflow.add_conditional_edges(
|