Add LangSmith run urls in time travel notebook

This commit is contained in:
Nuno Campos
2024-04-02 16:11:48 -07:00
parent d00d8913ca
commit f269db4d58
+129 -52
View File
@@ -402,7 +402,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"content='Hello Bob! How can I assist you today?' response_metadata={'token_usage': {'completion_tokens': 11, 'prompt_tokens': 86, 'total_tokens': 97}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-38594ccf-07c2-4fb5-a6bc-a6c36beb376f-0'\n"
"content='Hello Bob! How can I assist you today?' response_metadata={'token_usage': {'completion_tokens': 11, 'prompt_tokens': 86, 'total_tokens': 97}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-b5f3758d-1e41-4c18-9ea4-628a5dc9304a-0'\n"
]
}
],
@@ -415,6 +415,16 @@
" print(v)"
]
},
{
"cell_type": "markdown",
"id": "9230c0a7-bab8-4327-a9b4-f21e7a28d32a",
"metadata": {},
"source": [
"See LangSmith example run here https://smith.langchain.com/public/48931f97-3a33-453a-9150-e9cef6ec8cef/r\n",
"\n",
"Here you can see the \"agent\" node ran, and then \"should_continue\" returned \"end\" so the graph stopped execution there."
]
},
{
"cell_type": "markdown",
"id": "c161d511-0dc3-4824-b89e-0dbcf9a7a759",
@@ -432,8 +442,8 @@
{
"data": {
"text/plain": [
"[HumanMessage(content=\"hi! I'm bob\", id='4ade65af-ee09-4a95-b913-ba936f4fbf61'),\n",
" AIMessage(content='Hello Bob! How can I assist you today?', response_metadata={'token_usage': {'completion_tokens': 11, 'prompt_tokens': 86, 'total_tokens': 97}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-38594ccf-07c2-4fb5-a6bc-a6c36beb376f-0')]"
"[HumanMessage(content=\"hi! I'm bob\", id='9d441d6c-8e75-4fb1-b8d7-142d97f445f7'),\n",
" AIMessage(content='Hello Bob! How can I assist you today?', response_metadata={'token_usage': {'completion_tokens': 11, 'prompt_tokens': 86, 'total_tokens': 97}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-b5f3758d-1e41-4c18-9ea4-628a5dc9304a-0')]"
]
},
"execution_count": 11,
@@ -463,9 +473,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"content='' additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}} response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 111, 'total_tokens': 133}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None} id='run-d3da860e-8c39-4d4a-8841-f7e59d12d861-0'\n",
"content='[{\\'url\\': \\'https://weather.com/weather/hourbyhour/l/USCA0987:1:US\\', \\'content\\': \"recents\\\\nSpecialty Forecasts\\\\nHourly Weather-San Francisco, CA\\\\nBeach Hazard Statement\\\\nSaturday, November 25\\\\n5 pm\\\\nClear\\\\n6 pm\\\\nClear\\\\n7 pm\\\\nClear\\\\n8 pm\\\\nMostly Clear\\\\n9 pm\\\\nPartly Cloudy\\\\n10 pm\\\\nPartly Cloudy\\\\n11 pm\\\\nPartly Cloudy\\\\nSunday, November 26\\\\n12 am\\\\nPartly Cloudy\\\\n1 am\\\\nMostly Cloudy\\\\n2 am\\\\nMostly Cloudy\\\\n3 am\\\\nMostly Cloudy\\\\n4 am\\\\nCloudy\\\\n5 am\\\\nCloudy\\\\n6 am\\\\nMostly Cloudy\\\\n7 am\\\\nMostly Cloudy\\\\n8 am\\\\nMostly Cloudy\\\\n9 am\\\\nMostly Cloudy\\\\n10 am\\\\nPartly Cloudy\\\\n11 am\\\\nPartly Cloudy\\\\n12 pm\\\\nPartly Cloudy\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nPartly Cloudy\\\\n3 pm\\\\nPartly Cloudy\\\\n4 pm\\\\nPartly Cloudy\\\\n5 pm\\\\nPartly Cloudy\\\\n6 pm\\\\nPartly Cloudy\\\\n7 pm\\\\nPartly Cloudy\\\\n8 pm\\\\nPartly Cloudy\\\\n9 pm\\\\nMostly Clear\\\\n10 pm\\\\nMostly Clear\\\\n11 pm\\\\nMostly Clear\\\\nMonday, November 27\\\\n12 am\\\\nClear\\\\n1 am\\\\nMostly Clear\\\\n2 am\\\\nMostly Clear\\\\n3 am\\\\nPartly Cloudy\\\\n4 am\\\\nMostly Clear\\\\n5 am\\\\nMostly Clear\\\\n6 am\\\\nClear\\\\n7 am\\\\nClear\\\\n8 am\\\\nSunny\\\\n9 am\\\\nSunny\\\\n10 am\\\\nSunny\\\\n11 am\\\\nSunny\\\\n12 pm\\\\nMostly Sunny\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nMostly Sunny\\\\n3 pm\\\\nMostly Sunny\\\\n4 pm\\\\nPartly Cloudy\\\\nRadar\\\\nSafety First!\\\\n Don\\'t Miss\\\\nIrresistible\\\\nWeather Wonders\\\\nOur Amazing World\\\\nCelestial Symphony\\\\nFried Turkey Fail\\\\nLook At That!\\\\n Health & Activities\\\\nSeasonal Allergies and Pollen Count Forecast\\\\nNo pollen detected in your area\\\\nCold & Flu Forecast\\\\nFlu risk is low in your area\\\\nWe recognize our responsibility to use data and technology for good. Changes For Critters\\\\nHurricane Tracker\\\\nStay Safe\\\\nAir Quality Index\\\\nAir quality is considered satisfactory, and air pollution poses little or no risk.\\\\n Take control of your data.\\\\n\"}]' name='tavily_search_results_json' id='25805743-0dc3-4a28-80a1-0cd9e556e6ac'\n",
"content='The current weather in San Francisco is as follows:\\n- 5 pm: Clear\\n- 6 pm: Clear\\n- 7 pm: Clear\\n- 8 pm: Mostly Clear\\n- 9 pm: Partly Cloudy\\n\\nFor more detailed and updated information, you can visit [this link](https://weather.com/weather/hourbyhour/l/USCA0987:1:US).' response_metadata={'token_usage': {'completion_tokens': 84, 'prompt_tokens': 684, 'total_tokens': 768}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-45171cbb-b4bd-47cd-9ae5-51718d45904b-0'\n"
"content='' additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}} response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 111, 'total_tokens': 133}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None} id='run-86030ee6-69eb-4399-9ffb-cf31103ed095-0'\n",
"content='[{\\'url\\': \\'https://weather.com/weather/hourbyhour/l/USCA0987:1:US\\', \\'content\\': \"recents\\\\nSpecialty Forecasts\\\\nHourly Weather-San Francisco, CA\\\\nBeach Hazard Statement\\\\nSaturday, November 25\\\\n5 pm\\\\nClear\\\\n6 pm\\\\nClear\\\\n7 pm\\\\nClear\\\\n8 pm\\\\nMostly Clear\\\\n9 pm\\\\nPartly Cloudy\\\\n10 pm\\\\nPartly Cloudy\\\\n11 pm\\\\nPartly Cloudy\\\\nSunday, November 26\\\\n12 am\\\\nPartly Cloudy\\\\n1 am\\\\nMostly Cloudy\\\\n2 am\\\\nMostly Cloudy\\\\n3 am\\\\nMostly Cloudy\\\\n4 am\\\\nCloudy\\\\n5 am\\\\nCloudy\\\\n6 am\\\\nMostly Cloudy\\\\n7 am\\\\nMostly Cloudy\\\\n8 am\\\\nMostly Cloudy\\\\n9 am\\\\nMostly Cloudy\\\\n10 am\\\\nPartly Cloudy\\\\n11 am\\\\nPartly Cloudy\\\\n12 pm\\\\nPartly Cloudy\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nPartly Cloudy\\\\n3 pm\\\\nPartly Cloudy\\\\n4 pm\\\\nPartly Cloudy\\\\n5 pm\\\\nPartly Cloudy\\\\n6 pm\\\\nPartly Cloudy\\\\n7 pm\\\\nPartly Cloudy\\\\n8 pm\\\\nPartly Cloudy\\\\n9 pm\\\\nMostly Clear\\\\n10 pm\\\\nMostly Clear\\\\n11 pm\\\\nMostly Clear\\\\nMonday, November 27\\\\n12 am\\\\nClear\\\\n1 am\\\\nMostly Clear\\\\n2 am\\\\nMostly Clear\\\\n3 am\\\\nPartly Cloudy\\\\n4 am\\\\nMostly Clear\\\\n5 am\\\\nMostly Clear\\\\n6 am\\\\nClear\\\\n7 am\\\\nClear\\\\n8 am\\\\nSunny\\\\n9 am\\\\nSunny\\\\n10 am\\\\nSunny\\\\n11 am\\\\nSunny\\\\n12 pm\\\\nMostly Sunny\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nMostly Sunny\\\\n3 pm\\\\nMostly Sunny\\\\n4 pm\\\\nPartly Cloudy\\\\nRadar\\\\nSafety First!\\\\n Don\\'t Miss\\\\nIrresistible\\\\nWeather Wonders\\\\nOur Amazing World\\\\nCelestial Symphony\\\\nFried Turkey Fail\\\\nLook At That!\\\\n Health & Activities\\\\nSeasonal Allergies and Pollen Count Forecast\\\\nNo pollen detected in your area\\\\nCold & Flu Forecast\\\\nFlu risk is low in your area\\\\nWe recognize our responsibility to use data and technology for good. Changes For Critters\\\\nHurricane Tracker\\\\nStay Safe\\\\nAir Quality Index\\\\nAir quality is considered satisfactory, and air pollution poses little or no risk.\\\\n Take control of your data.\\\\n\"}]' name='tavily_search_results_json' id='89c58552-0092-4169-bff6-e1cb6c8fe321'\n",
"content='The current weather in San Francisco is as follows:\\n- 5 pm: Clear\\n- 6 pm: Clear\\n- 7 pm: Clear\\n- 8 pm: Mostly Clear\\n- 9 pm: Partly Cloudy\\n- 10 pm: Partly Cloudy\\n\\nFor more detailed weather information, you can visit [this link](https://weather.com/weather/hourbyhour/l/USCA0987:1:US).' response_metadata={'token_usage': {'completion_tokens': 93, 'prompt_tokens': 684, 'total_tokens': 777}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-11318f28-a516-4b5c-85f6-8d9775205db9-0'\n"
]
}
],
@@ -475,12 +485,20 @@
" print(v)"
]
},
{
"cell_type": "markdown",
"id": "c0ebc4b8-b2cc-4394-bb5a-8964bafa8d2d",
"metadata": {},
"source": [
"See LangSmith example run here https://smith.langchain.com/public/12ac5112-f550-4dc2-ae7c-4b813b9f65dd/r"
]
},
{
"cell_type": "markdown",
"id": "18d3141b-9f9a-4ad8-b475-400674848b16",
"metadata": {},
"source": [
"We can see it planned the tool execution, then executed the tool, and then emitted the final response. Let's see how we can have more control over this."
"We can see it planned the tool execution (ie the \"agent\" node), then \"should_continue\" edge returned \"continue\" so we proceeded to \"action\" node, which executed the tool, and then \"agent\" node emitted the final response, which made \"should_continue\" edge return \"end\". Let's see how we can have more control over this."
]
},
{
@@ -496,12 +514,12 @@
"id": "06aaa787-32fe-404b-abeb-5b2ed94309fd",
"metadata": {},
"source": [
"If you notice below, we added `interrupt_before=[\"action\"]` - this means that before any actions are taken we pause. This is a great moment to allow the user to correct and update the state! This is very useful when you want to have a human-in-the-loop to validate (and potentially change) the action to take. "
"If you notice below, we now will add `interrupt_before=[\"action\"]` - this means that before any actions are taken we pause. This is a great moment to allow the user to correct and update the state! This is very useful when you want to have a human-in-the-loop to validate (and potentially change) the action to take. "
]
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 16,
"id": "5a68afc0-606f-4294-a872-b2b563be0d69",
"metadata": {},
"outputs": [],
@@ -511,7 +529,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 14,
"id": "08ae8246-11d5-40e1-8567-361e5bef8917",
"metadata": {},
"outputs": [
@@ -519,7 +537,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"content='I apologize for the inconvenience. Let me provide you with the current weather in San Francisco.' additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}} response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 260, 'total_tokens': 301}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None} id='run-19d40ebd-d551-4e36-8bd4-ed6ae5256954-0'\n"
"content='' additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}} response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None} id='run-966f6180-3c8f-42d5-af89-906650c46ab5-0'\n"
]
}
],
@@ -530,6 +548,15 @@
" print(v)"
]
},
{
"cell_type": "markdown",
"id": "c53352c8-dcf7-48b5-940c-f75a279cb42c",
"metadata": {},
"source": [
"See LangSmith example run here https://smith.langchain.com/public/54d37892-9ff4-48a8-8be9-bb9ff537de68/r\n",
"This time it executed the \"agent\" node same as before, and you can see in the LangSmith trace that \"should_continue\" returned \"continue\", but it paused execution per our setting above."
]
},
{
"cell_type": "markdown",
"id": "7d9fa4f0-fb7d-47a7-b77e-464e8b619273",
@@ -540,7 +567,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 17,
"id": "5a53df78-6c25-4176-b049-02a02a713771",
"metadata": {},
"outputs": [
@@ -551,7 +578,7 @@
" 'name': 'tavily_search_results_json'}}"
]
},
"execution_count": 22,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -571,7 +598,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 18,
"id": "060e2e33-1f6a-40ef-850e-161b308986fb",
"metadata": {},
"outputs": [],
@@ -582,7 +609,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 19,
"id": "3210d003-e20e-47fa-b4f4-402fed7409f1",
"metadata": {},
"outputs": [
@@ -590,10 +617,10 @@
"data": {
"text/plain": [
"{'configurable': {'thread_id': '4',\n",
" 'thread_ts': '2024-04-02T21:49:50.740187+00:00'}}"
" 'thread_ts': '2024-04-02T23:05:41.595778+00:00'}}"
]
},
"execution_count": 24,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -602,6 +629,16 @@
"app_w_interrupt.update_state(thread, current_values.values)"
]
},
{
"cell_type": "markdown",
"id": "0a21b87a-319c-4a93-9ac1-a3c6ad3f5400",
"metadata": {},
"source": [
"This actually produces a LangSmith run too! See it here https://smith.langchain.com/public/0f3ed712-35a3-4a34-8353-85780dc1bd05/r\n",
"\n",
"This is a shorter run that allows you to inspect the edges that reacted to the state update, you can see \"should_continue\" returned \"continue\" as before, given this is still a function call."
]
},
{
"cell_type": "markdown",
"id": "3613f445-cf46-46a0-b7c1-e83a02aae96f",
@@ -612,23 +649,45 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 22,
"id": "4a7dfaab-bfa7-47c7-8b93-2b06b3560809",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0'), FunctionMessage(content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629', 'content': 'Hourly weather forecast in San Francisco, CA. Check current conditions in San Francisco, CA with radar, hourly, and more.'}]\", name='tavily_search_results_json', id='9db65c5e-aaa2-4ee7-b149-0e57d2db5bf6'), AIMessage(content=\"You can check the hourly weather forecast in San Francisco, CA on AccuWeather's website. Here is the [link](https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629) to view the current conditions.\", response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 186, 'total_tokens': 246}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-c09b1f88-5e55-4b65-b82d-054d4fb2522f-0'), HumanMessage(content='what is the weather in sf currently', id='98cec2a0-26f7-4b9f-9491-2a893f58c591'), AIMessage(content='I apologize for the inconvenience. Let me provide you with the current weather in San Francisco.', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 260, 'total_tokens': 301}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-19d40ebd-d551-4e36-8bd4-ed6ae5256954-0')], next=('action',), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T21:49:50.740187+00:00'}}, parent_config=None)"
"[HumanMessage(content='what is the weather in sf currently', id='06076c4e-40fe-4f44-978a-612fed60849c'),\n",
" AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-966f6180-3c8f-42d5-af89-906650c46ab5-0')]"
]
},
"execution_count": 25,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"app_w_interrupt.get_state(thread)"
"app_w_interrupt.get_state(thread).values"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "77d73f33-93cb-41db-b6bb-81697569fdb0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"('action',)"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"app_w_interrupt.get_state(thread).next"
]
},
{
@@ -641,7 +700,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 24,
"id": "273d56a8-f40f-4a51-a27f-7c6bb2bda0ba",
"metadata": {},
"outputs": [
@@ -649,8 +708,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/weather-forecast/347629', 'content': 'San Francisco, CA Weather Forecast, with current conditions, wind, air quality, and what to expect for the next 3 days.'}]\" name='tavily_search_results_json' id='8f9238a2-e464-41d7-b3a5-e73ab75156bf'\n",
"content=\"You can check the current weather in San Francisco, CA along with the forecast for the next 3 days on AccuWeather's website. Here is the [link](https://www.accuweather.com/en/us/san-francisco/94103/weather-forecast/347629) to view the information.\" response_metadata={'token_usage': {'completion_tokens': 64, 'prompt_tokens': 377, 'total_tokens': 441}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-18cd2315-f103-46fe-ac9c-f7eea55e210e-0'\n"
"content='[{\\'url\\': \\'https://weather.com/weather/hourbyhour/l/USCA0987:1:US\\', \\'content\\': \"recents\\\\nSpecialty Forecasts\\\\nHourly Weather-San Francisco, CA\\\\nBeach Hazard Statement\\\\nSaturday, November 25\\\\n5 pm\\\\nClear\\\\n6 pm\\\\nClear\\\\n7 pm\\\\nClear\\\\n8 pm\\\\nMostly Clear\\\\n9 pm\\\\nPartly Cloudy\\\\n10 pm\\\\nPartly Cloudy\\\\n11 pm\\\\nPartly Cloudy\\\\nSunday, November 26\\\\n12 am\\\\nPartly Cloudy\\\\n1 am\\\\nMostly Cloudy\\\\n2 am\\\\nMostly Cloudy\\\\n3 am\\\\nMostly Cloudy\\\\n4 am\\\\nCloudy\\\\n5 am\\\\nCloudy\\\\n6 am\\\\nMostly Cloudy\\\\n7 am\\\\nMostly Cloudy\\\\n8 am\\\\nMostly Cloudy\\\\n9 am\\\\nMostly Cloudy\\\\n10 am\\\\nPartly Cloudy\\\\n11 am\\\\nPartly Cloudy\\\\n12 pm\\\\nPartly Cloudy\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nPartly Cloudy\\\\n3 pm\\\\nPartly Cloudy\\\\n4 pm\\\\nPartly Cloudy\\\\n5 pm\\\\nPartly Cloudy\\\\n6 pm\\\\nPartly Cloudy\\\\n7 pm\\\\nPartly Cloudy\\\\n8 pm\\\\nPartly Cloudy\\\\n9 pm\\\\nMostly Clear\\\\n10 pm\\\\nMostly Clear\\\\n11 pm\\\\nMostly Clear\\\\nMonday, November 27\\\\n12 am\\\\nClear\\\\n1 am\\\\nMostly Clear\\\\n2 am\\\\nMostly Clear\\\\n3 am\\\\nPartly Cloudy\\\\n4 am\\\\nMostly Clear\\\\n5 am\\\\nMostly Clear\\\\n6 am\\\\nClear\\\\n7 am\\\\nClear\\\\n8 am\\\\nSunny\\\\n9 am\\\\nSunny\\\\n10 am\\\\nSunny\\\\n11 am\\\\nSunny\\\\n12 pm\\\\nMostly Sunny\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nMostly Sunny\\\\n3 pm\\\\nMostly Sunny\\\\n4 pm\\\\nPartly Cloudy\\\\nRadar\\\\nSafety First!\\\\n Don\\'t Miss\\\\nIrresistible\\\\nWeather Wonders\\\\nOur Amazing World\\\\nCelestial Symphony\\\\nFried Turkey Fail\\\\nLook At That!\\\\n Health & Activities\\\\nSeasonal Allergies and Pollen Count Forecast\\\\nNo pollen detected in your area\\\\nCold & Flu Forecast\\\\nFlu risk is low in your area\\\\nWe recognize our responsibility to use data and technology for good. Changes For Critters\\\\nHurricane Tracker\\\\nStay Safe\\\\nAir Quality Index\\\\nAir quality is considered satisfactory, and air pollution poses little or no risk.\\\\n Take control of your data.\\\\n\"}]' name='tavily_search_results_json' id='97fa7a07-399e-4c5d-8175-624be906c574'\n",
"content='The current weather in San Francisco is partly cloudy. The temperature is expected to remain consistent with partly cloudy conditions throughout the day.' response_metadata={'token_usage': {'completion_tokens': 26, 'prompt_tokens': 661, 'total_tokens': 687}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-b99e4fd0-7688-4db7-a677-bf8ba9b8698e-0'\n"
]
}
],
@@ -660,6 +719,16 @@
" print(v)"
]
},
{
"cell_type": "markdown",
"id": "14d288a5-1027-4a12-898c-1c6bfcc19bb6",
"metadata": {},
"source": [
"See this run in LangSmith here https://smith.langchain.com/public/51c7843b-039a-4efc-bcbd-3f93ad3cbd13/r\n",
"\n",
"This continues where we left off, with \"action\" node, followed by \"agent\" node, which terminates the execution."
]
},
{
"cell_type": "markdown",
"id": "1c38c505-6cee-427f-9dcd-493a2ade7ebb",
@@ -672,7 +741,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 25,
"id": "8578a66d-6489-4e03-8c23-fd0530278455",
"metadata": {},
"outputs": [
@@ -680,17 +749,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0'), FunctionMessage(content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629', 'content': 'Hourly weather forecast in San Francisco, CA. Check current conditions in San Francisco, CA with radar, hourly, and more.'}]\", name='tavily_search_results_json', id='9db65c5e-aaa2-4ee7-b149-0e57d2db5bf6'), AIMessage(content=\"You can check the hourly weather forecast in San Francisco, CA on AccuWeather's website. Here is the [link](https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629) to view the current conditions.\", response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 186, 'total_tokens': 246}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-c09b1f88-5e55-4b65-b82d-054d4fb2522f-0'), HumanMessage(content='what is the weather in sf currently', id='98cec2a0-26f7-4b9f-9491-2a893f58c591'), AIMessage(content='I apologize for the inconvenience. Let me provide you with the current weather in San Francisco.', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 260, 'total_tokens': 301}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-19d40ebd-d551-4e36-8bd4-ed6ae5256954-0'), FunctionMessage(content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/weather-forecast/347629', 'content': 'San Francisco, CA Weather Forecast, with current conditions, wind, air quality, and what to expect for the next 3 days.'}]\", name='tavily_search_results_json', id='8f9238a2-e464-41d7-b3a5-e73ab75156bf'), AIMessage(content=\"You can check the current weather in San Francisco, CA along with the forecast for the next 3 days on AccuWeather's website. Here is the [link](https://www.accuweather.com/en/us/san-francisco/94103/weather-forecast/347629) to view the information.\", response_metadata={'token_usage': {'completion_tokens': 64, 'prompt_tokens': 377, 'total_tokens': 441}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-18cd2315-f103-46fe-ac9c-f7eea55e210e-0')], next=(), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T21:49:56.166057+00:00'}}, parent_config=None)\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='06076c4e-40fe-4f44-978a-612fed60849c'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-966f6180-3c8f-42d5-af89-906650c46ab5-0'), FunctionMessage(content='[{\\'url\\': \\'https://weather.com/weather/hourbyhour/l/USCA0987:1:US\\', \\'content\\': \"recents\\\\nSpecialty Forecasts\\\\nHourly Weather-San Francisco, CA\\\\nBeach Hazard Statement\\\\nSaturday, November 25\\\\n5 pm\\\\nClear\\\\n6 pm\\\\nClear\\\\n7 pm\\\\nClear\\\\n8 pm\\\\nMostly Clear\\\\n9 pm\\\\nPartly Cloudy\\\\n10 pm\\\\nPartly Cloudy\\\\n11 pm\\\\nPartly Cloudy\\\\nSunday, November 26\\\\n12 am\\\\nPartly Cloudy\\\\n1 am\\\\nMostly Cloudy\\\\n2 am\\\\nMostly Cloudy\\\\n3 am\\\\nMostly Cloudy\\\\n4 am\\\\nCloudy\\\\n5 am\\\\nCloudy\\\\n6 am\\\\nMostly Cloudy\\\\n7 am\\\\nMostly Cloudy\\\\n8 am\\\\nMostly Cloudy\\\\n9 am\\\\nMostly Cloudy\\\\n10 am\\\\nPartly Cloudy\\\\n11 am\\\\nPartly Cloudy\\\\n12 pm\\\\nPartly Cloudy\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nPartly Cloudy\\\\n3 pm\\\\nPartly Cloudy\\\\n4 pm\\\\nPartly Cloudy\\\\n5 pm\\\\nPartly Cloudy\\\\n6 pm\\\\nPartly Cloudy\\\\n7 pm\\\\nPartly Cloudy\\\\n8 pm\\\\nPartly Cloudy\\\\n9 pm\\\\nMostly Clear\\\\n10 pm\\\\nMostly Clear\\\\n11 pm\\\\nMostly Clear\\\\nMonday, November 27\\\\n12 am\\\\nClear\\\\n1 am\\\\nMostly Clear\\\\n2 am\\\\nMostly Clear\\\\n3 am\\\\nPartly Cloudy\\\\n4 am\\\\nMostly Clear\\\\n5 am\\\\nMostly Clear\\\\n6 am\\\\nClear\\\\n7 am\\\\nClear\\\\n8 am\\\\nSunny\\\\n9 am\\\\nSunny\\\\n10 am\\\\nSunny\\\\n11 am\\\\nSunny\\\\n12 pm\\\\nMostly Sunny\\\\n1 pm\\\\nPartly Cloudy\\\\n2 pm\\\\nMostly Sunny\\\\n3 pm\\\\nMostly Sunny\\\\n4 pm\\\\nPartly Cloudy\\\\nRadar\\\\nSafety First!\\\\n Don\\'t Miss\\\\nIrresistible\\\\nWeather Wonders\\\\nOur Amazing World\\\\nCelestial Symphony\\\\nFried Turkey Fail\\\\nLook At That!\\\\n Health & Activities\\\\nSeasonal Allergies and Pollen Count Forecast\\\\nNo pollen detected in your area\\\\nCold & Flu Forecast\\\\nFlu risk is low in your area\\\\nWe recognize our responsibility to use data and technology for good. Changes For Critters\\\\nHurricane Tracker\\\\nStay Safe\\\\nAir Quality Index\\\\nAir quality is considered satisfactory, and air pollution poses little or no risk.\\\\n Take control of your data.\\\\n\"}]', name='tavily_search_results_json', id='97fa7a07-399e-4c5d-8175-624be906c574'), AIMessage(content='The current weather in San Francisco is partly cloudy. The temperature is expected to remain consistent with partly cloudy conditions throughout the day.', response_metadata={'token_usage': {'completion_tokens': 26, 'prompt_tokens': 661, 'total_tokens': 687}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-b99e4fd0-7688-4db7-a677-bf8ba9b8698e-0')], next=(), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T23:07:42.012426+00:00'}}, parent_config=None)\n",
"--\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0'), FunctionMessage(content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629', 'content': 'Hourly weather forecast in San Francisco, CA. Check current conditions in San Francisco, CA with radar, hourly, and more.'}]\", name='tavily_search_results_json', id='9db65c5e-aaa2-4ee7-b149-0e57d2db5bf6'), AIMessage(content=\"You can check the hourly weather forecast in San Francisco, CA on AccuWeather's website. Here is the [link](https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629) to view the current conditions.\", response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 186, 'total_tokens': 246}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-c09b1f88-5e55-4b65-b82d-054d4fb2522f-0'), HumanMessage(content='what is the weather in sf currently', id='98cec2a0-26f7-4b9f-9491-2a893f58c591'), AIMessage(content='I apologize for the inconvenience. Let me provide you with the current weather in San Francisco.', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 260, 'total_tokens': 301}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-19d40ebd-d551-4e36-8bd4-ed6ae5256954-0')], next=('action',), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T21:49:50.740187+00:00'}}, parent_config=None)\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='06076c4e-40fe-4f44-978a-612fed60849c'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-966f6180-3c8f-42d5-af89-906650c46ab5-0')], next=('action',), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T23:05:41.595778+00:00'}}, parent_config=None)\n",
"--\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0'), FunctionMessage(content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629', 'content': 'Hourly weather forecast in San Francisco, CA. Check current conditions in San Francisco, CA with radar, hourly, and more.'}]\", name='tavily_search_results_json', id='9db65c5e-aaa2-4ee7-b149-0e57d2db5bf6'), AIMessage(content=\"You can check the hourly weather forecast in San Francisco, CA on AccuWeather's website. Here is the [link](https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629) to view the current conditions.\", response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 186, 'total_tokens': 246}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-c09b1f88-5e55-4b65-b82d-054d4fb2522f-0'), HumanMessage(content='what is the weather in sf currently', id='98cec2a0-26f7-4b9f-9491-2a893f58c591'), AIMessage(content='I apologize for the inconvenience. Let me provide you with the current weather in San Francisco.', additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 41, 'prompt_tokens': 260, 'total_tokens': 301}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-19d40ebd-d551-4e36-8bd4-ed6ae5256954-0')], next=('action',), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T21:49:45.798416+00:00'}}, parent_config=None)\n",
"--\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0'), FunctionMessage(content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629', 'content': 'Hourly weather forecast in San Francisco, CA. Check current conditions in San Francisco, CA with radar, hourly, and more.'}]\", name='tavily_search_results_json', id='9db65c5e-aaa2-4ee7-b149-0e57d2db5bf6'), AIMessage(content=\"You can check the hourly weather forecast in San Francisco, CA on AccuWeather's website. Here is the [link](https://www.accuweather.com/en/us/san-francisco/94103/hourly-weather-forecast/347629) to view the current conditions.\", response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 186, 'total_tokens': 246}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None}, id='run-c09b1f88-5e55-4b65-b82d-054d4fb2522f-0')], next=(), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T21:44:09.910235+00:00'}}, parent_config=None)\n",
"--\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"weather in San Francisco today\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0')], next=('action',), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T21:44:06.248818+00:00'}}, parent_config=None)\n",
"--\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0')], next=('action',), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T21:44:04.515773+00:00'}}, parent_config=None)\n",
"StateSnapshot(values=[HumanMessage(content='what is the weather in sf currently', id='06076c4e-40fe-4f44-978a-612fed60849c'), AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-966f6180-3c8f-42d5-af89-906650c46ab5-0')], next=('action',), config={'configurable': {'thread_id': '4', 'thread_ts': '2024-04-02T23:01:11.296458+00:00'}}, parent_config=None)\n",
"--\n"
]
}
@@ -713,18 +776,18 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 26,
"id": "21e7fc18-6fd9-4e11-a84b-e0325c9640c8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'),\n",
" AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0')]"
"[HumanMessage(content='what is the weather in sf currently', id='06076c4e-40fe-4f44-978a-612fed60849c'),\n",
" AIMessage(content='', additional_kwargs={'function_call': {'arguments': '{\"query\":\"current weather in San Francisco\"}', 'name': 'tavily_search_results_json'}}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 88, 'total_tokens': 110}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'function_call', 'logprobs': None}, id='run-966f6180-3c8f-42d5-af89-906650c46ab5-0')]"
]
},
"execution_count": 28,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
@@ -735,7 +798,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 27,
"id": "d4b01634-0041-4632-8d1f-5464580e54f5",
"metadata": {},
"outputs": [
@@ -745,7 +808,7 @@
"('action',)"
]
},
"execution_count": 29,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
@@ -766,7 +829,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 28,
"id": "e986f94f-706f-4b6f-b3c4-f95483b9e9b8",
"metadata": {},
"outputs": [
@@ -774,8 +837,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"content=\"[{'url': 'https://forecast.weather.gov/zipcity.php?inputstring=San francisco,CA', 'content': 'San Francisco CA 37.77°N 122.41°W (Elev. 131 ft) Last Update: 8:37 am PDT Apr 2, 2024. Forecast Valid: 9am PDT Apr 2, 2024-6pm PDT Apr 8, 2024 . ... Severe Weather ; Current Outlook Maps ; Drought ; Fire Weather ; Fronts/Precipitation Maps ; Current Graphical Forecast Maps ; Rivers ; Marine ; Offshore and High Seas; Hurricanes ;'}]\" name='tavily_search_results_json' id='8c02a3ff-3919-4e55-9c50-396abecbf654'\n",
"content='I found information on the weather in San Francisco. You can check the current weather in San Francisco by visiting this [link](https://forecast.weather.gov/zipcity.php?inputstring=San%20francisco,CA).' response_metadata={'token_usage': {'completion_tokens': 48, 'prompt_tokens': 259, 'total_tokens': 307}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-c7eed90e-582b-4e3c-a23b-3b09e5bc7581-0'\n"
"content=\"[{'url': 'https://www.accuweather.com/en/us/san-francisco/94103/current-weather/347629', 'content': 'Get the latest weather conditions and forecast for San Francisco, CA. See the temperature, humidity, wind, pressure, cloud cover, and alerts for the current hour and the next few days.'}]\" name='tavily_search_results_json' id='82d6c2ac-260c-4d5d-9541-21ac4fab8916'\n",
"content='You can check the current weather conditions and forecast for San Francisco, CA on [AccuWeather](https://www.accuweather.com/en/us/san-francisco/94103/current-weather/347629). It will provide you with information on temperature, humidity, wind, pressure, cloud cover, and alerts for the current hour and the next few days.' response_metadata={'token_usage': {'completion_tokens': 75, 'prompt_tokens': 194, 'total_tokens': 269}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': 'fp_b28b39ffa8', 'finish_reason': 'stop', 'logprobs': None} id='run-b4ab153a-266f-44c2-ad37-5fd2a869003a-0'\n"
]
}
],
@@ -785,6 +848,16 @@
" print(v)"
]
},
{
"cell_type": "markdown",
"id": "8b4b81dd-1108-4ab7-b680-3f641b3efa70",
"metadata": {},
"source": [
"See this run in LangSmith here https://smith.langchain.com/public/f26e9e1d-16df-48ae-98f7-c823d6942bf7/r\n",
"\n",
"This is similar to the previous run, this time with the original search query, instead of our modified one. "
]
},
{
"cell_type": "markdown",
"id": "59910951-fae1-4475-8511-f622439b590d",
@@ -795,7 +868,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 29,
"id": "b084f141-5800-487b-b115-d2e58421b963",
"metadata": {},
"outputs": [],
@@ -805,7 +878,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 30,
"id": "1a7cfcd4-289e-419e-8b49-dfaef4f88641",
"metadata": {},
"outputs": [],
@@ -815,18 +888,18 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 31,
"id": "5198f9c1-d2d4-458a-993d-3caa55810b1e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[HumanMessage(content='what is the weather in sf currently', id='c4e2e843-0f21-4a54-9f18-68ba5ee02f4a'),\n",
" AIMessage(content='All done here!', id='run-a324e2bc-2f34-433d-912b-473ef0e15b40-0')]"
"[HumanMessage(content='what is the weather in sf currently', id='06076c4e-40fe-4f44-978a-612fed60849c'),\n",
" AIMessage(content='All done here!', id='run-966f6180-3c8f-42d5-af89-906650c46ab5-0')]"
]
},
"execution_count": 33,
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
@@ -837,7 +910,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 32,
"id": "5d89d55d-db84-4c2d-828b-64a29a69947b",
"metadata": {},
"outputs": [
@@ -847,7 +920,7 @@
"()"
]
},
"execution_count": 34,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
@@ -861,7 +934,11 @@
"id": "cc168c90-a374-4280-a9a6-8bc232dbb006",
"metadata": {},
"source": [
"You can see the snapshot was updated and now correctly reflects that there is no next step."
"You can see the snapshot was updated and now correctly reflects that there is no next step.\n",
"\n",
"You can see this in LangSmith update run here https://smith.langchain.com/public/65104717-6eda-4a0f-93c1-4755c6f929ed/r\n",
"\n",
"This shows the \"should_continue\" edge now reacting to this replaced message, and now changing the outcome to \"end\" which finishes the computation."
]
},
{