Open AndreaDiTrani opened 5 months ago
I have the exact same issue. Based on the logs, it seems it's linked to the retry function. Also, in the meantime mistralai lib has been updated to 1.0.2 which is not retro-compatible with instructor.
Thanks for the good work!
Traceback (most recent call last): [personal code and folders are redacted] File ".py", line 94, in extract return self.client.messages.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/instructor/client.py", line 93, in create return self.create_fn( ^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/openinference/instrumentation/instructor/_wrappers.py", line 129, in patched_new_func resp = new_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/instructor/patch.py", line 143, in new_create_sync response = retry_sync( ^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/instructor/retry.py", line 162, in retry_sync for attempt in max_retries: File "/.venv/lib/python3.12/site-packages/tenacity/init.py", line 443, in iter do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/tenacity/init.py", line 376, in iter result = action(retry_state) ^^^^^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/tenacity/init.py", line 418, in exc_check raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/tenacity/init.py", line 185, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.get_result() ^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in get_result raise self._exception File "__/.venv/lib/python3.12/site-packages/instructor/retry.py", line 165, in retry_sync response = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/mistralai/client.py", line 223, in chat for response in single_response: File "__/.venv/lib/python3.12/site-packages/mistralai/client.py", line 148, in _request yield self._check_response(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.venv/lib/python3.12/site-packages/mistralai/client.py", line 77, in _check_response self._check_response_status_codes(response) File "/.venv/lib/python3.12/site-packages/mistralai/client.py", line 62, in _check_response_status_codes raise MistralAPIException.from_response( mistralai.exceptions.MistralAPIException: Status: 400. Message: {"object":"error","message":"Not the same number of function calls and responses","type":"invalid_request_error","param":null,"code":null}
What Model are you using?
Describe the bug I have some documents regarding electrical components and i am trying to extract the relevant features from them. On some samples of those documents everything works fine but on some of them it fails with the following exception:
MistralAPIException: Status: 400. Message: {"object":"error","message":"Not the same number of function calls and responses","type":"invalid_request_error","param":null,"code":null}
To Reproduce The pydantic structure i am using is the following:
and this is the function i'm calling to extract the features
Expected behavior The expected behavior is something similar to what happens with "sane" text samples:
If needed i can provide the prompts i'm using and also the text i'm trying to extract
Screenshots If applicable, add screenshots to help explain your problem.