{ "cells": [ { "cell_type": "markdown", "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ "# How to stream messages from your graph\n", "\n", "There are multiple different streaming modes.\n", "\n", "- `values`: This streaming mode streams back values of the graph. This is the **full state of the graph** after each node is called.\n", "- `updates`: This streaming mode streams back updates to the graph. This is the **update to the state of the graph** after each node is called.\n", "- `messages`: This streaming mode streams back messages - both complete messages (at the end of a node) as well as **tokens** for any messages generated inside a node. This mode is primarily meant for powering chat applications.\n", "\n", "\n", "This notebook covers `streaming_mode=\"messages\"`.\n", "\n", "In order to use this mode, the state of the graph you are interacting with MUST have a messages key that is a list of messages.\n", "Eg, the state should look something like:\n", "\n", "```python\n", "from typing import TypedDict, Annotated\n", "from langgraph.graph import add_messages\n", "from langchain_core.messages import AnyMessage\n", "\n", "class State(TypedDict):\n", " messages: Annotated[list[AnyMessage], add_messages]\n", "```\n", "\n", "OR it should be an instance or subclass of `from langgraph.graph import MessageState` (`MessageState` is just a helper type hint equivalent to the above).\n", "\n", "With `stream_mode=\"messages\"` two things will be streamed back:\n", "\n", "- It outputs messages produced by any chat model called inside (unless tagged in a special way)\n", "- It outputs messages returned from nodes (to allow for nodes to return `ToolMessages` and the like" ] }, { "cell_type": "code", "execution_count": 1, "id": "521d975b-e94b-4c37-bfa1-82d969e2a4dc", "metadata": {}, "outputs": [], "source": [ "from langgraph_sdk import get_client" ] }, { "cell_type": "code", "execution_count": 2, "id": "27a1392b-86c3-464e-99a8-90ffc965f3ec", "metadata": {}, "outputs": [], "source": [ "client = get_client()" ] }, { "cell_type": "code", "execution_count": 3, "id": "714e9f92-86b4-4cd8-9d68-cfc45d56ed2c", "metadata": {}, "outputs": [], "source": [ "assistant = await client.assistants.create(graph_id=\"agent\", config={\"configurable\": {\"model_name\": \"openai\"}})" ] }, { "cell_type": "code", "execution_count": 4, "id": "4947e9bc-111f-4991-8c41-1041da9bf0ba", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'assistant_id': 'e6de0bea-86b1-4902-a20b-1f60caf24ef9',\n", " 'graph_id': 'agent',\n", " 'config': {'configurable': {'model_name': 'openai'}},\n", " 'created_at': '2024-05-18T19:58:45.145734+00:00',\n", " 'updated_at': '2024-05-18T19:58:45.145734+00:00',\n", " 'metadata': {}}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "assistant" ] }, { "cell_type": "code", "execution_count": 43, "id": "56aa5159-5583-4134-9210-709b969bda6f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'thread_id': 'd7d3507f-8242-4705-ae6a-2bf45aefe38c',\n", " 'created_at': '2024-05-18T20:14:05.504749+00:00',\n", " 'updated_at': '2024-05-18T20:14:05.504749+00:00',\n", " 'metadata': {}}" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "thread = await client.threads.create()\n", "thread" ] }, { "cell_type": "code", "execution_count": 44, "id": "147c3f98-f889-4f05-a090-6b31f2a0b291", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "runs = await client.runs.list(thread['thread_id'])\n", "runs" ] }, { "cell_type": "code", "execution_count": 46, "id": "040795c6-5d9f-4729-9132-f3b0f94d9e94", "metadata": {}, "outputs": [], "source": [ "# Helper function for formatting messages\n", "\n", "def format_tool_calls(tool_calls):\n", " if tool_calls:\n", " formatted_calls = []\n", " for call in tool_calls:\n", " formatted_calls.append(f\"Tool Call ID: {call['id']}, Function: {call['name']}, Arguments: {call['args']}\")\n", " return \"\\n\".join(formatted_calls)\n", " return \"No tool calls\"" ] }, { "cell_type": "code", "execution_count": 45, "id": "7da70e20-1a4e-4df2-b996-1927f474c835", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Metadata: Run ID - c64b3e27-c7a4-4851-9618-07641fa24296\n", "--------------------------------------------------\n", "Human: what's the weather in sf\n", "--------------------------------------------------\n", "Invalid Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: \n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': ''}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current'}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current weather'}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current weather in'}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current weather in San'}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current weather in San Francisco'}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current weather in San Francisco'}\n", "--------------------------------------------------\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current weather in San Francisco'}\n", "Response Metadata: Finish Reason - tool_calls\n", "--------------------------------------------------\n", "AI: what's the weather in sf\n", "Tool Calls:\n", "Tool Call ID: call_8XskpDf4mjpQOuIL8F9IzQR8, Function: tavily_search_results_json, Arguments: {'query': 'current weather in San Francisco'}\n", "Response Metadata: Finish Reason - tool_calls\n", "--------------------------------------------------\n", "AI: [{\"url\": \"https://www.weatherapi.com/\", \"content\": \"{'location': {'name': 'San Francisco', 'region': 'California', 'country': 'United States of America', 'lat': 37.78, 'lon': -122.42, 'tz_id': 'America/Los_Angeles', 'localtime_epoch': 1716063227, 'localtime': '2024-05-18 13:13'}, 'current': {'last_updated_epoch': 1716062400, 'last_updated': '2024-05-18 13:00', 'temp_c': 17.2, 'temp_f': 63.0, 'is_day': 1, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/day/116.png', 'code': 1003}, 'wind_mph': 2.2, 'wind_kph': 3.6, 'wind_degree': 237, 'wind_dir': 'WSW', 'pressure_mb': 1015.0, 'pressure_in': 29.98, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 65, 'cloud': 50, 'feelslike_c': 17.2, 'feelslike_f': 63.0, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 5.0, 'gust_mph': 13.8, 'gust_kph': 22.3}}\"}]\n", "--------------------------------------------------\n", "--------------------------------------------------\n", "AI: The\n", "--------------------------------------------------\n", "AI: The current\n", "--------------------------------------------------\n", "AI: The current weather\n", "--------------------------------------------------\n", "AI: The current weather in\n", "--------------------------------------------------\n", "AI: The current weather in San\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** \n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Part\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** \n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 k\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph)\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the W\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** \n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** \n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** \n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 101\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** \n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "-\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **G\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gust\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:**\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to \n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 k\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Part\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weather\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64/day\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64/day/\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64/day/116\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64/day/116.png\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64/day/116.png)\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64/day/116.png)\n", "Response Metadata: Finish Reason - stop\n", "--------------------------------------------------\n", "AI: The current weather in San Francisco is as follows:\n", "\n", "- **Temperature:** 17.2°C (63.0°F)\n", "- **Condition:** Partly cloudy\n", "- **Wind:** 2.2 mph (3.6 kph) from the WSW\n", "- **Humidity:** 65%\n", "- **Visibility:** 16 km (9 miles)\n", "- **Pressure:** 1015.0 mb (29.98 in)\n", "- **UV Index:** 5\n", "- **Gusts:** Up to 13.8 mph (22.3 kph)\n", "\n", "![Partly cloudy](//cdn.weatherapi.com/weather/64x64/day/116.png)\n", "Response Metadata: Finish Reason - stop\n", "--------------------------------------------------\n", "--------------------------------------------------\n" ] } ], "source": [ "input = {\"messages\": [{\"role\": \"user\", \"content\": \"what's the weather in sf\"}]}\n", "\n", "async for event in client.runs.stream(thread['thread_id'], assistant['assistant_id'], input=input, stream_mode='messages'):\n", " if event.event == 'metadata':\n", " print(f\"Metadata: Run ID - {event.data['run_id']}\")\n", " elif event.event == 'data':\n", " for data_item in event.data:\n", " if 'role' in data_item and data_item['role'] == 'user':\n", " print(f\"Human: {data_item['content']}\")\n", " else:\n", " tool_calls = data_item.get('tool_calls', [])\n", " invalid_tool_calls = data_item.get('invalid_tool_calls', [])\n", " content = data_item.get('content', \"\")\n", " response_metadata = data_item.get('response_metadata', {})\n", "\n", " if content:\n", " print(f\"AI: {content}\")\n", " \n", " if tool_calls:\n", " print(\"Tool Calls:\")\n", " print(format_tool_calls(tool_calls))\n", " \n", " if invalid_tool_calls:\n", " print(\"Invalid Tool Calls:\")\n", " print(format_tool_calls(invalid_tool_calls))\n", "\n", " if response_metadata:\n", " finish_reason = response_metadata.get('finish_reason', 'N/A')\n", " print(f\"Response Metadata: Finish Reason - {finish_reason}\")\n", " print(\"-\" * 50)\n", " " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.1" } }, "nbformat": 4, "nbformat_minor": 5 }