You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I want to upload an image from local path, that error exists
code: client = PoeApi(cookie=tokens) bot = "claude_2_1_bamboo" local_paths = ["/research/d1/rshr/jwfu/tmp/1661501360757.0_left.jpg"] for chunk in client.send_message(bot, "What is this file about?", file_path=local_paths): print(chunk["response"], end="", flush=True)
error: Traceback (most recent call last): File "test_poe_api.py", line 38, in <module> for chunk in client.send_message(bot, "What is this file about?", file_path=local_paths): File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/poe_api_wrapper/api.py", line 843, in send_message raise e File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/poe_api_wrapper/api.py", line 810, in send_message message_data = self.send_request(apiPath, 'SendMessageMutation', variables, file_form) File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/poe_api_wrapper/api.py", line 222, in send_request payload = MultipartEncoder( File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 125, in __init__ self._prepare_parts() File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 246, in _prepare_parts self.parts = [Part.from_field(f, enc) for f in self._iter_fields()] File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 246, in <listcomp> self.parts = [Part.from_field(f, enc) for f in self._iter_fields()] File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 495, in from_field return cls(headers, body) File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 488, in __init__ self.len = len(self.headers) + total_len(self.body) File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 432, in total_len if hasattr(o, 'len'): File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 573, in len return total_len(self.fd) - self.fd.tell() File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 437, in total_len fileno = o.fileno() ValueError: I/O operation on closed file
Thanks for your help
The text was updated successfully, but these errors were encountered:
the file has closed after post request int the functionsend_request, then the send_message will call send_requestagain. Close the same file loads to occur a exception.
I confirm that this problem occurred after updating to 1.4.0
I have the exact same codebase on 2 different laptops and after updating poe-api-wrapper from 1.3.7 to 1.4.0, this error started to appear.
As mentioned by OP, it occurs when uploading a file.
It still works on version 1.3.7, so I assume its not caused by their API or any change made in the back-end.
In my usage scenario, setting msgPrice=*correct msgPrice* can solve this problem.
This is because when it is detected that msgPrice does not match the actual situation, send_request will be sent again.
I guess that after the first send, the file is closed; so simply directly set the correct msgPrice.
Since I have other more urgent things right now, I don't have time to fix this problem; if I have time in the future, I will dig in and fix this problem. If anyone else is interested in this problem, you can try reading this Code snippet if message_data["data"] != .....
By the way, sorry for my bad English.
When I want to upload an image from local path, that error exists
code:
client = PoeApi(cookie=tokens) bot = "claude_2_1_bamboo" local_paths = ["/research/d1/rshr/jwfu/tmp/1661501360757.0_left.jpg"] for chunk in client.send_message(bot, "What is this file about?", file_path=local_paths): print(chunk["response"], end="", flush=True)
error:
Traceback (most recent call last): File "test_poe_api.py", line 38, in <module> for chunk in client.send_message(bot, "What is this file about?", file_path=local_paths): File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/poe_api_wrapper/api.py", line 843, in send_message raise e File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/poe_api_wrapper/api.py", line 810, in send_message message_data = self.send_request(apiPath, 'SendMessageMutation', variables, file_form) File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/poe_api_wrapper/api.py", line 222, in send_request payload = MultipartEncoder( File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 125, in __init__ self._prepare_parts() File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 246, in _prepare_parts self.parts = [Part.from_field(f, enc) for f in self._iter_fields()] File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 246, in <listcomp> self.parts = [Part.from_field(f, enc) for f in self._iter_fields()] File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 495, in from_field return cls(headers, body) File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 488, in __init__ self.len = len(self.headers) + total_len(self.body) File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 432, in total_len if hasattr(o, 'len'): File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 573, in len return total_len(self.fd) - self.fd.tell() File "/research/d1/rshr/jwfu/anaconda3/envs/tmp/lib/python3.8/site-packages/requests_toolbelt/multipart/encoder.py", line 437, in total_len fileno = o.fileno() ValueError: I/O operation on closed file
Thanks for your help
The text was updated successfully, but these errors were encountered: