当前位置: 首页 > news >正文

L2 LangGraph_Components

参考自https://www.deeplearning.ai/short-courses/ai-agents-in-langgraph,以下为代码的实现。

  • 这里用LangGraph把L1的ReAct_Agent实现,可以看出用LangGraph流程化了很多。

LangGraph Components

import os
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())
# print(os.environ.get('OPENAI_API_KEY'))
# print(os.environ.get('TAVILY_API_KEY'))
# print(os.environ.get('OPENAI_BASE_URL'))
from langgraph.graph import StateGraph, END
from typing import TypedDict, Annotated
import operator
from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage, ToolMessage
from langchain_openai import ChatOpenAI
from langchain_community.tools.tavily_search import TavilySearchResults
tool = TavilySearchResults(max_results=2) #increased number of results
print(type(tool))
print(tool.name)
<class 'langchain_community.tools.tavily_search.tool.TavilySearchResults'>
tavily_search_results_json
class AgentState(TypedDict):messages: Annotated[list[AnyMessage], operator.add]
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class Agent:def __init__(self, model, tools, system=""):self.system = systemgraph = StateGraph(AgentState)graph.add_node("llm", self.call_openai)graph.add_node("action", self.take_action)graph.add_conditional_edges("llm",self.exists_action,{True: "action", False: END})graph.add_edge("action", "llm")graph.set_entry_point("llm")self.graph = graph.compile()self.tools = {t.name: t for t in tools}self.model = model.bind_tools(tools)logger.info(f"model: {self.model}")def exists_action(self, state: AgentState):result = state['messages'][-1]logger.info(f"exists_action result: {result}")return len(result.tool_calls) > 0def call_openai(self, state: AgentState):logger.info(f"state: {state}")messages = state['messages']if self.system:messages = [SystemMessage(content=self.system)] + messagesmessage = self.model.invoke(messages)logger.info(f"LLM message: {message}")return {'messages': [message]}def take_action(self, state: AgentState):import threadingprint(f"take_action called in thread: {threading.current_thread().name}")tool_calls = state['messages'][-1].tool_callsresults = []print(f"take_action called with tool_calls: {tool_calls}")for t in tool_calls:logger.info(f"Calling: {t}")print(f"Calling: {t}") if not t['name'] in self.tools:      # check for bad tool name from LLMprint("\n ....bad tool name....")result = "bad tool name, retry"  # instruct LLM to retry if badelse:result = self.tools[t['name']].invoke(t['args'])logger.info(f"action {t['name']}, result: {result}")print(f"action {t['name']}, result: {result}")results.append(ToolMessage(tool_call_id=t['id'], name=t['name'], content=str(result)))print("Back to the model!")return {'messages': results}
prompt = """You are a smart research assistant. Use the search engine to look up information.  \
You are allowed to make multiple calls (either together or in sequence). \
Only look up information when you are sure of what you want. \
If you need to look up some information before asking a follow up question, you are allowed to do that!
"""
model = ChatOpenAI(model="gpt-4o")  #reduce inference cost
# model = ChatOpenAI(model="yi-large")
abot = Agent(model, [tool], system=prompt)
INFO:__main__:model: bound=ChatOpenAI(client=<openai.resources.chat.completions.Completions object at 0x0000029BECD41520>, async_client=<openai.resources.chat.completions.AsyncCompletions object at 0x0000029BECD43200>, model_name='gpt-4o', openai_api_key=SecretStr('**********'), openai_proxy='') kwargs={'tools': [{'type': 'function', 'function': {'name': 'tavily_search_results_json', 'description': 'A search engine optimized for comprehensive, accurate, and trusted results. Useful for when you need to answer questions about current events. Input should be a search query.', 'parameters': {'type': 'object', 'properties': {'query': {'description': 'search query to look up', 'type': 'string'}}, 'required': ['query']}}}]}
from IPython.display import ImageImage(abot.graph.get_graph().draw_png())

在这里插入图片描述

