{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import utils\n", "\n", "utils.load_env()\n", "os.environ['LANGCHAIN_TRACING_V2'] = \"true\"" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:141: LangChainDeprecationWarning: The class `ChatOpenAI` was deprecated in LangChain 0.0.10 and will be removed in 0.3.0. An updated version of the class exists in the langchain-openai package and should be used instead. To use it run `pip install -U langchain-openai` and import as `from langchain_openai import ChatOpenAI`.\n", " warn_deprecated(\n", "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:141: LangChainDeprecationWarning: The function `format_tool_to_openai_function` was deprecated in LangChain 0.1.16 and will be removed in 1.0. Use langchain_core.utils.function_calling.convert_to_openai_function() instead.\n", " warn_deprecated(\n" ] } ], "source": [ "from langchain_core.messages import HumanMessage\n", "\n", "# for llm model\n", "from langchain_openai import ChatOpenAI\n", "from langchain.agents.format_scratchpad import format_to_openai_function_messages\n", "from tools import find_place_from_text, nearby_search\n", "from typing import Dict, List, Tuple\n", "from langchain.agents import (\n", " AgentExecutor,\n", ")\n", "from langchain.agents.output_parsers import OpenAIFunctionsAgentOutputParser\n", "from langchain_community.chat_models import ChatOpenAI\n", "from langchain_community.tools.convert_to_openai import format_tool_to_openai_function\n", "from langchain_core.messages import AIMessage, HumanMessage\n", "from langchain_core.pydantic_v1 import BaseModel, Field\n", "from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n", "\n", "# Bind the tools to the model\n", "tools = [find_place_from_text, nearby_search] # Include both tools if needed\n", "\n", "llm = ChatOpenAI(model=\"gpt-4o-mini\")\n", "\n", "llm_with_tools = llm.bind(functions=[format_tool_to_openai_function(t) for t in tools])\n", "\n", "def _format_chat_history(chat_history: List[Tuple[str, str]]):\n", " buffer = []\n", " for human, ai in chat_history:\n", " buffer.append(HumanMessage(content=human))\n", " buffer.append(AIMessage(content=ai))\n", " return buffer\n", "\n", "meta = utils.load_agent_meta()[0]\n", "\n", "prompt = ChatPromptTemplate.from_messages(\n", " [\n", " (\"system\", meta['prompt']),\n", " MessagesPlaceholder(variable_name=\"chat_history\"),\n", " (\"user\", \"{input}\"),\n", " MessagesPlaceholder(variable_name=\"agent_scratchpad\"),\n", " ]\n", ")\n", "\n", "agent = (\n", " {\n", " \"input\": lambda x: x[\"input\"],\n", " \"chat_history\": lambda x: _format_chat_history(x[\"chat_history\"]),\n", " \"agent_scratchpad\": lambda x: format_to_openai_function_messages(\n", " x[\"intermediate_steps\"]\n", " ),\n", " }\n", " | prompt\n", " | llm_with_tools\n", " | OpenAIFunctionsAgentOutputParser()\n", ")\n", "\n", "\n", "class AgentInput(BaseModel):\n", " input: str\n", " chat_history: List[Tuple[str, str]] = Field(\n", " ..., extra={\"widget\": {\"type\": \"chat\", \"input\": \"input\", \"output\": \"output\"}}\n", " )\n", "\n", "\n", "agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True).with_types(\n", " input_type=AgentInput\n", ")\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32;1m\u001b[1;3m\n", "Invoking: `nearby_search` with `{'input_dict': {'keyword': 'coffee shop', 'location_name': 'มาบุญครอง', 'radius': 1500, 'place_type': 'cafe'}}`\n", "\n", "\n", "\u001b[0m" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n", "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[33;1m\u001b[1;3m\n", " address: 991/1 Rama I Rd, Pathum Wan\n", "\n", " location: {'lat': 13.7458781, 'lng': 100.5341476}\n", "\n", " name: BEANS Coffee Roaster Paragon\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 5\n", "\n", " plus code: 7P52PGWM+9M\n", "\n", "\n", " \n", " address: 43/4 Rama VI Rd, Rong Muang, Pathum Wan\n", "\n", " location: {'lat': 13.7497223, 'lng': 100.521221}\n", "\n", " name: Olympic Coffee\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.8\n", "\n", " plus code: 7P52PGXC+VF\n", "\n", "\n", " \n", " address: 994 Makkasan, Ratchathewi\n", "\n", " location: {'lat': 13.7495947, 'lng': 100.5426623}\n", "\n", " name: Earthy Roaster (Specialty Coffee)\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.8\n", "\n", " plus code: 7P52PGXV+R3\n", "\n", "\n", " \n", " address: MINT TOWER Bantadthong Phetchaburi Rd, Subdistrict Pathum Wan\n", "\n", " location: {'lat': 13.7450255, 'lng': 100.5235735}\n", "\n", " name: Treasure specialty coffee\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.9\n", "\n", " plus code: 7P52PGWF+2C\n", "\n", "\n", " \n", " address: ตึก Gaysorn Amarin (ชั้น 2 496-502 Phloen Chit Rd, Khwaeng Lumphini, Pathum Wan\n", "\n", " location: {'lat': 13.7439676, 'lng': 100.5413037}\n", "\n", " name: The Basic Coffee BKK\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.7\n", "\n", " plus code: 7P52PGVR+HG\n", "\n", "\n", " \n", " address: 126 ซ. จุฬาลงกรณ์ 50 Wang Mai, Pathum Wan\n", "\n", " location: {'lat': 13.7344961, 'lng': 100.5268998}\n", "\n", " name: CRANNIES Coffee & Brunch\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 5\n", "\n", " plus code: 7P52PGMG+RQ\n", "\n", "\n", " \n", " address: 85 1 Akkharanithi Alley, Thanon Phaya Thai, Ratchathewi\n", "\n", " location: {'lat': 13.7537094, 'lng': 100.5328794}\n", "\n", " name: Bullet Thai Craft Beer\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 5\n", "\n", " plus code: 7P52QG3M+F5\n", "\n", "\n", " \n", " address: 36, 6 Kasem San 1 Alley, Wang Mai, Pathum Wan\n", "\n", " location: {'lat': 13.7477989, 'lng': 100.5296324}\n", "\n", " name: Sip 'n Drip\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.9\n", "\n", " plus code: 7P52PGXH+4V\n", "\n", "\n", " \n", " address: 502, ห้างสรรพสินค้าอัมรินทร์ พลาซ่า ชั้น 1, Phloen Chit Rd, Lumphini, Pathum Wan\n", "\n", " location: {'lat': 13.743762, 'lng': 100.541402}\n", "\n", " name: TABLA Craft Coffee\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.6\n", "\n", " plus code: 7P52PGVR+GH\n", "\n", "\n", " \n", " address: Velaa Sindhorn Village Langsuan, 87 Soi Langsuan, Lumphini, Pathum Wan\n", "\n", " location: {'lat': 13.7365082, 'lng': 100.5428638}\n", "\n", " name: The Coffee Academics\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.4\n", "\n", " plus code: 7P52PGPV+J4\n", "\n", "\n", " \n", " address: 445 Rama I Rd, Rong Muang, Pathum Wan\n", "\n", " location: {'lat': 13.7476317, 'lng': 100.5232939}\n", "\n", " name: D Coffee House\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.9\n", "\n", " plus code: 7P52PGXF+38\n", "\n", "\n", " \n", " address: ศูนย์รวมนักศึกษาแบ๊บติสต์ 473 Thanon Si Ayutthaya, Thung Phaya Thai, Ratchathewi\n", "\n", " location: {'lat': 13.758337, 'lng': 100.534177}\n", "\n", " name: Baptist coffee\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 5\n", "\n", " plus code: 7P52QG5M+8M\n", "\n", "\n", " \n", " address: 1/11 Rong Muang 5 Alley, Rong Muang, Pathum Wan\n", "\n", " location: {'lat': 13.7466928, 'lng': 100.5227848}\n", "\n", " name: Greatercafe Specialty Coffee Bangkok\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.7\n", "\n", " plus code: 7P52PGWF+M4\n", "\n", "\n", " \n", " address: Bldg., 1 st Fl 320 TangHuaPak (Hualamphong Rama IV Rd, Mahapruettaram Bang Rak\n", "\n", " location: {'lat': 13.7374409, 'lng': 100.5165419}\n", "\n", " name: Better Coffee\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 5\n", "\n", " plus code: 7P52PGP8+XJ\n", "\n", "\n", " \n", " address: อาคารหอศิลปวัฒนธรรมแห่งกรุงเทพมหานคร(BACC) 939 Rama I Rd, Wang Mai, Pathum Wan\n", "\n", " location: {'lat': 13.7466896, 'lng': 100.5304572}\n", "\n", " name: Gallery Drip Coffee\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.6\n", "\n", " plus code: 7P52PGWJ+M5\n", "\n", "\n", " \n", " address: 27 ซอย จุฬาลงกรณ์ 20 Wang Mai, Pathum Wan\n", "\n", " location: {'lat': 13.7408514, 'lng': 100.5230725}\n", "\n", " name: mm : MAKE MERRY\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.8\n", "\n", " plus code: 7P52PGRF+86\n", "\n", "\n", " \n", " address: 2nd Floor Siam Square One 388 Rama I Rd, Pathum Wan\n", "\n", " location: {'lat': 13.7446247, 'lng': 100.5340785}\n", "\n", " name: GATTA CAFé\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.9\n", "\n", " plus code: 7P52PGVM+RJ\n", "\n", "\n", " \n", " address: 1873 Rama IV Rd, Khlong Tan Nuea, Watthana\n", "\n", " location: {'lat': 13.7335441, 'lng': 100.5377224}\n", "\n", " name: Redwood coffee and eatery\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.8\n", "\n", " plus code: 7P52PGMQ+C3\n", "\n", "\n", " \n", " address: B1 The Offices At Central World ชั้น 104 Rama I Rd, Pathum Wan\n", "\n", " location: {'lat': 13.7458267, 'lng': 100.5381669}\n", "\n", " name: Baankhunlek coffee สาขา CentralworldOffices\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 5\n", "\n", " plus code: 7P52PGWQ+87\n", "\n", "\n", " \n", " address: 3rd Floor, CentralWorld, Ratchadamri Rd, Pathum Wan\n", "\n", " location: {'lat': 13.7470656, 'lng': 100.5397062}\n", "\n", " name: Café BAGA Central World\n", "\n", " opening hours: {'open_now': True}\n", "\n", " rating: 4.7\n", "\n", " plus code: 7P52PGWQ+RV\n", "\n", "\n", " \u001b[0m" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Unable to load requested LangChainTracer. To disable this warning, unset the LANGCHAIN_TRACING_V2 environment variables.\n", "LangSmithUserError('API key must be provided when using hosted LangSmith API')\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32;1m\u001b[1;3mHere is a list of coffee shops near มาบุญครอง (MBK Center):\n", "\n", "1. **BEANS Coffee Roaster Paragon**\n", " - Address: 991/1 Rama I Rd, Pathum Wan\n", " - Rating: 5.0\n", " - Open Now: Yes\n", "\n", "2. **Olympic Coffee**\n", " - Address: 43/4 Rama VI Rd, Rong Muang, Pathum Wan\n", " - Rating: 4.8\n", " - Open Now: Yes\n", "\n", "3. **Earthy Roaster (Specialty Coffee)**\n", " - Address: 994 Makkasan, Ratchathewi\n", " - Rating: 4.8\n", " - Open Now: Yes\n", "\n", "4. **Treasure specialty coffee**\n", " - Address: MINT TOWER Bantadthong Phetchaburi Rd, Pathum Wan\n", " - Rating: 4.9\n", " - Open Now: Yes\n", "\n", "5. **The Basic Coffee BKK**\n", " - Address: ตึก Gaysorn Amarin, ชั้น 2 496-502 Phloen Chit Rd, Khwaeng Lumphini, Pathum Wan\n", " - Rating: 4.7\n", " - Open Now: Yes\n", "\n", "6. **CRANNIES Coffee & Brunch**\n", " - Address: 126 ซ. จุฬาลงกรณ์ 50 Wang Mai, Pathum Wan\n", " - Rating: 5.0\n", " - Open Now: Yes\n", "\n", "7. **Bullet Thai Craft Beer**\n", " - Address: 85 1 Akkharanithi Alley, Thanon Phaya Thai, Ratchathewi\n", " - Rating: 5.0\n", " - Open Now: Yes\n", "\n", "8. **Sip 'n Drip**\n", " - Address: 36, 6 Kasem San 1 Alley, Wang Mai, Pathum Wan\n", " - Rating: 4.9\n", " - Open Now: Yes\n", "\n", "9. **TABLA Craft Coffee**\n", " - Address: 502, ห้างสรรพสินค้าอัมรินทร์ พลาซ่า ชั้น 1, Phloen Chit Rd, Lumphini, Pathum Wan\n", " - Rating: 4.6\n", " - Open Now: Yes\n", "\n", "10. **The Coffee Academics**\n", " - Address: Velaa Sindhorn Village Langsuan, 87 Soi Langsuan, Lumphini, Pathum Wan\n", " - Rating: 4.4\n", " - Open Now: Yes\n", "\n", "11. **D Coffee House**\n", " - Address: 445 Rama I Rd, Rong Muang, Pathum Wan\n", " - Rating: 4.9\n", " - Open Now: Yes\n", "\n", "12. **Baptist coffee**\n", " - Address: ศูนย์รวมนักศึกษาแบ๊บติสต์ 473 Thanon Si Ayutthaya, Thung Phaya Thai, Ratchathewi\n", " - Rating: 5.0\n", " - Open Now: Yes\n", "\n", "13. **Greatercafe Specialty Coffee Bangkok**\n", " - Address: 1/11 Rong Muang 5 Alley, Rong Muang, Pathum Wan\n", " - Rating: 4.7\n", " - Open Now: Yes\n", "\n", "14. **Better Coffee**\n", " - Address: Bldg., 1 st Fl 320 TangHuaPak (Hualamphong Rama IV Rd, Mahapruettaram Bang Rak\n", " - Rating: 5.0\n", " - Open Now: Yes\n", "\n", "15. **Gallery Drip Coffee**\n", " - Address: อาคารหอศิลปวัฒนธรรมแห่งกรุงเทพมหานคร(BACC) 939 Rama I Rd, Wang Mai, Pathum Wan\n", " - Rating: 4.6\n", " - Open Now: Yes\n", "\n", "16. **mm : MAKE MERRY**\n", " - Address: 27 ซอย จุฬาลงกรณ์ 20 Wang Mai, Pathum Wan\n", " - Rating: 4.8\n", " - Open Now: Yes\n", "\n", "17. **GATTA CAFé**\n", " - Address: 2nd Floor Siam Square One 388 Rama I Rd, Pathum Wan\n", " - Rating: 4.9\n", " - Open Now: Yes\n", "\n", "18. **Redwood coffee and eatery**\n", " - Address: 1873 Rama IV Rd, Khlong Tan Nuea, Watthana\n", " - Rating: 4.8\n", " - Open Now: Yes\n", "\n", "19. **Baankhunlek coffee สาขา CentralworldOffices**\n", " - Address: B1 The Offices At Central World ชั้น 104 Rama I Rd, Pathum Wan\n", " - Rating: 5.0\n", " - Open Now: Yes\n", "\n", "20. **Café BAGA Central World**\n", " - Address: 3rd Floor, CentralWorld, Ratchadamri Rd, Pathum Wan\n", " - Rating: 4.7\n", " - Open Now: Yes\n", "\n", "These coffee shops are within a radius of approximately 1500 meters from MBK Center and are currently open.\u001b[0m\n", "\n", "\u001b[1m> Finished chain.\u001b[0m\n" ] }, { "data": { "text/plain": [ "\"Here is a list of coffee shops near มาบุญครอง (MBK Center):\\n\\n1. **BEANS Coffee Roaster Paragon**\\n - Address: 991/1 Rama I Rd, Pathum Wan\\n - Rating: 5.0\\n - Open Now: Yes\\n\\n2. **Olympic Coffee**\\n - Address: 43/4 Rama VI Rd, Rong Muang, Pathum Wan\\n - Rating: 4.8\\n - Open Now: Yes\\n\\n3. **Earthy Roaster (Specialty Coffee)**\\n - Address: 994 Makkasan, Ratchathewi\\n - Rating: 4.8\\n - Open Now: Yes\\n\\n4. **Treasure specialty coffee**\\n - Address: MINT TOWER Bantadthong Phetchaburi Rd, Pathum Wan\\n - Rating: 4.9\\n - Open Now: Yes\\n\\n5. **The Basic Coffee BKK**\\n - Address: ตึก Gaysorn Amarin, ชั้น 2 496-502 Phloen Chit Rd, Khwaeng Lumphini, Pathum Wan\\n - Rating: 4.7\\n - Open Now: Yes\\n\\n6. **CRANNIES Coffee & Brunch**\\n - Address: 126 ซ. จุฬาลงกรณ์ 50 Wang Mai, Pathum Wan\\n - Rating: 5.0\\n - Open Now: Yes\\n\\n7. **Bullet Thai Craft Beer**\\n - Address: 85 1 Akkharanithi Alley, Thanon Phaya Thai, Ratchathewi\\n - Rating: 5.0\\n - Open Now: Yes\\n\\n8. **Sip 'n Drip**\\n - Address: 36, 6 Kasem San 1 Alley, Wang Mai, Pathum Wan\\n - Rating: 4.9\\n - Open Now: Yes\\n\\n9. **TABLA Craft Coffee**\\n - Address: 502, ห้างสรรพสินค้าอัมรินทร์ พลาซ่า ชั้น 1, Phloen Chit Rd, Lumphini, Pathum Wan\\n - Rating: 4.6\\n - Open Now: Yes\\n\\n10. **The Coffee Academics**\\n - Address: Velaa Sindhorn Village Langsuan, 87 Soi Langsuan, Lumphini, Pathum Wan\\n - Rating: 4.4\\n - Open Now: Yes\\n\\n11. **D Coffee House**\\n - Address: 445 Rama I Rd, Rong Muang, Pathum Wan\\n - Rating: 4.9\\n - Open Now: Yes\\n\\n12. **Baptist coffee**\\n - Address: ศูนย์รวมนักศึกษาแบ๊บติสต์ 473 Thanon Si Ayutthaya, Thung Phaya Thai, Ratchathewi\\n - Rating: 5.0\\n - Open Now: Yes\\n\\n13. **Greatercafe Specialty Coffee Bangkok**\\n - Address: 1/11 Rong Muang 5 Alley, Rong Muang, Pathum Wan\\n - Rating: 4.7\\n - Open Now: Yes\\n\\n14. **Better Coffee**\\n - Address: Bldg., 1 st Fl 320 TangHuaPak (Hualamphong Rama IV Rd, Mahapruettaram Bang Rak\\n - Rating: 5.0\\n - Open Now: Yes\\n\\n15. **Gallery Drip Coffee**\\n - Address: อาคารหอศิลปวัฒนธรรมแห่งกรุงเทพมหานคร(BACC) 939 Rama I Rd, Wang Mai, Pathum Wan\\n - Rating: 4.6\\n - Open Now: Yes\\n\\n16. **mm : MAKE MERRY**\\n - Address: 27 ซอย จุฬาลงกรณ์ 20 Wang Mai, Pathum Wan\\n - Rating: 4.8\\n - Open Now: Yes\\n\\n17. **GATTA CAFé**\\n - Address: 2nd Floor Siam Square One 388 Rama I Rd, Pathum Wan\\n - Rating: 4.9\\n - Open Now: Yes\\n\\n18. **Redwood coffee and eatery**\\n - Address: 1873 Rama IV Rd, Khlong Tan Nuea, Watthana\\n - Rating: 4.8\\n - Open Now: Yes\\n\\n19. **Baankhunlek coffee สาขา CentralworldOffices**\\n - Address: B1 The Offices At Central World ชั้น 104 Rama I Rd, Pathum Wan\\n - Rating: 5.0\\n - Open Now: Yes\\n\\n20. **Café BAGA Central World**\\n - Address: 3rd Floor, CentralWorld, Ratchadamri Rd, Pathum Wan\\n - Rating: 4.7\\n - Open Now: Yes\\n\\nThese coffee shops are within a radius of approximately 1500 meters from MBK Center and are currently open.\"" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def submitUserMessage(user_input: str) -> str:\n", " responce = agent_executor.invoke({\"input\": user_input, \"chat_history\": []})\n", " return responce[\"output\"]\n", "\n", "submitUserMessage(\"ค้นหาร้านกาแฟใกล้มาบุญครอง\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 2 }