Closed deronkel82 closed 1 year ago
UPDATE: I have fixed it with the help of ChatGPT. In the running_recorder.py file every line with "with open...." needs to be updated like this:
with open(os.path.join(self.record_root_dir, f"query.json"), "w", encoding='utf-8') as writer:
before it looked like this:
with open(os.path.join(self.record_root_dir, f"query.json"), "w"') as writer:
Great! Could you please submit a pull request?
Done i think.. I´m not very experienced using github.
We've adopt your solution, thanks a lot!
The following error occurs. The task was to develop the game tetris in python using the pygame engine.
NEXT ACTION: COMMAND: shell_command_executor ARGUMENTS: {'command': 'pip install pygame'} Traceback (most recent call last): File "I:\KI\XAgent\XAgentServer\server.py", line 104, in interact await task_handler.outer_loop_async() File "I:\KI\XAgent\XAgent\workflow\task_handler.py", line 146, in outer_loop_async search_method = await self.inner_loop_async(self.now_dealing_task) File "I:\KI\XAgent\XAgent\workflow\task_handler.py", line 292, in inner_loop_async await search_method.run_async(config=self.config, File "I:\KI\XAgent\XAgent\inner_loop_search_algorithms\ReACT.py", line 64, in run_async await self.generate_chain_async(config, agent, task_handler, function_list, tool_functions_description_list, task_id) File "I:\KI\XAgent\XAgent\inner_loop_search_algorithms\ReACT.py", line 328, in generate_chain_async tool_output, tool_output_status_code, need_for_plan_refine, using_tools = function_handler.handle_tool_call( File "I:\KI\XAgent\XAgent\tool_call_handle.py", line 360, in handle_tool_call command_result, tool_output_status_code, = toolserver_interface.execute_command_client( File "I:\KI\XAgent\XAgent\tool_call_handle.py", line 240, in execute_command_client recorder.regist_tool_server(url=url, File "I:\KI\XAgent\XAgent\running_recorder.py", line 135, in regist_tool_server json.dump(tool_record, writer, indent=2, ensure_ascii=False) File "C:\Users\heins\miniconda3\envs\vicuna\lib\json__init__.py", line 180, in dump fp.write(chunk) File "C:\Users\heins\miniconda3\envs\vicuna\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 305-344: character maps to
Disconnect with client 78f0a4d1-c992-4739-b219-9c76138f8c3b: websocket 78f0a4d1-c992-4739-b219-9c76138f8c3b remove from active connections ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 254, in run_asgi result = await self.app(self.scope, self.asgi_receive, self.asgi_send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in call return await self.app(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\fastapi\applications.py", line 276, in call await super().call(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\middleware\errors.py", line 149, in call await self.app(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\middleware\cors.py", line 76, in call await self.app(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\middleware\base.py", line 26, in call await self.app(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call raise e File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\routing.py", line 718, in call await route.handle(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\routing.py", line 341, in handle await self.app(scope, receive, send) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\endpoints.py", line 89, in dispatch raise exc File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\starlette\endpoints.py", line 81, in dispatch await self.on_receive(websocket, data) File "I:\KI\XAgent\app.py", line 628, in on_receive await asyncio.create_task(self.do_running_long_task(parameter)) File "I:\KI\XAgent\app.py", line 688, in do_running_long_task await task File "I:\KI\XAgent\XAgentServer\server.py", line 107, in interact raise e File "I:\KI\XAgent\XAgentServer\server.py", line 104, in interact await task_handler.outer_loop_async() File "I:\KI\XAgent\XAgent\workflow\task_handler.py", line 146, in outer_loop_async search_method = await self.inner_loop_async(self.now_dealing_task) File "I:\KI\XAgent\XAgent\workflow\task_handler.py", line 292, in inner_loop_async await search_method.run_async(config=self.config, File "I:\KI\XAgent\XAgent\inner_loop_search_algorithms\ReACT.py", line 64, in run_async await self.generate_chain_async(config, agent, task_handler, function_list, tool_functions_description_list, task_id) File "I:\KI\XAgent\XAgent\inner_loop_search_algorithms\ReACT.py", line 328, in generate_chain_async tool_output, tool_output_status_code, need_for_plan_refine, using_tools = function_handler.handle_tool_call( File "I:\KI\XAgent\XAgent\tool_call_handle.py", line 360, in handle_tool_call command_result, tool_output_status_code, = toolserver_interface.execute_command_client( File "I:\KI\XAgent\XAgent\tool_call_handle.py", line 240, in execute_command_client recorder.regist_tool_server(url=url, File "I:\KI\XAgent\XAgent\running_recorder.py", line 135, in regist_tool_server json.dump(tool_record, writer, indent=2, ensure_ascii=False) File "C:\Users\heins\miniconda3\envs\vicuna\lib\json__init__.py", line 180, in dump fp.write(chunk) File "C:\Users\heins\miniconda3\envs\vicuna\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 305-344: character maps to
ERROR: closing handshake failed
Traceback (most recent call last):
File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 959, in transfer_data
message = await self.read_message()
File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 1029, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 1104, in read_data_frame
frame = await self.read_frame(max_size)
File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 1161, in read_frame
frame = await Frame.read(
File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\framing.py", line 68, in read
data = await reader(2)
File "C:\Users\heins\miniconda3\envs\vicuna\lib\asyncio\streams.py", line 708, in readexactly
await self._wait_for_data('readexactly')
File "C:\Users\heins\miniconda3\envs\vicuna\lib\asyncio\streams.py", line 502, in _wait_for_data
await self._waiter
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\server.py", line 248, in handler await self.close() File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 766, in close await self.write_close_frame(Close(code, reason)) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 1232, in write_close_frame await self.write_frame(True, OP_CLOSE, data, _state=State.CLOSING) File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 1205, in write_frame await self.drain() File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 1194, in drain await self.ensure_open() File "C:\Users\heins\miniconda3\envs\vicuna\lib\site-packages\websockets\legacy\protocol.py", line 935, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedError: sent 1000 (OK); no close frame received
This is what ChatGPT has to say to the error:
The error UnicodeEncodeError: 'charmap' codec can't encode characters in position 305-344: character maps to indicates that Python tried to encode a Unicode character that is not defined in the current character map (charmap).
This error occurs when you try to write such a character to a file that was opened in a format that does not support this character. By default, Python uses the cp1252 character map on Windows, which does not include this character.
To fix the problem, you can open the file in UTF-8 format, which supports all Unicode characters. You can do this by adding the encoding='utf-8' parameter to the open function when you open the file. Here is an example:
In your specific case, the error seems to occur in the regist_tool_server function in the running_recorder.py file. You could try opening the file in this function in UTF-8 format to fix the problem.