assafelovic / gpt-researcher

LLM based autonomous agent that does online comprehensive research on any given topic
https://gptr.dev
Apache License 2.0
14.08k stars 1.82k forks source link

UnicodeEncodeError #732

Open will-deeplearn opened 1 month ago

will-deeplearn commented 1 month ago

It's my first time to run the project and after I entered the question and clicked "Research", the agent output showed " 🤔 Thinking about research questions for the task..." and had the following errors.

INFO: 127.0.0.1:58668 - "GET / HTTP/1.1" 200 OK INFO: 127.0.0.1:58668 - "GET /site/styles.css HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:58669 - "GET /static/gptr-logo.png HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:58668 - "GET /site/scripts.js HTTP/1.1" 304 Not Modified INFO: 127.0.0.1:58668 - "GET /static/favicon.ico HTTP/1.1" 304 Not Modified INFO: ('127.0.0.1', 58673) - "WebSocket /ws" [accepted] INFO: connection open ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\jianxing\anaconda3\Lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 244, in run_asgi result = await self.app(self.scope, self.asgi_receive, self.asgi_send) # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jianxing\anaconda3\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 70, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jianxing\anaconda3\Lib\site-packages\fastapi\applications.py", line 1054, in call await super().call(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\applications.py", line 123, in call await self.middleware_stack(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\middleware\errors.py", line 151, in call await self.app(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\middleware\cors.py", line 77, in call await self.app(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\middleware\exceptions.py", line 65, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app raise exc File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 756, in call await self.middleware_stack(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 776, in app await route.handle(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 373, in handle await self.app(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 96, in app await wrap_app_handling_exceptions(app, session)(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app raise exc File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 94, in app await func(session) File "C:\Users\jianxing\anaconda3\Lib\site-packages\fastapi\routing.py", line 348, in app await dependant.call(values) File "E:\gpt-researcher\backend\server.py", line 89, in websocket_endpoint report = await manager.start_streaming( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\gpt-researcher\backend\websocket_manager.py", line 60, in start_streaming report = await run_agent(task, report_type, report_source, source_urls, tone, websocket, headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\gpt-researcher\backend\websocket_manager.py", line 97, in run_agent report = await researcher.run() ^^^^^^^^^^^^^^^^^^^^^^ File "E:\gpt-researcher\backend\report_type\basic_report\basic_report.py", line 41, in run await researcher.conduct_research() File "E:\gpt-researcher\gpt_researcher\master\agent.py", line 103, in conduct_research await stream_output( File "E:\gpt-researcher\gpt_researcher\master\actions.py", line 463, in stream_output print(output) UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f50e' in position 0: illegal multibyte sequence INFO: connection closed INFO: ('127.0.0.1', 58675) - "WebSocket /ws" [accepted] INFO: connection open ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\jianxing\anaconda3\Lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 244, in run_asgi result = await self.app(self.scope, self.asgi_receive, self.asgi_send) # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jianxing\anaconda3\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 70, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\jianxing\anaconda3\Lib\site-packages\fastapi\applications.py", line 1054, in call await super().call(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\applications.py", line 123, in call await self.middleware_stack(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\middleware\errors.py", line 151, in call await self.app(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\middleware\cors.py", line 77, in call await self.app(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\middleware\exceptions.py", line 65, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app raise exc File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 756, in call await self.middleware_stack(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 776, in app await route.handle(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 373, in handle await self.app(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 96, in app await wrap_app_handling_exceptions(app, session)(scope, receive, send) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 64, in wrapped_app raise exc File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "C:\Users\jianxing\anaconda3\Lib\site-packages\starlette\routing.py", line 94, in app await func(session) File "C:\Users\jianxing\anaconda3\Lib\site-packages\fastapi\routing.py", line 348, in app await dependant.call(values) File "E:\gpt-researcher\backend\server.py", line 89, in websocket_endpoint report = await manager.start_streaming( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\gpt-researcher\backend\websocket_manager.py", line 60, in start_streaming report = await run_agent(task, report_type, report_source, source_urls, tone, websocket, headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\gpt-researcher\backend\websocket_manager.py", line 97, in run_agent report = await researcher.run() ^^^^^^^^^^^^^^^^^^^^^^ File "E:\gpt-researcher\backend\report_type\basic_report\basic_report.py", line 41, in run await researcher.conduct_research() File "E:\gpt-researcher\gpt_researcher\master\agent.py", line 103, in conduct_research await stream_output( File "E:\gpt-researcher\gpt_researcher\master\actions.py", line 463, in stream_output print(output) UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f50e' in position 0: illegal multibyte sequence INFO: connection closed

assafelovic commented 1 month ago

Hey @kitty-elephant can you share what was your initial research query?

will-deeplearn commented 1 month ago

Hey @kitty-elephant can you share what was your initial research query?

At first I used Chinese to query, and then I restarted the project and tried English like "Is the cryptocurrency market suitable for adding positions now?". Both of them have the above problems.

afern247 commented 1 month ago

I can confirm, my first try as well and getting the same error @assafelovic

ElishaKay commented 1 month ago

Welcome @kitty-elephant @afern247

I had a similar issue yesterday and we pushed up a fix here in actions.py

Both cases are UnicodeEncodeError instances, occurring when trying to print Unicode characters that can't be encoded using the default character encoding of the console.

The recommended fix & path of least resistance for OS-specific issues is to run via Docker (even if you've never used it before)

Try this flow

Feel free to give it a shot and let us know if the issue persists