Skip to content

openai cli --stream error #402

@oiuv

Description

@oiuv

Describe the bug

image

When adding the --stream parameter to the OpenAI command, an error occurred.

To Reproduce

When adding the --stream parameter to the OpenAI command, an error occurred.

> openai api chat_completions.create -m gpt-3.5-turbo -g user "Hello" --stream
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Scripts\openai.exe\__main__.py", line 7, in <module>
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\openai\_openai_scripts.py", line 70, in main
    args.func(args)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\openai\cli.py", line 144, in create
    sys.stdout.write(c["message"]["content"])
KeyError: 'message'

Code snippets

No response

OS

Windows

Python version

Python v3.10.6

Library version

openai v0.27.4

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixed in v1Issues addressed by the v1 beta

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions