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
Vectorized calls to OpenAI API are throwing an error.
Steps/code to reproduce the bug:
importoutlinesfrompydanticimportBaseModelclassModel(BaseModel):
name: strclassConfig:
extra="forbid"model=models.openai("gpt-4o-mini")
generator=outlines.generate.json(model, Model)
results=generator(["This is a first test", "This is a second test"]) # failsprint(len(results))
Expected result:
2
Error message:
Traceback (most recent call last):
File "/Users/xxx/Documents/Repos/xxx/main.py", line 183, in<module>
fire.Fire(DuneApp)
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/xxx-DgNc0zAM-py3.11/lib/python3.11/site-packages/fire/core.py", line 135, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/xxx-DgNc0zAM-py3.11/lib/python3.11/site-packages/fire/core.py", line 468, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/xxx-DgNc0zAM-py3.11/lib/python3.11/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Documents/Repos/xxx/main.py", line 76, intest
results = generator(["This is a first test", "This is a second test"]) # fails
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/xxx-DgNc0zAM-py3.11/lib/python3.11/site-packages/outlines/models/openai.py", line 151, in __call__
return self.format_sequence(response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/xxx-DgNc0zAM-py3.11/lib/python3.11/site-packages/outlines/generate/json.py", line 90, in<lambda>
format_sequence = lambda x: schema_object.parse_raw(x)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/xxx-DgNc0zAM-py3.11/lib/python3.11/site-packages/pydantic/main.py", line 1275, in parse_raw
raise pydantic_core.ValidationError.from_exception_data(cls.__name__, [error])
pydantic_core._pydantic_core.ValidationError: 1 validation error for Model
__root__
the JSON object must be str, bytes or bytearray, not ndarray [type=type_error, input_value=array(['{"name":"Test Suc...}'],
dtype='<U31'), input_type=ndarray]
Vectorized calls allow batching multiple prompts into a single API request, which is more cost-effective and faster than making multiple individual requests. Without working vectorized calls, users are forced to iterate through prompts sequentially, which increases API latency and usage costs.
The text was updated successfully, but these errors were encountered:
Describe the issue as clearly as possible:
Vectorized calls to OpenAI API are throwing an error.
Steps/code to reproduce the bug:
Expected result:
Error message:
Outlines/Python version information:
0.1.13
Python 3.11.11 (main, Dec 3 2024, 17:20:40) [Clang 16.0.0 (clang-1600.0.26.4)]
Context for the issue:
Vectorized calls allow batching multiple prompts into a single API request, which is more cost-effective and faster than making multiple individual requests. Without working vectorized calls, users are forced to iterate through prompts sequentially, which increases API latency and usage costs.
The text was updated successfully, but these errors were encountered: