assafelovic / gpt-researcher

LLM based autonomous agent that conducts local and web research on any topic and generates a comprehensive report with citations.
https://gptr.dev
Apache License 2.0
14.95k stars 2k forks source link

ERROR: Exception in ASGI application #68

Closed gH2AX closed 1 year ago

gH2AX commented 1 year ago

Due to the latest changes I now get the above error on my MacBook Pro M1 with all the correct dependencies installed. It was working a week ago for me with the FastAPI installation.

gH2AX commented 1 year ago

Found the culprit. I happened in the following commit: f4d8beb76be80adffa551540524eab43a1e20ccf. Just revert it.

gH2AX commented 1 year ago

And the issue resurfaced. Let me share the traceback with you:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/uvicorn/protocols/websockets/wsproto_impl.py", line 234, in run_asgi
    result = await self.app(self.scope, self.receive, self.send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/fastapi/applications.py", line 289, in __call__
    await super().__call__(scope, receive, send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/starlette/middleware/errors.py", line 149, in __call__
    await self.app(scope, receive, send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/starlette/routing.py", line 341, in handle
    await self.app(scope, receive, send)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/starlette/routing.py", line 82, in app
    await func(session)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/site-packages/fastapi/routing.py", line 324, in app
    await dependant.call(**values)
  File "/Users/gH2AX/gpt-researcher/main.py", line 50, in websocket_endpoint
    await manager.start_streaming(task, report_type, agent, websocket)
  File "/Users/gH2AX/gpt-researcher/agent/run.py", line 38, in start_streaming
    report, path = await run_agent(task, report_type, agent, websocket)
  File "/Users/gH2AX/gpt-researcher/agent/run.py", line 50, in run_agent
    await assistant.conduct_research()
  File "/Users/gH2AX/gpt-researcher/agent/research_agent.py", line 137, in conduct_research
    search_queries = await self.create_search_queries()
  File "/Users/gH2AX/gpt-researcher/agent/research_agent.py", line 92, in create_search_queries
    return json.loads(result)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/gpt-researcher/lib/python3.10/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 51)
Drawwork commented 1 year ago

the same problem. plz share it for me after you fix it

polygonfuture commented 1 year ago

Worked two times and then this starting occuring for me as well using docker container.

rotemweiss57 commented 1 year ago

Thank you, will take a look at it. I will update you soon

paradoxtown commented 1 year ago

the same problem. plz share it for me after you fix it

temporary solution: research_agent.py line 92: return json.loads(result) if type(result) != str else result.strip("[]").replace('"', '').split("] [")

image

darrenmarshall commented 1 year ago

the same problem. plz share it for me after you fix it

temporary solution: research_agent.py line 92: return json.loads(result) if type(result) != str else result.strip("[]").replace('"', '').split("] [")

image

Unfortunately adding this line in the latest build didn't correct the issue for me.

paradoxtown commented 1 year ago

the same problem. plz share it for me after you fix it

temporary solution: research_agent.py line 92: return json.loads(result) if type(result) != str else result.strip("[]").replace('"', '').split("] [") image

Unfortunately adding this line in the latest build didn't correct the issue for me.

This is because the response from chatgpt cannot follow the format strictly. Most error cases can be solved by the above temporary solution. And I am waiting for the official solution as well.