messages = [HumanMessage(content=“What is the weather in sf?”)]
result = abot.graph.invoke({“messages”: messages})
Got:
Calling: {‘name’: ‘tavily_search_results_json’, ‘args’: {‘query’: ‘weather in San Francisco’}, ‘id’: ‘call_cEb7nvJ0bxAXV2OmCwjEUFd3’, ‘type’: ‘tool_call’}
Back to the model!
Calling: {‘name’: ‘tavily_search_results_json’, ‘args’: {‘query’: ‘weather in San Francisco’}, ‘id’: ‘call_Ru5wcKggRlF7PBu3XXCR1vHC’, ‘type’: ‘tool_call’}
Back to the model!
Then issued int he next cell:
result
Then no results is return with
ToolMessage(content=“HTTPError(‘401 Client Error: Unauthorized for url: https://api.tavily.com/search’)”, name=‘tavily_search_results_json’, tool_call_id=‘call_cEb7nvJ0bxAXV2OmCwjEUFd3’),
error clearly states there is no authorisation to use api key from the url you have used.
make sure when you running codes locally you have your own api keys and also sometimes when a multi interference api keys is set up, chances are your own openai api key might work. You might need to go through the documentation for the codes you are trying to run for understanding the authorisation part.
oh ok then that should work, can you please post rather screenshot of the error you are encountering, rather than copy paste.
Also did you raise a ticket at tavily site about this error. because seems like the authorisation is blocked from there, probably they will know if there is any issue with your api key.
I also check if in your coded if the API keys are in discrepancy with some other module, even that can cause error.
I worked locally and I confirm that it works properly .
My suggestions to solve your issue are the followng :
From your message, it seems that you are using the default TAVILY_API_KEY. This should work, however it may have limited access and it may only work in specific scenarios. Therefore, my suggestion is to Generate Your Own TAVILY_API_KEY.
Another suggestion to solve the problem is to have a look how you have set up the value of TAVILY_API_KEY in the env. Remember it should be without quotes :
TAVILY_API_KEY=tvly-your-valid-api-key
Then,
# Load environment variables
load_dotenv()
# Print the API key to verify it is loaded correctly
print(f"TAVILY_API_KEY: {os.getenv('TAVILY_API_KEY')}")