Spaces:
Runtime error
Runtime error
Upload 17 files
Browse files- chatbot_multiagent.ipynb +31 -7
- prompt.json +1 -1
chatbot_multiagent.ipynb
CHANGED
@@ -249,22 +249,46 @@
|
|
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\":\"
|
260 |
"----\n",
|
261 |
-
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"
|
262 |
"----\n",
|
263 |
-
"{'reporter': {'messages': [AIMessage(content='
|
264 |
"----\n",
|
265 |
-
"{'data collector': {'messages': [AIMessage(content='
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
"----\n"
|
267 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
],
|
270 |
"source": [
|
@@ -274,12 +298,12 @@
|
|
274 |
" {\n",
|
275 |
" \"messages\": [\n",
|
276 |
" HumanMessage(\n",
|
277 |
-
" content=\"
|
278 |
" )\n",
|
279 |
" ],\n",
|
280 |
" },\n",
|
281 |
" # Maximum number of steps to take in the graph\n",
|
282 |
-
" {\"recursion_limit\":
|
283 |
")\n",
|
284 |
"for s in events:\n",
|
285 |
" print(s)\n",
|
|
|
249 |
},
|
250 |
{
|
251 |
"cell_type": "code",
|
252 |
+
"execution_count": 8,
|
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_507c9469a1', 'finish_reason': 'function_call', 'logprobs': None}, name='analyst', id='run-364a4721-9a93-44fa-9a52-775ed65fce98-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': 24, 'prompt_tokens': 333, 'total_tokens': 357}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-4c69ccd0-2dff-45cb-9961-23c4fa3c5caf-0')], 'sender': 'data collector'}}\n",
|
262 |
"----\n",
|
263 |
+
"{'reporter': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"location\":\"นวมินทร์ 71\"}', 'name': 'find_place_from_text'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 410, 'total_tokens': 432}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-74b33ab4-fa8d-4244-8a9e-a50214c87162-0')], 'sender': 'reporter'}}\n",
|
264 |
"----\n",
|
265 |
+
"{'data collector': {'messages': [AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"location\":\"นวมินทร์ 71, กรุงเทพมหานคร, ไทย\"}', 'name': 'find_place_from_text'}}, response_metadata={'token_usage': {'completion_tokens': 26, 'prompt_tokens': 385, 'total_tokens': 411}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-922d93a6-233d-4946-857d-0fa7672e3825-0')], 'sender': 'data collector'}}\n",
|
266 |
+
"----\n",
|
267 |
+
"{'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': 44, 'prompt_tokens': 464, 'total_tokens': 508}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-a5611413-8372-4019-9835-7fc372753217-0')], 'sender': 'reporter'}}\n",
|
268 |
+
"----\n",
|
269 |
+
"{'data collector': {'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': 461, 'total_tokens': 502}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-a38c3339-7f1d-4368-845f-1bb43f4df107-0')], 'sender': 'data collector'}}\n",
|
270 |
+
"----\n",
|
271 |
+
"{'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': 45, 'prompt_tokens': 555, 'total_tokens': 600}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_507c9469a1', 'finish_reason': 'function_call', 'logprobs': None}, name='reporter', id='run-aa6417ad-5890-4eba-97fc-38a5adc9687a-0')], 'sender': 'reporter'}}\n",
|
272 |
+
"----\n",
|
273 |
+
"{'data collector': {'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': 553, 'total_tokens': 594}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'function_call', 'logprobs': None}, name='data collector', id='run-6a5a11fd-a81f-4e1b-85ea-2b919169b15e-0')], 'sender': 'data collector'}}\n",
|
274 |
+
"----\n",
|
275 |
+
"{'reporter': {'messages': [AIMessage(content='ได้ทำการค้นหาร้านอาหารแถวนวมินทร์ 71 แล้ว ขอสรุปผลการค้นหาดังนี้:\\n\\n1. **จำนวนร้านอาหาร**: ในระยะ 1 กิโลเมตรรอบ ๆ นวมินทร์ 71 มีร้านอาหารหลายแห่งที่เปิดให้บริการ ซึ่งแสดงให้เห็นถึงความต้องการและความสนใจในการรับประทานอาหารในพื้นที่นี้\\n\\n2. **ประเภทของร้านอาหาร**: ร้านอาหารที่พบมีหลายประเภท ตั้งแต่อาหารไทย, อาหารจีน, อาหารญี่ปุ่น, จนถึงฟาสต์ฟู้ด ซึ่งทำให้มีความหลากหลายในการเล���อกใช้บริการ\\n\\n3. **การแข่งขัน**: เนื่องจากมีร้านอาหารอยู่หลายแห่งในบริเวณนี้ จึงมีการแข่งขันที่สูง ซึ่งอาจจะต้องพิจารณาในเรื่องของคุณภาพอาหาร, ราคา, และการบริการ เพื่อดึงดูดลูกค้า\\n\\n4. **โอกาสในการเปิดร้าน**: หากสามารถนำเสนอแนวคิดหรือเมนูที่แตกต่างจากที่มีอยู่ในตลาด หรือสร้างบรรยากาศที่ดึงดูดลูกค้า จะสามารถแข่งขันได้ในตลาดนี้\\n\\n5. **ลูกค้าเป้าหมาย**: ควรพิจารณากลุ่มลูกค้าในบริเวณนี้ เช่น คนทำงาน, นักเรียน, หรือครอบครัว เพื่อการตลาดที่มีประสิทธิภาพ\\n\\nจากข้อมูลที่ได้รับ การเปิดร้านอาหารแถวนวมินทร์ 71 มีโอกาสที่ดี แต่ก็ต้องมีการวางแผนและกลยุทธ์การตลาดที่เหมาะสมเพื่อตอบสนองความต้องการของลูกค้าในพื้นที่นี้ให้ได้ดีที่สุด', response_metadata={'token_usage': {'completion_tokens': 364, 'prompt_tokens': 647, 'total_tokens': 1011}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'stop', 'logprobs': None}, name='reporter', id='run-83a4c073-9917-42c2-97b2-7ba11bbda1a3-0')], 'sender': 'reporter'}}\n",
|
276 |
+
"----\n",
|
277 |
+
"{'data collector': {'messages': [AIMessage(content='FINAL ANSWER: การเปิดร้านอาหารแถวนวมินทร์ 71 มีโอกาสที่ดี เนื่องจากมีร้านอาหารหลายแห่งในพื้นที่ แสดงถึงความต้องการในการรับประทานอาหาร แต่ก็มีการแข่งขันที่สูง ดังนั้นควรพิจารณาในเรื่องของคุณภาพอาหาร, ราคา, และการบริการ เพื่อดึงดูดลูกค้า รวมถึงการออกแบบเมนูที่แตกต่างและกลยุทธ์การตลาดที่เหมาะสมเพื่อตอบสนองความต้องการของลูกค้าในพื้นที่.', response_metadata={'token_usage': {'completion_tokens': 117, 'prompt_tokens': 964, 'total_tokens': 1081}, 'model_name': 'gpt-4o-mini', 'system_fingerprint': 'fp_48196bc67a', 'finish_reason': 'stop', 'logprobs': None}, name='data collector', id='run-380be5c9-29d1-43e9-91b9-afb5caf0d15a-0')], 'sender': 'data collector'}}\n",
|
278 |
"----\n"
|
279 |
]
|
280 |
+
},
|
281 |
+
{
|
282 |
+
"ename": "GraphRecursionError",
|
283 |
+
"evalue": "Recursion limit of 10 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.",
|
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[8], 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;241m10\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",
|
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 10 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key."
|
291 |
+
]
|
292 |
}
|
293 |
],
|
294 |
"source": [
|
|
|
298 |
" {\n",
|
299 |
" \"messages\": [\n",
|
300 |
" HumanMessage(\n",
|
301 |
+
" content=\"วิเคราะห์ความเป็นไปได้ในการเปิดร้านอาหารแถวนวมินทร์ 71\"\n",
|
302 |
" )\n",
|
303 |
" ],\n",
|
304 |
" },\n",
|
305 |
" # Maximum number of steps to take in the graph\n",
|
306 |
+
" {\"recursion_limit\": 15},\n",
|
307 |
")\n",
|
308 |
"for s in events:\n",
|
309 |
" print(s)\n",
|
prompt.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
},
|
12 |
{
|
13 |
"name": "reporter",
|
14 |
-
"prompt": "You are the Reporter responsible for compiling the data into a clear and informative report for the user. When you receive the data from the Data Collector, you will: Organize and analyze the data to generate insights about the competitive landscape and market opportunities at the specified location. Create a well-structured report that provides the user with actionable recommendations based on the analysis. Ensure the report is clear, concise, and delivered in the same language as the user's original request. If you want to respond to user, you should to respond to the same language as the user's original request. Except the
|
15 |
"continue": "data collector"
|
16 |
}
|
17 |
]
|
|
|
11 |
},
|
12 |
{
|
13 |
"name": "reporter",
|
14 |
+
"prompt": "You are the Reporter responsible for compiling the data into a clear and informative report for the user. When you receive the data from the Data Collector, you will: Organize and analyze the data to generate insights about the competitive landscape and market opportunities at the specified location. Create a well-structured report that provides the user with actionable recommendations based on the analysis. Ensure the report is clear, concise, and delivered in the same language as the user's original request. If you want to respond to user, you should to respond to the same language as the user's original request. Except the FINAL ANSWER keep it the same.",
|
15 |
"continue": "data collector"
|
16 |
}
|
17 |
]
|