422 Client Error: Unprocessable Entity for url: https://api.tavily.com/search
Closed this issue · 0 comments
Been digging through the code. Is this reproducable?
Press CTRL+C to quit 127.0.0.1 - - [27/Jan/2024 08:58:17] "OPTIONS /generate_newspaper HTTP/1.1" 200 - [2024-01-27 08:58:17,850] ERROR in app: Exception on /generate_newspaper [POST] Traceback (most recent call last): File "/home/dirk/.local/lib/python3.10/site-packages/flask/app.py", line 1463, in wsgi_app response = self.full_dispatch_request() File "/home/dirk/.local/lib/python3.10/site-packages/flask/app.py", line 872, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/dirk/.local/lib/python3.10/site-packages/flask_cors/extension.py", line 176, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/home/dirk/.local/lib/python3.10/site-packages/flask/app.py", line 870, in full_dispatch_request rv = self.dispatch_request() File "/home/dirk/.local/lib/python3.10/site-packages/flask/app.py", line 855, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] File "/home/dirk/dev/gpt_newspaper/gpt-newspaper/backend/server.py", line 14, in generate_newspaper newspaper = master_agent.run(data["topics"], data["layout"]) File "/home/dirk/dev/gpt_newspaper/gpt-newspaper/backend/langgraph_agent.py", line 52, in run parallel_results = list(executor.map(lambda q: chain.invoke({"query": q}), queries)) File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator yield _result_or_cancel(fs.pop()) File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel return fut.result(timeout) File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result return self.__get_result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result raise self._exception File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/home/dirk/dev/gpt_newspaper/gpt-newspaper/backend/langgraph_agent.py", line 52, in <lambda> parallel_results = list(executor.map(lambda q: chain.invoke({"query": q}), queries)) File "/home/dirk/.local/lib/python3.10/site-packages/langgraph/pregel/__init__.py", line 569, in invoke for chunk in self.stream( File "/home/dirk/.local/lib/python3.10/site-packages/langgraph/pregel/__init__.py", line 605, in transform for chunk in self._transform_stream_with_config( File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 1497, in _transform_stream_with_config chunk: Output = context.run(next, iterator) # type: ignore File "/home/dirk/.local/lib/python3.10/site-packages/langgraph/pregel/__init__.py", line 347, in _transform _interrupt_or_proceed(done, inflight, step) File "/home/dirk/.local/lib/python3.10/site-packages/langgraph/pregel/__init__.py", line 688, in _interrupt_or_proceed raise exc File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3887, in invoke return self.bound.invoke( File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 2053, in invoke input = step.invoke( File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3353, in invoke return self._call_with_config( File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 1246, in _call_with_config context.run( File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/config.py", line 326, in call_func_with_variable_args return func(input, **kwargs) # type: ignore[call-arg] File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3229, in _invoke output = call_func_with_variable_args( File "/home/dirk/.local/lib/python3.10/site-packages/langchain_core/runnables/config.py", line 326, in call_func_with_variable_args return func(input, **kwargs) # type: ignore[call-arg] File "/home/dirk/dev/gpt_newspaper/gpt-newspaper/backend/agents/search.py", line 21, in run res = self.search_tavily(article["query"]) File "/home/dirk/dev/gpt_newspaper/gpt-newspaper/backend/agents/search.py", line 12, in search_tavily results = tavily_client.search(query=query, topic="news", max_results=10, include_images=True) File "/home/dirk/.local/lib/python3.10/site-packages/tavily/tavily.py", line 48, in search return self._search(query, search_depth=search_depth, **kwargs) File "/home/dirk/.local/lib/python3.10/site-packages/tavily/tavily.py", line 42, in _search response.raise_for_status() # Raises a HTTPError if the HTTP request returned an unsuccessful status code File "/home/dirk/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.tavily.com/search 127.0.0.1 - - [27/Jan/2024 08:58:17] "POST /generate_newspaper HTTP/1.1" 500 -