Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Json parsing issue when using openai.Completion.acreate(stream=True) #184

Closed
@nfcampos

Description

@nfcampos

See the last line, looks like the stream iterator might be breaking up parts where it shouldn't? Unless it's an API issue. cc @ddeville

Traceback (most recent call last):
  File "/Users/nuno/Library/Caches/pypoetry/virtualenvs/platform-api-30l3Kv3P-py3.10/lib/python3.10/site-packages/openai/api_requestor.py", line 670, in _interpret_response_line
    data = json.loads(rbody)
  File "/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 191 (char 190)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/nuno/dev/concat/server-py/concat/conversation.py", line 87, in handle_conversation
    await run
  File "/Users/nuno/dev/concat/server-py/concat/agent/openai/openai.py", line 122, in __call__
    msg, _ = await asyncio.gather(
  File "/Users/nuno/dev/concat/server-py/concat/tools/multi_prompt.py", line 87, in __call__
    return await self.call(prompt["prompt"], examples, input, ctx)
  File "/Users/nuno/dev/concat/server-py/concat/tools/sql/__init__.py", line 59, in call
    async for key, msg in ctx.stream_multi_message_async(
  File "/Users/nuno/dev/concat/server-py/concat/context/context.py", line 419, in stream_multi_message_async
    async for text in iterator:
  File "/Users/nuno/dev/concat/server-py/concat/utils/openai.py", line 37, in openai_completion_stream
    async for chunk in cast(
  File "/Users/nuno/Library/Caches/pypoetry/virtualenvs/platform-api-30l3Kv3P-py3.10/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 230, in <genexpr>
    return (
  File "/Users/nuno/Library/Caches/pypoetry/virtualenvs/platform-api-30l3Kv3P-py3.10/lib/python3.10/site-packages/openai/api_requestor.py", line 320, in wrap_resp
    async for r in resp:
  File "/Users/nuno/Library/Caches/pypoetry/virtualenvs/platform-api-30l3Kv3P-py3.10/lib/python3.10/site-packages/openai/api_requestor.py", line 635, in <genexpr>
    self._interpret_response_line(
  File "/Users/nuno/Library/Caches/pypoetry/virtualenvs/platform-api-30l3Kv3P-py3.10/lib/python3.10/site-packages/openai/api_requestor.py", line 672, in _interpret_response_line
    raise error.APIError(
openai.error.APIError: HTTP code 200 from API ({"id": "cmpl-6YxjgLI6W6XwRj8hqhDZ6aCFz19Hp", "object": "text_completion", "created": 1673790796, "choices": [{"text": "sche", "index": 0, "logprobs": null, "finish_reason": null}], "model": ")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions