当前位置: 首页 > 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 意向…...

1.10编程基础之简单排序--02:奇数单增序列

OpenJudge - 02:奇数单增序列http://noi.openjudge.cn/ch0110/02/ 描述 给定一个长度为N(不大于500)的正整数序列,请将其中的所有奇数取出,并按升序输出。 输入 共2行: 第1行为 N; 第2行为 N 个正整数,其间用空格间隔。 输出 增序输出的奇数序列,数据之间以逗号间隔。数…...

【leetcode78-81贪心算法、技巧96-100】

贪心算法【78-81】 121.买卖股票的最佳时机 class Solution:def maxProfit(self, prices: List[int]) -> int:dp[[0,0] for _ in range(len(prices))] #dp[i][0]第i天持有股票&#xff0c;dp[i][1]第i天不持有股票dp[0][0] -prices[0]for i in range(1, len(prices)):dp[…...

IEC62056标准体系简介-4.IEC62056-53 COSEM应用层

为在通信介质中传输COSEM对象模型&#xff0c;IEC62056参照OSI参考模型&#xff0c;制定了简化的三层通信模型&#xff0c;包括应用层、数据链路层&#xff08;或中间协议层&#xff09;和物理层&#xff0c;如图6所示。COSEM应用层完成对COSEM对象的属性和方法的访问&#xff…...

嵌入式应用开发之代码整洁之道

前言&#xff1a;本系列教程旨在如何将自己的代码写的整洁&#xff0c;同时也希望小伙伴们懂如何把代码写脏&#xff0c;以备不时之需&#xff0c;同时本系列参考 正点原子 &#xff0c; C代码整洁之道&#xff0c;编写可读的代码艺术。 #好的代码的特点 好的代码应该都有着几…...

iwconfig iwpriv学习之路

iwconfig和iwpriv是两个常用的wifi调试工具&#xff0c;最近需要使用这两个工具完成某款wifi芯片的定频测试&#xff0c;俗话说好记性不如烂笔头&#xff0c;于是再此记录下iwconfig和iwpriv的使用方式。 -----再牛逼的梦想&#xff0c;也抵不住傻逼般的坚持&#xff01; ----2…...

【Docker-compose】搭建php 环境

文章目录 Docker-compose容器编排1. 是什么2. 能干嘛3. 去哪下4. Compose 核心概念5. 实战 &#xff1a;linux 配置dns 服务器&#xff0c;搭建lemp环境&#xff08;Nginx MySQL (MariaDB) PHP &#xff09;要求6. 配置dns解析配置 lemp Docker-compose容器编排 1. 是什么 …...

【记录】LaTex|LaTex 代码片段 Listings 添加带圆圈数字标号的箭头(又名 LaTex Tikz 库画箭头的简要介绍)

文章目录 前言注意事项1 Tikz 的调用方法&#xff1a;newcommand2 标号圆圈数字的添加方式&#xff1a;\large{\textcircled{\small{1}}}\normalsize3 快速掌握 Tikz 箭头写法&#xff1a;插入点相对位移标号node3.1 第一张图&#xff1a;插入点相对位移3.2 第二张图&#xff1…...

《框架封装 · Redis 事件监听》

&#x1f4e2; 大家好&#xff0c;我是 【战神刘玉栋】&#xff0c;有10多年的研发经验&#xff0c;致力于前后端技术栈的知识沉淀和传播。 &#x1f497; &#x1f33b; CSDN入驻不久&#xff0c;希望大家多多支持&#xff0c;后续会继续提升文章质量&#xff0c;绝不滥竽充数…...

小白学webgl合集-Three.js加载器

THREE.TextureLoader: 用途: 加载单个图像文件并将其作为纹理应用到材质上。示例: const loader new THREE.DataTextureLoader(); loader.load(path/to/data.bin, function (texture) {const material new THREE.MeshBasicMaterial({ map: texture });const geometry new TH…...

【算法】字符串的排列

难度&#xff1a;中等 给你两个字符串 s1 和 s2 &#xff0c;写一个函数来判断 s2 是否包含 s1 的排列。如果是&#xff0c;返回 true &#xff1b;否则&#xff0c;返回 false 。 换句话说&#xff0c;s1 的排列之一是 s2 的 子串 。 示例 1&#xff1a; 输入&#xff1a;…...

网站服务器配置单/免费做网站怎么做网站链接

分享一下我老师大神的人工智能教程&#xff01;零基础&#xff0c;通俗易懂&#xff01;http://blog.csdn.net/jiangjunshow也欢迎大家转载本篇文章。分享知识&#xff0c;造福人民&#xff0c;实现我们中华民族伟大复兴&#xff01;SQL> set linesize 200SQL> set pages…...

如何制作网站后台/b站推广入口2023破解版

npm install laravel-echo-server -g安装了之后在其他目录无法执行&#xff0c;找不到命令&#xff0c;在windows下可以直接使用&#xff0c;在linux下需要配置下环境变量 npm prefix -g 该命令可以看到node全局环境的目录在哪里 将node环境中bin目录中的生成的 laravel-echo-…...

互联网公司的排名/杭州seo网站排名

本文翻译了 Material Design 规范中对底部导航的规范总结&#xff0c;希望可以带给你更多帮助。本文翻译了 Material Design 规范中对底部导航的规范总结&#xff0c;希望可以带给你更多帮助。备注&#xff1a;以下内容在翻译过程中根据阅读习惯有相应的调整&#xff0c;如有不…...

零基础网站建设教学服务/免费入驻的卖货平台

以下讨论的属性无论大小&#xff0c;收缩或者伸展&#xff0c;均是按照flex conntainer的主轴方向说的。 flex-grow: 是否允许flex item在多余空间内伸展。默认为0, 即不允许伸展。 flex-shrink: 是否允许flex item在flex container宽度收缩时自动收缩。默认为1&#xff0c;即允…...

怎样做网站变手机软件/韩国vs加纳分析比分

JSON的定义&#xff1a; 一种轻量级的数据交换格式&#xff0c;具有良好的可读和便于快速编写的特性。业内主流技术为其提供了完整的解决方案&#xff08;有点类似于正则表达式 &#xff0c;获得了当今大部分语言的支持&#xff09;&#xff0c;从而可以在不同平台间进行数据交…...

网站网页链接/关键词排名查询工具有哪些

【问题描述】 Lsy喜欢幸运数字&#xff0c;众所周知&#xff0c;幸运数字就是数字位上只有4和7的数字。 但是本题的幸运序列和幸运数字完全没关系&#xff0c;就是一个非常非常普通的序列。哈哈&#xff0c;是不是感觉被耍了&#xff0c;没错&#xff0c;你就是被耍了。 Lsy现在…...