messages = [HumanMessage(content="What is the weather in sf?")]
result = abot.graph.invoke({"messages": messages})
INFO:__main__:state: {'messages': [HumanMessage(content='What is the weather in sf?')]}
INFO:httpx:HTTP Request: POST https://api.chatanywhere.tech/v1/chat/completions "HTTP/1.1 200 OK"
INFO:__main__:LLM message: content='' additional_kwargs={'tool_calls': [{'id': 'call_G1NzidVGnce0IG6VGUPp9xNk', 'function': {'arguments': '{"query":"current weather in San Francisco"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 152, 'total_tokens': 174}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-a06698d1-8bf1-4687-b27d-9dc66850dc7b-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_G1NzidVGnce0IG6VGUPp9xNk'}] usage_metadata={'input_tokens': 152, 'output_tokens': 22, 'total_tokens': 174}
INFO:__main__:exists_action result: content='' additional_kwargs={'tool_calls': [{'id': 'call_G1NzidVGnce0IG6VGUPp9xNk', 'function': {'arguments': '{"query":"current weather in San Francisco"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 152, 'total_tokens': 174}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-a06698d1-8bf1-4687-b27d-9dc66850dc7b-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_G1NzidVGnce0IG6VGUPp9xNk'}] usage_metadata={'input_tokens': 152, 'output_tokens': 22, 'total_tokens': 174}
INFO:__main__:Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_G1NzidVGnce0IG6VGUPp9xNk'}take_action called in thread: ThreadPoolExecutor-0_0
take_action called with tool_calls: [{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_G1NzidVGnce0IG6VGUPp9xNk'}]
Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_G1NzidVGnce0IG6VGUPp9xNk'}INFO:__main__:action tavily_search_results_json, result: [{'url': 'https://www.timeanddate.com/weather/usa/san-francisco/hourly', 'content': 'Hour-by-Hour Forecast for San Francisco, California, USA. Currently: 54 °F. Passing clouds. (Weather station: San Francisco International Airport, USA). See more current weather.'}, {'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': 1720592691, 'localtime': '2024-07-09 23:24'}, 'current': {'last_updated_epoch': 1720592100, 'last_updated': '2024-07-09 23:15', 'temp_c': 16.1, 'temp_f': 61.0, 'is_day': 0, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/night/116.png', 'code': 1003}, 'wind_mph': 9.4, 'wind_kph': 15.1, 'wind_degree': 290, 'wind_dir': 'WNW', 'pressure_mb': 1013.0, 'pressure_in': 29.9, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 90, 'cloud': 75, 'feelslike_c': 16.1, 'feelslike_f': 61.0, 'windchill_c': 13.5, 'windchill_f': 56.4, 'heatindex_c': 14.3, 'heatindex_f': 57.7, 'dewpoint_c': 12.7, 'dewpoint_f': 54.9, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 1.0, 'gust_mph': 11.8, 'gust_kph': 19.0}}"}]
INFO:__main__:state: {'messages': [HumanMessage(content='What is the weather in sf?'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_G1NzidVGnce0IG6VGUPp9xNk', 'function': {'arguments': '{"query":"current weather in San Francisco"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 152, 'total_tokens': 174}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-a06698d1-8bf1-4687-b27d-9dc66850dc7b-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_G1NzidVGnce0IG6VGUPp9xNk'}], usage_metadata={'input_tokens': 152, 'output_tokens': 22, 'total_tokens': 174}), ToolMessage(content='[{\'url\': \'https://www.timeanddate.com/weather/usa/san-francisco/hourly\', \'content\': \'Hour-by-Hour Forecast for San Francisco, California, USA. Currently: 54 °F. Passing clouds. (Weather station: San Francisco International Airport, USA). See more current weather.\'}, {\'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\': 1720592691, \'localtime\': \'2024-07-09 23:24\'}, \'current\': {\'last_updated_epoch\': 1720592100, \'last_updated\': \'2024-07-09 23:15\', \'temp_c\': 16.1, \'temp_f\': 61.0, \'is_day\': 0, \'condition\': {\'text\': \'Partly cloudy\', \'icon\': \'//cdn.weatherapi.com/weather/64x64/night/116.png\', \'code\': 1003}, \'wind_mph\': 9.4, \'wind_kph\': 15.1, \'wind_degree\': 290, \'wind_dir\': \'WNW\', \'pressure_mb\': 1013.0, \'pressure_in\': 29.9, \'precip_mm\': 0.0, \'precip_in\': 0.0, \'humidity\': 90, \'cloud\': 75, \'feelslike_c\': 16.1, \'feelslike_f\': 61.0, \'windchill_c\': 13.5, \'windchill_f\': 56.4, \'heatindex_c\': 14.3, \'heatindex_f\': 57.7, \'dewpoint_c\': 12.7, \'dewpoint_f\': 54.9, \'vis_km\': 16.0, \'vis_miles\': 9.0, \'uv\': 1.0, \'gust_mph\': 11.8, \'gust_kph\': 19.0}}"}]', name='tavily_search_results_json', tool_call_id='call_G1NzidVGnce0IG6VGUPp9xNk')]}action tavily_search_results_json, result: [{'url': 'https://www.timeanddate.com/weather/usa/san-francisco/hourly', 'content': 'Hour-by-Hour Forecast for San Francisco, California, USA. Currently: 54 °F. Passing clouds. (Weather station: San Francisco International Airport, USA). See more current weather.'}, {'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': 1720592691, 'localtime': '2024-07-09 23:24'}, 'current': {'last_updated_epoch': 1720592100, 'last_updated': '2024-07-09 23:15', 'temp_c': 16.1, 'temp_f': 61.0, 'is_day': 0, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/night/116.png', 'code': 1003}, 'wind_mph': 9.4, 'wind_kph': 15.1, 'wind_degree': 290, 'wind_dir': 'WNW', 'pressure_mb': 1013.0, 'pressure_in': 29.9, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 90, 'cloud': 75, 'feelslike_c': 16.1, 'feelslike_f': 61.0, 'windchill_c': 13.5, 'windchill_f': 56.4, 'heatindex_c': 14.3, 'heatindex_f': 57.7, 'dewpoint_c': 12.7, 'dewpoint_f': 54.9, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 1.0, 'gust_mph': 11.8, 'gust_kph': 19.0}}"}]
Back to the model!INFO:httpx:HTTP Request: POST https://api.chatanywhere.tech/v1/chat/completions "HTTP/1.1 200 OK"
INFO:__main__:LLM message: content='The current weather in San Francisco is partly cloudy with a temperature of 61°F (16.1°C). The wind is blowing from the west-northwest at 9.4 mph (15.1 kph), and the humidity is at 90%.' response_metadata={'token_usage': {'completion_tokens': 54, 'prompt_tokens': 658, 'total_tokens': 712}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'stop', 'logprobs': None} id='run-7543ad68-73c8-454e-b4de-14e16d7ad8c8-0' usage_metadata={'input_tokens': 658, 'output_tokens': 54, 'total_tokens': 712}
INFO:__main__:exists_action result: content='The current weather in San Francisco is partly cloudy with a temperature of 61°F (16.1°C). The wind is blowing from the west-northwest at 9.4 mph (15.1 kph), and the humidity is at 90%.' response_metadata={'token_usage': {'completion_tokens': 54, 'prompt_tokens': 658, 'total_tokens': 712}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'stop', 'logprobs': None} id='run-7543ad68-73c8-454e-b4de-14e16d7ad8c8-0' usage_metadata={'input_tokens': 658, 'output_tokens': 54, 'total_tokens': 712}
result
{'messages': [HumanMessage(content='What is the weather in sf?'),AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_G1NzidVGnce0IG6VGUPp9xNk', 'function': {'arguments': '{"query":"current weather in San Francisco"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 152, 'total_tokens': 174}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-a06698d1-8bf1-4687-b27d-9dc66850dc7b-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_G1NzidVGnce0IG6VGUPp9xNk'}], usage_metadata={'input_tokens': 152, 'output_tokens': 22, 'total_tokens': 174}),ToolMessage(content='[{\'url\': \'https://www.timeanddate.com/weather/usa/san-francisco/hourly\', \'content\': \'Hour-by-Hour Forecast for San Francisco, California, USA. Currently: 54 °F. Passing clouds. (Weather station: San Francisco International Airport, USA). See more current weather.\'}, {\'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\': 1720592691, \'localtime\': \'2024-07-09 23:24\'}, \'current\': {\'last_updated_epoch\': 1720592100, \'last_updated\': \'2024-07-09 23:15\', \'temp_c\': 16.1, \'temp_f\': 61.0, \'is_day\': 0, \'condition\': {\'text\': \'Partly cloudy\', \'icon\': \'//cdn.weatherapi.com/weather/64x64/night/116.png\', \'code\': 1003}, \'wind_mph\': 9.4, \'wind_kph\': 15.1, \'wind_degree\': 290, \'wind_dir\': \'WNW\', \'pressure_mb\': 1013.0, \'pressure_in\': 29.9, \'precip_mm\': 0.0, \'precip_in\': 0.0, \'humidity\': 90, \'cloud\': 75, \'feelslike_c\': 16.1, \'feelslike_f\': 61.0, \'windchill_c\': 13.5, \'windchill_f\': 56.4, \'heatindex_c\': 14.3, \'heatindex_f\': 57.7, \'dewpoint_c\': 12.7, \'dewpoint_f\': 54.9, \'vis_km\': 16.0, \'vis_miles\': 9.0, \'uv\': 1.0, \'gust_mph\': 11.8, \'gust_kph\': 19.0}}"}]', name='tavily_search_results_json', tool_call_id='call_G1NzidVGnce0IG6VGUPp9xNk'),AIMessage(content='The current weather in San Francisco is partly cloudy with a temperature of 61°F (16.1°C). The wind is blowing from the west-northwest at 9.4 mph (15.1 kph), and the humidity is at 90%.', response_metadata={'token_usage': {'completion_tokens': 54, 'prompt_tokens': 658, 'total_tokens': 712}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'stop', 'logprobs': None}, id='run-7543ad68-73c8-454e-b4de-14e16d7ad8c8-0', usage_metadata={'input_tokens': 658, 'output_tokens': 54, 'total_tokens': 712})]}
result['messages'][-1].content
'The current weather in San Francisco is partly cloudy with a temperature of 61°F (16.1°C). The wind is blowing from the west-northwest at 9.4 mph (15.1 kph), and the humidity is at 90%.'
messages = [HumanMessage(content="What is the weather in SF and LA?")]
result = abot.graph.invoke({"messages": messages})
INFO:__main__:state: {'messages': [HumanMessage(content='What is the weather in SF and LA?')]}
INFO:httpx:HTTP Request: POST https://api.chatanywhere.tech/v1/chat/completions "HTTP/1.1 200 OK"
INFO:__main__:LLM message: content='' additional_kwargs={'tool_calls': [{'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg', 'function': {'arguments': '{"query": "current weather in San Francisco"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}, {'id': 'call_LFYn4VtDMAhv014a7EfZoKS4', 'function': {'arguments': '{"query": "current weather in Los Angeles"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 154, 'total_tokens': 214}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d576307f90', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-4f5b63b9-857e-4a59-ae40-b9804bb1f5be-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg'}, {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in Los Angeles'}, 'id': 'call_LFYn4VtDMAhv014a7EfZoKS4'}] usage_metadata={'input_tokens': 154, 'output_tokens': 60, 'total_tokens': 214}
INFO:__main__:exists_action result: content='' additional_kwargs={'tool_calls': [{'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg', 'function': {'arguments': '{"query": "current weather in San Francisco"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}, {'id': 'call_LFYn4VtDMAhv014a7EfZoKS4', 'function': {'arguments': '{"query": "current weather in Los Angeles"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 154, 'total_tokens': 214}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d576307f90', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-4f5b63b9-857e-4a59-ae40-b9804bb1f5be-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg'}, {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in Los Angeles'}, 'id': 'call_LFYn4VtDMAhv014a7EfZoKS4'}] usage_metadata={'input_tokens': 154, 'output_tokens': 60, 'total_tokens': 214}
INFO:__main__:Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg'}take_action called in thread: ThreadPoolExecutor-1_0
take_action called with tool_calls: [{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg'}, {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in Los Angeles'}, 'id': 'call_LFYn4VtDMAhv014a7EfZoKS4'}]
Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg'}INFO:__main__:action tavily_search_results_json, result: [{'url': 'https://www.wunderground.com/hourly/us/ca/san-francisco/94188/date/2024-7-10', 'content': 'San Francisco Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for the San Francisco area. ... Wednesday 07/ ...'}, {'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': 1720592691, 'localtime': '2024-07-09 23:24'}, 'current': {'last_updated_epoch': 1720592100, 'last_updated': '2024-07-09 23:15', 'temp_c': 16.1, 'temp_f': 61.0, 'is_day': 0, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/night/116.png', 'code': 1003}, 'wind_mph': 9.4, 'wind_kph': 15.1, 'wind_degree': 290, 'wind_dir': 'WNW', 'pressure_mb': 1013.0, 'pressure_in': 29.9, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 90, 'cloud': 75, 'feelslike_c': 16.1, 'feelslike_f': 61.0, 'windchill_c': 13.5, 'windchill_f': 56.4, 'heatindex_c': 14.3, 'heatindex_f': 57.7, 'dewpoint_c': 12.7, 'dewpoint_f': 54.9, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 1.0, 'gust_mph': 11.8, 'gust_kph': 19.0}}"}]
INFO:__main__:Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in Los Angeles'}, 'id': 'call_LFYn4VtDMAhv014a7EfZoKS4'}action tavily_search_results_json, result: [{'url': 'https://www.wunderground.com/hourly/us/ca/san-francisco/94188/date/2024-7-10', 'content': 'San Francisco Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for the San Francisco area. ... Wednesday 07/ ...'}, {'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': 1720592691, 'localtime': '2024-07-09 23:24'}, 'current': {'last_updated_epoch': 1720592100, 'last_updated': '2024-07-09 23:15', 'temp_c': 16.1, 'temp_f': 61.0, 'is_day': 0, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/night/116.png', 'code': 1003}, 'wind_mph': 9.4, 'wind_kph': 15.1, 'wind_degree': 290, 'wind_dir': 'WNW', 'pressure_mb': 1013.0, 'pressure_in': 29.9, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 90, 'cloud': 75, 'feelslike_c': 16.1, 'feelslike_f': 61.0, 'windchill_c': 13.5, 'windchill_f': 56.4, 'heatindex_c': 14.3, 'heatindex_f': 57.7, 'dewpoint_c': 12.7, 'dewpoint_f': 54.9, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 1.0, 'gust_mph': 11.8, 'gust_kph': 19.0}}"}]
Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in Los Angeles'}, 'id': 'call_LFYn4VtDMAhv014a7EfZoKS4'}INFO:__main__:action tavily_search_results_json, result: [{'url': 'https://www.wunderground.com/hourly/us/ca/los-angeles/90026/date/2024-07-10', 'content': 'Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for the Los Angeles area. ... Wednesday 07/10 Hourly for Tomorrow, Wed 07/10'}, {'url': 'https://www.weatherapi.com/', 'content': "{'location': {'name': 'Los Angeles', 'region': 'California', 'country': 'United States of America', 'lat': 34.05, 'lon': -118.24, 'tz_id': 'America/Los_Angeles', 'localtime_epoch': 1720592759, 'localtime': '2024-07-09 23:25'}, 'current': {'last_updated_epoch': 1720592100, 'last_updated': '2024-07-09 23:15', 'temp_c': 18.3, 'temp_f': 64.9, 'is_day': 0, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/night/116.png', 'code': 1003}, 'wind_mph': 3.8, 'wind_kph': 6.1, 'wind_degree': 290, 'wind_dir': 'WNW', 'pressure_mb': 1010.0, 'pressure_in': 29.83, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 84, 'cloud': 50, 'feelslike_c': 18.3, 'feelslike_f': 64.9, 'windchill_c': 24.8, 'windchill_f': 76.6, 'heatindex_c': 25.7, 'heatindex_f': 78.3, 'dewpoint_c': 13.9, 'dewpoint_f': 57.0, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 1.0, 'gust_mph': 3.9, 'gust_kph': 6.2}}"}]
INFO:__main__:state: {'messages': [HumanMessage(content='What is the weather in SF and LA?'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg', 'function': {'arguments': '{"query": "current weather in San Francisco"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}, {'id': 'call_LFYn4VtDMAhv014a7EfZoKS4', 'function': {'arguments': '{"query": "current weather in Los Angeles"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 60, 'prompt_tokens': 154, 'total_tokens': 214}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d576307f90', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-4f5b63b9-857e-4a59-ae40-b9804bb1f5be-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'current weather in San Francisco'}, 'id': 'call_kdq99sJ89Icj8XO3JiDBqgzg'}, {'name': 'tavily_search_results_json', 'args': {'query': 'current weather in Los Angeles'}, 'id': 'call_LFYn4VtDMAhv014a7EfZoKS4'}], usage_metadata={'input_tokens': 154, 'output_tokens': 60, 'total_tokens': 214}), ToolMessage(content='[{\'url\': \'https://www.wunderground.com/hourly/us/ca/san-francisco/94188/date/2024-7-10\', \'content\': \'San Francisco Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for the San Francisco area. ... Wednesday 07/ ...\'}, {\'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\': 1720592691, \'localtime\': \'2024-07-09 23:24\'}, \'current\': {\'last_updated_epoch\': 1720592100, \'last_updated\': \'2024-07-09 23:15\', \'temp_c\': 16.1, \'temp_f\': 61.0, \'is_day\': 0, \'condition\': {\'text\': \'Partly cloudy\', \'icon\': \'//cdn.weatherapi.com/weather/64x64/night/116.png\', \'code\': 1003}, \'wind_mph\': 9.4, \'wind_kph\': 15.1, \'wind_degree\': 290, \'wind_dir\': \'WNW\', \'pressure_mb\': 1013.0, \'pressure_in\': 29.9, \'precip_mm\': 0.0, \'precip_in\': 0.0, \'humidity\': 90, \'cloud\': 75, \'feelslike_c\': 16.1, \'feelslike_f\': 61.0, \'windchill_c\': 13.5, \'windchill_f\': 56.4, \'heatindex_c\': 14.3, \'heatindex_f\': 57.7, \'dewpoint_c\': 12.7, \'dewpoint_f\': 54.9, \'vis_km\': 16.0, \'vis_miles\': 9.0, \'uv\': 1.0, \'gust_mph\': 11.8, \'gust_kph\': 19.0}}"}]', name='tavily_search_results_json', tool_call_id='call_kdq99sJ89Icj8XO3JiDBqgzg'), ToolMessage(content='[{\'url\': \'https://www.wunderground.com/hourly/us/ca/los-angeles/90026/date/2024-07-10\', \'content\': \'Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for the Los Angeles area. ... Wednesday 07/10 Hourly for Tomorrow, Wed 07/10\'}, {\'url\': \'https://www.weatherapi.com/\', \'content\': "{\'location\': {\'name\': \'Los Angeles\', \'region\': \'California\', \'country\': \'United States of America\', \'lat\': 34.05, \'lon\': -118.24, \'tz_id\': \'America/Los_Angeles\', \'localtime_epoch\': 1720592759, \'localtime\': \'2024-07-09 23:25\'}, \'current\': {\'last_updated_epoch\': 1720592100, \'last_updated\': \'2024-07-09 23:15\', \'temp_c\': 18.3, \'temp_f\': 64.9, \'is_day\': 0, \'condition\': {\'text\': \'Partly cloudy\', \'icon\': \'//cdn.weatherapi.com/weather/64x64/night/116.png\', \'code\': 1003}, \'wind_mph\': 3.8, \'wind_kph\': 6.1, \'wind_degree\': 290, \'wind_dir\': \'WNW\', \'pressure_mb\': 1010.0, \'pressure_in\': 29.83, \'precip_mm\': 0.0, \'precip_in\': 0.0, \'humidity\': 84, \'cloud\': 50, \'feelslike_c\': 18.3, \'feelslike_f\': 64.9, \'windchill_c\': 24.8, \'windchill_f\': 76.6, \'heatindex_c\': 25.7, \'heatindex_f\': 78.3, \'dewpoint_c\': 13.9, \'dewpoint_f\': 57.0, \'vis_km\': 16.0, \'vis_miles\': 9.0, \'uv\': 1.0, \'gust_mph\': 3.9, \'gust_kph\': 6.2}}"}]', name='tavily_search_results_json', tool_call_id='call_LFYn4VtDMAhv014a7EfZoKS4')]}action tavily_search_results_json, result: [{'url': 'https://www.wunderground.com/hourly/us/ca/los-angeles/90026/date/2024-07-10', 'content': 'Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for the Los Angeles area. ... Wednesday 07/10 Hourly for Tomorrow, Wed 07/10'}, {'url': 'https://www.weatherapi.com/', 'content': "{'location': {'name': 'Los Angeles', 'region': 'California', 'country': 'United States of America', 'lat': 34.05, 'lon': -118.24, 'tz_id': 'America/Los_Angeles', 'localtime_epoch': 1720592759, 'localtime': '2024-07-09 23:25'}, 'current': {'last_updated_epoch': 1720592100, 'last_updated': '2024-07-09 23:15', 'temp_c': 18.3, 'temp_f': 64.9, 'is_day': 0, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/night/116.png', 'code': 1003}, 'wind_mph': 3.8, 'wind_kph': 6.1, 'wind_degree': 290, 'wind_dir': 'WNW', 'pressure_mb': 1010.0, 'pressure_in': 29.83, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 84, 'cloud': 50, 'feelslike_c': 18.3, 'feelslike_f': 64.9, 'windchill_c': 24.8, 'windchill_f': 76.6, 'heatindex_c': 25.7, 'heatindex_f': 78.3, 'dewpoint_c': 13.9, 'dewpoint_f': 57.0, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 1.0, 'gust_mph': 3.9, 'gust_kph': 6.2}}"}]
Back to the model!INFO:httpx:HTTP Request: POST https://api.chatanywhere.tech/v1/chat/completions "HTTP/1.1 200 OK"
INFO:__main__:LLM message: content='### San Francisco Weather:\n- **Temperature**: 16.1°C (61.0°F)\n- **Condition**: Partly cloudy\n- **Wind**: 9.4 mph (15.1 kph) from WNW\n- **Humidity**: 90%\n- **Visibility**: 16 km (9 miles)\n- **Pressure**: 1013 mb\n- **UV Index**: 1.0\n\n### Los Angeles Weather:\n- **Temperature**: 18.3°C (64.9°F)\n- **Condition**: Partly cloudy\n- **Wind**: 3.8 mph (6.1 kph) from WNW\n- **Humidity**: 84%\n- **Visibility**: 16 km (9 miles)\n- **Pressure**: 1010 mb\n- **UV Index**: 1.0' response_metadata={'token_usage': {'completion_tokens': 184, 'prompt_tokens': 1190, 'total_tokens': 1374}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_4008e3b719', 'finish_reason': 'stop', 'logprobs': None} id='run-c8c63c14-0b42-4b2a-8a52-5542b14311f5-0' usage_metadata={'input_tokens': 1190, 'output_tokens': 184, 'total_tokens': 1374}
INFO:__main__:exists_action result: content='### San Francisco Weather:\n- **Temperature**: 16.1°C (61.0°F)\n- **Condition**: Partly cloudy\n- **Wind**: 9.4 mph (15.1 kph) from WNW\n- **Humidity**: 90%\n- **Visibility**: 16 km (9 miles)\n- **Pressure**: 1013 mb\n- **UV Index**: 1.0\n\n### Los Angeles Weather:\n- **Temperature**: 18.3°C (64.9°F)\n- **Condition**: Partly cloudy\n- **Wind**: 3.8 mph (6.1 kph) from WNW\n- **Humidity**: 84%\n- **Visibility**: 16 km (9 miles)\n- **Pressure**: 1010 mb\n- **UV Index**: 1.0' response_metadata={'token_usage': {'completion_tokens': 184, 'prompt_tokens': 1190, 'total_tokens': 1374}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_4008e3b719', 'finish_reason': 'stop', 'logprobs': None} id='run-c8c63c14-0b42-4b2a-8a52-5542b14311f5-0' usage_metadata={'input_tokens': 1190, 'output_tokens': 184, 'total_tokens': 1374}
result['messages'][-1].content
'### San Francisco Weather:\n- **Temperature**: 16.1°C (61.0°F)\n- **Condition**: Partly cloudy\n- **Wind**: 9.4 mph (15.1 kph) from WNW\n- **Humidity**: 90%\n- **Visibility**: 16 km (9 miles)\n- **Pressure**: 1013 mb\n- **UV Index**: 1.0\n\n### Los Angeles Weather:\n- **Temperature**: 18.3°C (64.9°F)\n- **Condition**: Partly cloudy\n- **Wind**: 3.8 mph (6.1 kph) from WNW\n- **Humidity**: 84%\n- **Visibility**: 16 km (9 miles)\n- **Pressure**: 1010 mb\n- **UV Index**: 1.0'
query = "Who won the super bowl in 2024? In what state is the winning team headquarters located? \
What is the GDP of that state? Answer each question." 
messages = [HumanMessage(content=query)]
result = abot.graph.invoke({"messages": messages})
INFO:__main__:state: {'messages': [HumanMessage(content='Who won the super bowl in 2024? In what state is the winning team headquarters located? What is the GDP of that state? Answer each question.')]}
INFO:httpx:HTTP Request: POST https://api.chatanywhere.tech/v1/chat/completions "HTTP/1.1 200 OK"
INFO:__main__:LLM message: content='' additional_kwargs={'tool_calls': [{'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG', 'function': {'arguments': '{"query": "Super Bowl 2024 winner"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}, {'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc', 'function': {'arguments': '{"query": "GDP of state where the Super Bowl 2024 winning team is located"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 70, 'prompt_tokens': 177, 'total_tokens': 247}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_298125635f', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-c9583580-7404-491a-9e08-69fab8c54719-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'Super Bowl 2024 winner'}, 'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG'}, {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of state where the Super Bowl 2024 winning team is located'}, 'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc'}] usage_metadata={'input_tokens': 177, 'output_tokens': 70, 'total_tokens': 247}
INFO:__main__:exists_action result: content='' additional_kwargs={'tool_calls': [{'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG', 'function': {'arguments': '{"query": "Super Bowl 2024 winner"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}, {'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc', 'function': {'arguments': '{"query": "GDP of state where the Super Bowl 2024 winning team is located"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 70, 'prompt_tokens': 177, 'total_tokens': 247}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_298125635f', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-c9583580-7404-491a-9e08-69fab8c54719-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'Super Bowl 2024 winner'}, 'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG'}, {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of state where the Super Bowl 2024 winning team is located'}, 'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc'}] usage_metadata={'input_tokens': 177, 'output_tokens': 70, 'total_tokens': 247}
INFO:__main__:Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'Super Bowl 2024 winner'}, 'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG'}take_action called in thread: ThreadPoolExecutor-2_0
take_action called with tool_calls: [{'name': 'tavily_search_results_json', 'args': {'query': 'Super Bowl 2024 winner'}, 'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG'}, {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of state where the Super Bowl 2024 winning team is located'}, 'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc'}]
Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'Super Bowl 2024 winner'}, 'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG'}INFO:__main__:action tavily_search_results_json, result: [{'url': 'https://apnews.com/live/super-bowl-2024-updates', 'content': 'Throw in the fact that Chiefs coach Andy Reid will be in his fifth Super Bowl, the third most in NFL history, and has a chance to win a third ring, and the knowledge on the Kansas City sideline will be an advantage too big for the 49ers to overcome.\n She performed in Japan on Saturday night before a flight across nine time zones and the international date line to reach the U.S.\nRihanna performs during halftime of the NFL Super Bowl 57 football game between the Philadelphia Eagles and the Kansas City Chiefs, Sunday, Feb. 12, 2023, in Glendale, Ariz. (AP Photo/David J. Phillip)\n After the teams take the field, Post Malone will perform “America the Beautiful” and Reba McEntire will sing “The Star-Spangled Banner.”\nSan Francisco 49ers quarterback Brock Purdy (13) warms up before the NFL Super Bowl 58 football game against the Kansas City Chiefs, Sunday, Feb. 11, 2024, in Las Vegas. He was also the referee when the Chiefs beat the 49ers in the Super Bowl four years ago — and when the Rams beat the Saints in the 2019 NFC championship game after an infamous missed call.\n Purdy’s comeback from the injury to his throwing arm suffered in last season’s NFC championship loss to the Philadelphia Eagles has been part of the storybook start to his career that started as Mr. Irrelevant as the 262nd pick in the 2022 draft.\n'}, {'url': 'https://www.cbssports.com/nfl/news/2024-super-bowl-chiefs-vs-49ers-score-patrick-mahomes-leads-ot-comeback-as-k-c-wins-back-to-back-titles/live/', 'content': "The championship-winning drive, which included a fourth-and-1 scramble from Mahomes and a clutch 7-yard catch from tight end Travis Kelce, was a must-score for K.C. The NFL's new playoff overtime rules -- both teams are guaranteed at least one possession in the extra period -- were in effect for the first time, and the Chiefs needed to answer the Niners' field goal.\n Held out of the end zone until that point, Kansas City grabbed its first lead of the game at 13-10.\nJennings' touchdown receiving (followed by a missed extra point) concluded a 75-yard drive that put the Niners back on top, 16-13, as the wideout joined former Philadelphia Eagles quarterback Nick Foles as the only players to throw and catch a touchdown in a Super Bowl.\n He spread the ball around -- eight pass-catchers had at least two receptions -- slowly but surely overcoming a threatening 49ers defense that knocked him off his spot consistently in the first half.\nMahomes, with his third Super Bowl MVP, now sits alongside Tom Brady (five) and Joe Montana (three) atop the mountain while becoming just the third player to win the award back-to-back, joining Bart Starr (I-II) and Terry Bradshaw (XIII-XIV).\n The muffed punt that bounced off of cornerback Darrell Luter Jr.'s ankle was also the big break that the Chiefs needed as they scored on the very next play to take the lead for the first time in the game. College Pick'em\nA Daily SportsLine Betting Podcast\nNFL Playoff Time!\n2024 Super Bowl, Chiefs vs. 49ers score: Patrick Mahomes leads OT comeback as K.C. wins back-to-back titles\nCall it a dynasty; the Chiefs are the first team to win consecutive Super Bowls since 2003-04\nThe Kansas City Chiefs are Super Bowl champions, again."}]
INFO:__main__:Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of state where the Super Bowl 2024 winning team is located'}, 'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc'}action tavily_search_results_json, result: [{'url': 'https://apnews.com/live/super-bowl-2024-updates', 'content': 'Throw in the fact that Chiefs coach Andy Reid will be in his fifth Super Bowl, the third most in NFL history, and has a chance to win a third ring, and the knowledge on the Kansas City sideline will be an advantage too big for the 49ers to overcome.\n She performed in Japan on Saturday night before a flight across nine time zones and the international date line to reach the U.S.\nRihanna performs during halftime of the NFL Super Bowl 57 football game between the Philadelphia Eagles and the Kansas City Chiefs, Sunday, Feb. 12, 2023, in Glendale, Ariz. (AP Photo/David J. Phillip)\n After the teams take the field, Post Malone will perform “America the Beautiful” and Reba McEntire will sing “The Star-Spangled Banner.”\nSan Francisco 49ers quarterback Brock Purdy (13) warms up before the NFL Super Bowl 58 football game against the Kansas City Chiefs, Sunday, Feb. 11, 2024, in Las Vegas. He was also the referee when the Chiefs beat the 49ers in the Super Bowl four years ago — and when the Rams beat the Saints in the 2019 NFC championship game after an infamous missed call.\n Purdy’s comeback from the injury to his throwing arm suffered in last season’s NFC championship loss to the Philadelphia Eagles has been part of the storybook start to his career that started as Mr. Irrelevant as the 262nd pick in the 2022 draft.\n'}, {'url': 'https://www.cbssports.com/nfl/news/2024-super-bowl-chiefs-vs-49ers-score-patrick-mahomes-leads-ot-comeback-as-k-c-wins-back-to-back-titles/live/', 'content': "The championship-winning drive, which included a fourth-and-1 scramble from Mahomes and a clutch 7-yard catch from tight end Travis Kelce, was a must-score for K.C. The NFL's new playoff overtime rules -- both teams are guaranteed at least one possession in the extra period -- were in effect for the first time, and the Chiefs needed to answer the Niners' field goal.\n Held out of the end zone until that point, Kansas City grabbed its first lead of the game at 13-10.\nJennings' touchdown receiving (followed by a missed extra point) concluded a 75-yard drive that put the Niners back on top, 16-13, as the wideout joined former Philadelphia Eagles quarterback Nick Foles as the only players to throw and catch a touchdown in a Super Bowl.\n He spread the ball around -- eight pass-catchers had at least two receptions -- slowly but surely overcoming a threatening 49ers defense that knocked him off his spot consistently in the first half.\nMahomes, with his third Super Bowl MVP, now sits alongside Tom Brady (five) and Joe Montana (three) atop the mountain while becoming just the third player to win the award back-to-back, joining Bart Starr (I-II) and Terry Bradshaw (XIII-XIV).\n The muffed punt that bounced off of cornerback Darrell Luter Jr.'s ankle was also the big break that the Chiefs needed as they scored on the very next play to take the lead for the first time in the game. College Pick'em\nA Daily SportsLine Betting Podcast\nNFL Playoff Time!\n2024 Super Bowl, Chiefs vs. 49ers score: Patrick Mahomes leads OT comeback as K.C. wins back-to-back titles\nCall it a dynasty; the Chiefs are the first team to win consecutive Super Bowls since 2003-04\nThe Kansas City Chiefs are Super Bowl champions, again."}]
Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of state where the Super Bowl 2024 winning team is located'}, 'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc'}INFO:__main__:action tavily_search_results_json, result: [{'url': 'https://www.forbes.com/sites/jefffedotin/2024/06/03/super-bowl-lviii-generated-1-billion-economic-impact-for-las-vegas/', 'content': 'An average of 123.7 million watched the Kansas City Chiefs defeat the San Francisco 49ers in a 25-22, overtime classic on Super Bowl Sunday, but for Las Vegas, the economic impact started much ...'}, {'url': 'https://www.rollingstone.com/culture/culture-features/2024-super-bowl-helping-las-vegas-economy-1234964688/', 'content': "The 2024 Super Bowl Is Helping Las Vegas' Economy More Than Usual. big profits. Las Vegas Spent Decades Deprived of the Super Bowl. Now It Could Bring in $700 Million. After years of the NFL ..."}]
INFO:__main__:state: {'messages': [HumanMessage(content='Who won the super bowl in 2024? In what state is the winning team headquarters located? What is the GDP of that state? Answer each question.'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG', 'function': {'arguments': '{"query": "Super Bowl 2024 winner"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}, {'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc', 'function': {'arguments': '{"query": "GDP of state where the Super Bowl 2024 winning team is located"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 70, 'prompt_tokens': 177, 'total_tokens': 247}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_298125635f', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-c9583580-7404-491a-9e08-69fab8c54719-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'Super Bowl 2024 winner'}, 'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG'}, {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of state where the Super Bowl 2024 winning team is located'}, 'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc'}], usage_metadata={'input_tokens': 177, 'output_tokens': 70, 'total_tokens': 247}), ToolMessage(content='[{\'url\': \'https://apnews.com/live/super-bowl-2024-updates\', \'content\': \'Throw in the fact that Chiefs coach Andy Reid will be in his fifth Super Bowl, the third most in NFL history, and has a chance to win a third ring, and the knowledge on the Kansas City sideline will be an advantage too big for the 49ers to overcome.\\n She performed in Japan on Saturday night before a flight across nine time zones and the international date line to reach the U.S.\\nRihanna performs during halftime of the NFL Super Bowl 57 football game between the Philadelphia Eagles and the Kansas City Chiefs, Sunday, Feb. 12, 2023, in Glendale, Ariz. (AP Photo/David J. Phillip)\\n After the teams take the field, Post Malone will perform “America the Beautiful” and Reba McEntire will sing “The Star-Spangled Banner.”\\nSan Francisco 49ers quarterback Brock Purdy (13) warms up before the NFL Super Bowl 58 football game against the Kansas City Chiefs, Sunday, Feb. 11, 2024, in Las Vegas. He was also the referee when the Chiefs beat the 49ers in the Super Bowl four years ago — and when the Rams beat the Saints in the 2019 NFC championship game after an infamous missed call.\\n Purdy’s comeback from the injury to his throwing arm suffered in last season’s NFC championship loss to the Philadelphia Eagles has been part of the storybook start to his career that started as Mr. Irrelevant as the 262nd pick in the 2022 draft.\\n\'}, {\'url\': \'https://www.cbssports.com/nfl/news/2024-super-bowl-chiefs-vs-49ers-score-patrick-mahomes-leads-ot-comeback-as-k-c-wins-back-to-back-titles/live/\', \'content\': "The championship-winning drive, which included a fourth-and-1 scramble from Mahomes and a clutch 7-yard catch from tight end Travis Kelce, was a must-score for K.C. The NFL\'s new playoff overtime rules -- both teams are guaranteed at least one possession in the extra period -- were in effect for the first time, and the Chiefs needed to answer the Niners\' field goal.\\n Held out of the end zone until that point, Kansas City grabbed its first lead of the game at 13-10.\\nJennings\' touchdown receiving (followed by a missed extra point) concluded a 75-yard drive that put the Niners back on top, 16-13, as the wideout joined former Philadelphia Eagles quarterback Nick Foles as the only players to throw and catch a touchdown in a Super Bowl.\\n He spread the ball around -- eight pass-catchers had at least two receptions -- slowly but surely overcoming a threatening 49ers defense that knocked him off his spot consistently in the first half.\\nMahomes, with his third Super Bowl MVP, now sits alongside Tom Brady (five) and Joe Montana (three) atop the mountain while becoming just the third player to win the award back-to-back, joining Bart Starr (I-II) and Terry Bradshaw (XIII-XIV).\\n The muffed punt that bounced off of cornerback Darrell Luter Jr.\'s ankle was also the big break that the Chiefs needed as they scored on the very next play to take the lead for the first time in the game. College Pick\'em\\nA Daily SportsLine Betting Podcast\\nNFL Playoff Time!\\n2024 Super Bowl, Chiefs vs. 49ers score: Patrick Mahomes leads OT comeback as K.C. wins back-to-back titles\\nCall it a dynasty; the Chiefs are the first team to win consecutive Super Bowls since 2003-04\\nThe Kansas City Chiefs are Super Bowl champions, again."}]', name='tavily_search_results_json', tool_call_id='call_r4Su82QJqD03HLQ2Anh5f6eG'), ToolMessage(content='[{\'url\': \'https://www.forbes.com/sites/jefffedotin/2024/06/03/super-bowl-lviii-generated-1-billion-economic-impact-for-las-vegas/\', \'content\': \'An average of 123.7 million watched the Kansas City Chiefs defeat the San Francisco 49ers in a 25-22, overtime classic on Super Bowl Sunday, but for Las Vegas, the economic impact started much ...\'}, {\'url\': \'https://www.rollingstone.com/culture/culture-features/2024-super-bowl-helping-las-vegas-economy-1234964688/\', \'content\': "The 2024 Super Bowl Is Helping Las Vegas\' Economy More Than Usual. big profits. Las Vegas Spent Decades Deprived of the Super Bowl. Now It Could Bring in $700 Million. After years of the NFL ..."}]', name='tavily_search_results_json', tool_call_id='call_uNfBjk7uNU7yuDj0HEkgIzsc')]}action tavily_search_results_json, result: [{'url': 'https://www.forbes.com/sites/jefffedotin/2024/06/03/super-bowl-lviii-generated-1-billion-economic-impact-for-las-vegas/', 'content': 'An average of 123.7 million watched the Kansas City Chiefs defeat the San Francisco 49ers in a 25-22, overtime classic on Super Bowl Sunday, but for Las Vegas, the economic impact started much ...'}, {'url': 'https://www.rollingstone.com/culture/culture-features/2024-super-bowl-helping-las-vegas-economy-1234964688/', 'content': "The 2024 Super Bowl Is Helping Las Vegas' Economy More Than Usual. big profits. Las Vegas Spent Decades Deprived of the Super Bowl. Now It Could Bring in $700 Million. After years of the NFL ..."}]
Back to the model!INFO:httpx:HTTP Request: POST https://api.chatanywhere.tech/v1/chat/completions "HTTP/1.1 200 OK"
INFO:__main__:LLM message: content='1. The Kansas City Chiefs won the Super Bowl in 2024.\n2. The headquarters of the Kansas City Chiefs is located in Kansas City, Missouri.\n3. I will now look up the GDP of Missouri.' additional_kwargs={'tool_calls': [{'id': 'call_yHyeCHMR88aog66cjLdOYTYf', 'function': {'arguments': '{"query":"GDP of Missouri 2024"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 68, 'prompt_tokens': 1267, 'total_tokens': 1335}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-dfad5985-c34f-4c56-ab0f-7eec127e4419-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'GDP of Missouri 2024'}, 'id': 'call_yHyeCHMR88aog66cjLdOYTYf'}] usage_metadata={'input_tokens': 1267, 'output_tokens': 68, 'total_tokens': 1335}
INFO:__main__:exists_action result: content='1. The Kansas City Chiefs won the Super Bowl in 2024.\n2. The headquarters of the Kansas City Chiefs is located in Kansas City, Missouri.\n3. I will now look up the GDP of Missouri.' additional_kwargs={'tool_calls': [{'id': 'call_yHyeCHMR88aog66cjLdOYTYf', 'function': {'arguments': '{"query":"GDP of Missouri 2024"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]} response_metadata={'token_usage': {'completion_tokens': 68, 'prompt_tokens': 1267, 'total_tokens': 1335}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'tool_calls', 'logprobs': None} id='run-dfad5985-c34f-4c56-ab0f-7eec127e4419-0' tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'GDP of Missouri 2024'}, 'id': 'call_yHyeCHMR88aog66cjLdOYTYf'}] usage_metadata={'input_tokens': 1267, 'output_tokens': 68, 'total_tokens': 1335}
INFO:__main__:Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of Missouri 2024'}, 'id': 'call_yHyeCHMR88aog66cjLdOYTYf'}take_action called in thread: ThreadPoolExecutor-2_0
take_action called with tool_calls: [{'name': 'tavily_search_results_json', 'args': {'query': 'GDP of Missouri 2024'}, 'id': 'call_yHyeCHMR88aog66cjLdOYTYf'}]
Calling: {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of Missouri 2024'}, 'id': 'call_yHyeCHMR88aog66cjLdOYTYf'}INFO:__main__:action tavily_search_results_json, result: [{'url': 'https://usafacts.org/topics/economy/state/missouri/', 'content': "Real gross domestic product (GDP) Missouri's share of the US economy. Real gross domestic product (GDP) by industry. ... A majority of funding for the 2024 election — over 65%, or nearly $5.6 billion — comes from political action committees, also known as PACs. Published on May 17, 2024."}, {'url': 'https://www.bea.gov/data/gdp/gdp-state', 'content': 'Gross Domestic Product by State and Personal Income by State, 1st Quarter 2024. Real gross domestic product (GDP) increased in 39 states and the District of Columbia in the first quarter of 2024, with the percent change ranging from 5.0 percent at an annual rate in Idaho to -4.2 percent in South Dakota. Current Release. Current Release: June ...'}]
INFO:__main__:state: {'messages': [HumanMessage(content='Who won the super bowl in 2024? In what state is the winning team headquarters located? What is the GDP of that state? Answer each question.'), AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG', 'function': {'arguments': '{"query": "Super Bowl 2024 winner"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}, {'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc', 'function': {'arguments': '{"query": "GDP of state where the Super Bowl 2024 winning team is located"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 70, 'prompt_tokens': 177, 'total_tokens': 247}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_298125635f', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-c9583580-7404-491a-9e08-69fab8c54719-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'Super Bowl 2024 winner'}, 'id': 'call_r4Su82QJqD03HLQ2Anh5f6eG'}, {'name': 'tavily_search_results_json', 'args': {'query': 'GDP of state where the Super Bowl 2024 winning team is located'}, 'id': 'call_uNfBjk7uNU7yuDj0HEkgIzsc'}], usage_metadata={'input_tokens': 177, 'output_tokens': 70, 'total_tokens': 247}), ToolMessage(content='[{\'url\': \'https://apnews.com/live/super-bowl-2024-updates\', \'content\': \'Throw in the fact that Chiefs coach Andy Reid will be in his fifth Super Bowl, the third most in NFL history, and has a chance to win a third ring, and the knowledge on the Kansas City sideline will be an advantage too big for the 49ers to overcome.\\n She performed in Japan on Saturday night before a flight across nine time zones and the international date line to reach the U.S.\\nRihanna performs during halftime of the NFL Super Bowl 57 football game between the Philadelphia Eagles and the Kansas City Chiefs, Sunday, Feb. 12, 2023, in Glendale, Ariz. (AP Photo/David J. Phillip)\\n After the teams take the field, Post Malone will perform “America the Beautiful” and Reba McEntire will sing “The Star-Spangled Banner.”\\nSan Francisco 49ers quarterback Brock Purdy (13) warms up before the NFL Super Bowl 58 football game against the Kansas City Chiefs, Sunday, Feb. 11, 2024, in Las Vegas. He was also the referee when the Chiefs beat the 49ers in the Super Bowl four years ago — and when the Rams beat the Saints in the 2019 NFC championship game after an infamous missed call.\\n Purdy’s comeback from the injury to his throwing arm suffered in last season’s NFC championship loss to the Philadelphia Eagles has been part of the storybook start to his career that started as Mr. Irrelevant as the 262nd pick in the 2022 draft.\\n\'}, {\'url\': \'https://www.cbssports.com/nfl/news/2024-super-bowl-chiefs-vs-49ers-score-patrick-mahomes-leads-ot-comeback-as-k-c-wins-back-to-back-titles/live/\', \'content\': "The championship-winning drive, which included a fourth-and-1 scramble from Mahomes and a clutch 7-yard catch from tight end Travis Kelce, was a must-score for K.C. The NFL\'s new playoff overtime rules -- both teams are guaranteed at least one possession in the extra period -- were in effect for the first time, and the Chiefs needed to answer the Niners\' field goal.\\n Held out of the end zone until that point, Kansas City grabbed its first lead of the game at 13-10.\\nJennings\' touchdown receiving (followed by a missed extra point) concluded a 75-yard drive that put the Niners back on top, 16-13, as the wideout joined former Philadelphia Eagles quarterback Nick Foles as the only players to throw and catch a touchdown in a Super Bowl.\\n He spread the ball around -- eight pass-catchers had at least two receptions -- slowly but surely overcoming a threatening 49ers defense that knocked him off his spot consistently in the first half.\\nMahomes, with his third Super Bowl MVP, now sits alongside Tom Brady (five) and Joe Montana (three) atop the mountain while becoming just the third player to win the award back-to-back, joining Bart Starr (I-II) and Terry Bradshaw (XIII-XIV).\\n The muffed punt that bounced off of cornerback Darrell Luter Jr.\'s ankle was also the big break that the Chiefs needed as they scored on the very next play to take the lead for the first time in the game. College Pick\'em\\nA Daily SportsLine Betting Podcast\\nNFL Playoff Time!\\n2024 Super Bowl, Chiefs vs. 49ers score: Patrick Mahomes leads OT comeback as K.C. wins back-to-back titles\\nCall it a dynasty; the Chiefs are the first team to win consecutive Super Bowls since 2003-04\\nThe Kansas City Chiefs are Super Bowl champions, again."}]', name='tavily_search_results_json', tool_call_id='call_r4Su82QJqD03HLQ2Anh5f6eG'), ToolMessage(content='[{\'url\': \'https://www.forbes.com/sites/jefffedotin/2024/06/03/super-bowl-lviii-generated-1-billion-economic-impact-for-las-vegas/\', \'content\': \'An average of 123.7 million watched the Kansas City Chiefs defeat the San Francisco 49ers in a 25-22, overtime classic on Super Bowl Sunday, but for Las Vegas, the economic impact started much ...\'}, {\'url\': \'https://www.rollingstone.com/culture/culture-features/2024-super-bowl-helping-las-vegas-economy-1234964688/\', \'content\': "The 2024 Super Bowl Is Helping Las Vegas\' Economy More Than Usual. big profits. Las Vegas Spent Decades Deprived of the Super Bowl. Now It Could Bring in $700 Million. After years of the NFL ..."}]', name='tavily_search_results_json', tool_call_id='call_uNfBjk7uNU7yuDj0HEkgIzsc'), AIMessage(content='1. The Kansas City Chiefs won the Super Bowl in 2024.\n2. The headquarters of the Kansas City Chiefs is located in Kansas City, Missouri.\n3. I will now look up the GDP of Missouri.', additional_kwargs={'tool_calls': [{'id': 'call_yHyeCHMR88aog66cjLdOYTYf', 'function': {'arguments': '{"query":"GDP of Missouri 2024"}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 68, 'prompt_tokens': 1267, 'total_tokens': 1335}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-dfad5985-c34f-4c56-ab0f-7eec127e4419-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'GDP of Missouri 2024'}, 'id': 'call_yHyeCHMR88aog66cjLdOYTYf'}], usage_metadata={'input_tokens': 1267, 'output_tokens': 68, 'total_tokens': 1335}), ToolMessage(content='[{\'url\': \'https://usafacts.org/topics/economy/state/missouri/\', \'content\': "Real gross domestic product (GDP) Missouri\'s share of the US economy. Real gross domestic product (GDP) by industry. ... A majority of funding for the 2024 election — over 65%, or nearly $5.6 billion — comes from political action committees, also known as PACs. Published on May 17, 2024."}, {\'url\': \'https://www.bea.gov/data/gdp/gdp-state\', \'content\': \'Gross Domestic Product by State and Personal Income by State, 1st Quarter 2024. Real gross domestic product (GDP) increased in 39 states and the District of Columbia in the first quarter of 2024, with the percent change ranging from 5.0 percent at an annual rate in Idaho to -4.2 percent in South Dakota. Current Release. Current Release: June ...\'}]', name='tavily_search_results_json', tool_call_id='call_yHyeCHMR88aog66cjLdOYTYf')]}action tavily_search_results_json, result: [{'url': 'https://usafacts.org/topics/economy/state/missouri/', 'content': "Real gross domestic product (GDP) Missouri's share of the US economy. Real gross domestic product (GDP) by industry. ... A majority of funding for the 2024 election — over 65%, or nearly $5.6 billion — comes from political action committees, also known as PACs. Published on May 17, 2024."}, {'url': 'https://www.bea.gov/data/gdp/gdp-state', 'content': 'Gross Domestic Product by State and Personal Income by State, 1st Quarter 2024. Real gross domestic product (GDP) increased in 39 states and the District of Columbia in the first quarter of 2024, with the percent change ranging from 5.0 percent at an annual rate in Idaho to -4.2 percent in South Dakota. Current Release. Current Release: June ...'}]
Back to the model!INFO:httpx:HTTP Request: POST https://api.chatanywhere.tech/v1/chat/completions "HTTP/1.1 200 OK"
INFO:__main__:LLM message: content="1. **Super Bowl 2024 Winner**: The Kansas City Chiefs won the Super Bowl in 2024.\n2. **Location of Winning Team's Headquarters**: The headquarters of the Kansas City Chiefs is located in Kansas City, Missouri.\n3. **GDP of Missouri**: The most recent data indicates that Missouri's GDP is detailed on the [Bureau of Economic Analysis (BEA) website](https://www.bea.gov/data/gdp/gdp-state). As of the first quarter of 2024, Missouri is part of the states where the real gross domestic product (GDP) increased, but specific figures for Missouri's GDP in 2024 were not provided in the search results. For precise and updated figures, you can check the BEA's latest release on state GDP." response_metadata={'token_usage': {'completion_tokens': 162, 'prompt_tokens': 1549, 'total_tokens': 1711}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'stop', 'logprobs': None} id='run-3d28fe7f-51c1-40d1-85eb-45689a3cd2bd-0' usage_metadata={'input_tokens': 1549, 'output_tokens': 162, 'total_tokens': 1711}
INFO:__main__:exists_action result: content="1. **Super Bowl 2024 Winner**: The Kansas City Chiefs won the Super Bowl in 2024.\n2. **Location of Winning Team's Headquarters**: The headquarters of the Kansas City Chiefs is located in Kansas City, Missouri.\n3. **GDP of Missouri**: The most recent data indicates that Missouri's GDP is detailed on the [Bureau of Economic Analysis (BEA) website](https://www.bea.gov/data/gdp/gdp-state). As of the first quarter of 2024, Missouri is part of the states where the real gross domestic product (GDP) increased, but specific figures for Missouri's GDP in 2024 were not provided in the search results. For precise and updated figures, you can check the BEA's latest release on state GDP." response_metadata={'token_usage': {'completion_tokens': 162, 'prompt_tokens': 1549, 'total_tokens': 1711}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_d33f7b429e', 'finish_reason': 'stop', 'logprobs': None} id='run-3d28fe7f-51c1-40d1-85eb-45689a3cd2bd-0' usage_metadata={'input_tokens': 1549, 'output_tokens': 162, 'total_tokens': 1711}
print(result['messages'][-1].content)
1. **Super Bowl 2024 Winner**: The Kansas City Chiefs won the Super Bowl in 2024.
2. **Location of Winning Team's Headquarters**: The headquarters of the Kansas City Chiefs is located in Kansas City, Missouri.
3. **GDP of Missouri**: The most recent data indicates that Missouri's GDP is detailed on the [Bureau of Economic Analysis (BEA) website](https://www.bea.gov/data/gdp/gdp-state). As of the first quarter of 2024, Missouri is part of the states where the real gross domestic product (GDP) increased, but specific figures for Missouri's GDP in 2024 were not provided in the search results. For precise and updated figures, you can check the BEA's latest release on state GDP.
he first quarter of 2024, Missouri is part of the states where the real gross domestic product (GDP) increased, but specific figures for Missouri's GDP in 2024 were not provided in the search results. For precise and updated figures, you can check the BEA's latest release on state GDP.

相关文章:

L2 LangGraph_Components

参考自https://www.deeplearning.ai/short-courses/ai-agents-in-langgraph&#xff0c;以下为代码的实现。 这里用LangGraph把L1的ReAct_Agent实现&#xff0c;可以看出用LangGraph流程化了很多。 LangGraph Components import os from dotenv import load_dotenv, find_do…...

09.C2W4.Word Embeddings with Neural Networks

往期文章请点这里 目录 OverviewBasic Word RepresentationsIntegersOne-hot vectors Word EmbeddingsMeaning as vectorsWord embedding vectors Word embedding processWord Embedding MethodsBasic word embedding methodsAdvanced word embedding methods Continuous Bag-…...

硅谷甄选二(登录)

一、登录路由静态组件 src\views\login\index.vue <template><div class"login_container"><!-- Layout 布局 --><el-row><el-col :span"12" :xs"0"></el-col><el-col :span"12" :xs"2…...

scipy库中,不同应用滤波函数的区别,以及FIR滤波器和IIR滤波器的区别

一、在 Python 中&#xff0c;有多种函数可以用于应用 FIR/IIR 滤波器&#xff0c;每个函数的使用场景和特点各不相同。以下是一些常用的 FIR /IIR滤波器应用函数及其区别&#xff1a; from scipy.signal import lfiltery lfilter(fir_coeff, 1.0, x)from scipy.signal impo…...

简谈设计模式之建造者模式

建造者模式是一种创建型设计模式, 旨在将复杂对象的构建过程与其表示分离, 使同样的构建过程可以构建不同的表示. 建造者模式主要用于以下情况: 需要创建的对象非常复杂: 这个对象由多个部分组成, 且这些部分需要一步步地构建不同的表示: 通过相同的构建过程可以生成不同的表示…...

力扣 hot100 -- 动态规划(下)

目录 &#x1f4bb;最长递增子序列 AC 动态规划 AC 动态规划(贪心) 二分 &#x1f3e0;乘积最大子数组 AC 动规 AC 用 0 分割 &#x1f42c;分割等和子集 AC 二维DP AC 一维DP ⚾最长有效括号 AC 栈 哨兵 &#x1f4bb;最长递增子序列 300. 最长递增子序列…...

【计算机毕业设计】018基于weixin小程序实习记录

&#x1f64a;作者简介&#xff1a;拥有多年开发工作经验&#xff0c;分享技术代码帮助学生学习&#xff0c;独立完成自己的项目或者毕业设计。 代码可以私聊博主获取。&#x1f339;赠送计算机毕业设计600个选题excel文件&#xff0c;帮助大学选题。赠送开题报告模板&#xff…...

力扣之有序链表去重

删除链表中的重复元素&#xff0c;重复元素保留一个 p1 p2 1 -> 1 -> 2 -> 3 -> 3 -> null p1.val p2.val 那么删除 p2&#xff0c;注意 p1 此时保持不变 p1 p2 1 -> 2 -> 3 -> 3 -> null p1.val ! p2.val 那么 p1&#xff0c;p2 向后移动 p1 …...

Apache配置与应用(优化apache)

Apache配置解析&#xff08;配置优化&#xff09; Apache链接保持 KeepAlive&#xff1a;决定是否打开连接保持功能&#xff0c;后面接 OFF 表示关闭&#xff0c;接 ON 表示打开 KeepAliveTimeout&#xff1a;表示一次连接多次请求之间的最大间隔时间&#xff0c;即两次请求之间…...

怎么将3张照片合并成一张?这几种拼接方法很实用!

怎么将3张照片合并成一张&#xff1f;在我们丰富多彩的日常生活里&#xff0c;是否总爱捕捉那些稍纵即逝的美好瞬间&#xff0c;将它们定格为一张张珍贵的图片&#xff1f;然而&#xff0c;随着时间的推移&#xff0c;这些满载回忆的宝藏却可能逐渐演变成一项管理挑战&#xff…...

YOLOv10改进 | 图像去雾 | MB-TaylorFormer改善YOLOv10高分辨率和图像去雾检测(ICCV,全网独家首发)

一、本文介绍 本文给大家带来的改进机制是图像去雾MB-TaylorFormer&#xff0c;其发布于2023年的国际计算机视觉会议&#xff08;ICCV&#xff09;上&#xff0c;可以算是一遍比较权威的图像去雾网络&#xff0c; MB-TaylorFormer是一种为图像去雾设计的多分支高效Transformer…...

spring boot读取yml配置注意点记录

问题1&#xff1a;yml中配置的值加载到代码后值变了。 现场yml配置如下&#xff1a; type-maps:infos:data_register: 0ns_xzdy: 010000ns_zldy: 020000ns_yl: 030000ns_jzjz: 040000ns_ggglyggfwjz: 050000ns_syffyjz: 060000ns_gyjz: 070000ns_ccywljz: 080000ns_qtjz: 090…...

电子电气架构 --- 关于DoIP的一些闲思 下

我是穿拖鞋的汉子,魔都中坚持长期主义的汽车电子工程师。 老规矩,分享一段喜欢的文字,避免自己成为高知识低文化的工程师: 屏蔽力是信息过载时代一个人的特殊竞争力,任何消耗你的人和事,多看一眼都是你的不对。非必要不费力证明自己,无利益不试图说服别人,是精神上的节…...

Java getSuperclass和getGenericSuperclass

1.官方API对这两个方法的介绍 getSuperclass : 返回表示此 Class 所表示的实体&#xff08;类、接口、基本类型或 void&#xff09;的超类的 Class。如果此 Class 表示 Object 类、一个接口、一个基本类型或 void&#xff0c;则返回 null。如果此对象表示一个数组类&#xff…...

ARM功耗管理标准接口之ACPI

安全之安全(security)博客目录导读 思考&#xff1a;功耗管理有哪些标准接口&#xff1f;ACPI&PSCI&SCMI&#xff1f; Advanced Configuration and Power Interface Power State Coordination Interface System Control and Management Interface ACPI可以被理解为一…...

2024年网络监控软件排名|10大网络监控软件是哪些

网络安全&#xff0c;小到关系到企业的生死存亡&#xff0c;大到关系到国家的生死存亡。 因此网络安全刻不容缓&#xff0c;在这里推荐网络监控软件。 2024年这10款软件火爆监控市场。 1.安企神软件&#xff1a; 7天免费试用https://work.weixin.qq.com/ca/cawcde06a33907e6…...

通过Arcgis从逐月平均气温数据中提取并计算年平均气温

通过Arcgis快速将逐月平均气温数据生成年平均气温数据。本次用2020年逐月平均气温数据操作说明。 一、准备工作 &#xff08;1&#xff09;准备Arcmap桌面软件&#xff1b; &#xff08;2&#xff09;准备2020年逐月平均气温数据&#xff08;NC格式&#xff09;、范围图层数据&…...

每日一题~abc356(对于一串连续数字 找规律,开数值桶算贡献)

添加链接描述 题意&#xff1a;对于给定的n,m 。计算0~n 每一个数和m & 之后&#xff0c;得到的数 的二进制中 1的个数的和。 一位一位的算。最多是60位。 我们只需要计算 在 1-n这些数上&#xff0c;有多少个数 第i位 为1. 因为是连续的自然数&#xff0c;每一位上1 的…...

商业合作方案撰写指南:让你的提案脱颖而出的秘诀

作为一名策划人&#xff0c;撰写一份商业合作方案需要细致的规划和清晰的表达。 它是一个综合性的过程&#xff0c;需要策划人具备市场洞察力、分析能力和创意思维。 以下是能够帮助你撰写一份有效的商业合作方案的关键步骤和要点&#xff1a; 明确合作目标&#xff1a;设定…...

【MySQL】锁(黑马课程)

【MySQL】锁 0. 锁的考察点1. 概述1. 锁的分类1.1 属性分类1.2 粒度分类 2. 全局锁2.1 全局锁操作2.2.1 备份问题 3. 表级锁3.1 表锁3.2 语法3.3 表共享读锁&#xff08;读锁&#xff09;3.4 表独占写锁&#xff08;写锁&#xff09;3.5 元数据锁(meta data lock, MDL)3.6 意向…...

OpenLayers 可视化之热力图

注&#xff1a;当前使用的是 ol 5.3.0 版本&#xff0c;天地图使用的key请到天地图官网申请&#xff0c;并替换为自己的key 热力图&#xff08;Heatmap&#xff09;又叫热点图&#xff0c;是一种通过特殊高亮显示事物密度分布、变化趋势的数据可视化技术。采用颜色的深浅来显示…...

7.4.分块查找

一.分块查找的算法思想&#xff1a; 1.实例&#xff1a; 以上述图片的顺序表为例&#xff0c; 该顺序表的数据元素从整体来看是乱序的&#xff0c;但如果把这些数据元素分成一块一块的小区间&#xff0c; 第一个区间[0,1]索引上的数据元素都是小于等于10的&#xff0c; 第二…...

iOS 26 携众系统重磅更新,但“苹果智能”仍与国行无缘

美国西海岸的夏天&#xff0c;再次被苹果点燃。一年一度的全球开发者大会 WWDC25 如期而至&#xff0c;这不仅是开发者的盛宴&#xff0c;更是全球数亿苹果用户翘首以盼的科技春晚。今年&#xff0c;苹果依旧为我们带来了全家桶式的系统更新&#xff0c;包括 iOS 26、iPadOS 26…...

rknn优化教程(二)

文章目录 1. 前述2. 三方库的封装2.1 xrepo中的库2.2 xrepo之外的库2.2.1 opencv2.2.2 rknnrt2.2.3 spdlog 3. rknn_engine库 1. 前述 OK&#xff0c;开始写第二篇的内容了。这篇博客主要能写一下&#xff1a; 如何给一些三方库按照xmake方式进行封装&#xff0c;供调用如何按…...

mongodb源码分析session执行handleRequest命令find过程

mongo/transport/service_state_machine.cpp已经分析startSession创建ASIOSession过程&#xff0c;并且验证connection是否超过限制ASIOSession和connection是循环接受客户端命令&#xff0c;把数据流转换成Message&#xff0c;状态转变流程是&#xff1a;State::Created 》 St…...

如何在看板中体现优先级变化

在看板中有效体现优先级变化的关键措施包括&#xff1a;采用颜色或标签标识优先级、设置任务排序规则、使用独立的优先级列或泳道、结合自动化规则同步优先级变化、建立定期的优先级审查流程。其中&#xff0c;设置任务排序规则尤其重要&#xff0c;因为它让看板视觉上直观地体…...

解决Ubuntu22.04 VMware失败的问题 ubuntu入门之二十八

现象1 打开VMware失败 Ubuntu升级之后打开VMware上报需要安装vmmon和vmnet&#xff0c;点击确认后如下提示 最终上报fail 解决方法 内核升级导致&#xff0c;需要在新内核下重新下载编译安装 查看版本 $ vmware -v VMware Workstation 17.5.1 build-23298084$ lsb_release…...

Caliper 配置文件解析:config.yaml

Caliper 是一个区块链性能基准测试工具,用于评估不同区块链平台的性能。下面我将详细解释你提供的 fisco-bcos.json 文件结构,并说明它与 config.yaml 文件的关系。 fisco-bcos.json 文件解析 这个文件是针对 FISCO-BCOS 区块链网络的 Caliper 配置文件,主要包含以下几个部…...

聊一聊接口测试的意义有哪些?

目录 一、隔离性 & 早期测试 二、保障系统集成质量 三、验证业务逻辑的核心层 四、提升测试效率与覆盖度 五、系统稳定性的守护者 六、驱动团队协作与契约管理 七、性能与扩展性的前置评估 八、持续交付的核心支撑 接口测试的意义可以从四个维度展开&#xff0c;首…...

网站指纹识别

网站指纹识别 网站的最基本组成&#xff1a;服务器&#xff08;操作系统&#xff09;、中间件&#xff08;web容器&#xff09;、脚本语言、数据厍 为什么要了解这些&#xff1f;举个例子&#xff1a;发现了一个文件读取漏洞&#xff0c;我们需要读/etc/passwd&#xff0c;如…...