Skip to content

fix(cli/chat): only send params when set #2077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/openai/cli/_api/chat/completions.py
Original file line number Diff line number Diff line change
@@ -100,13 +100,17 @@ def create(args: CLIChatCompletionCreateArgs) -> None:
"messages": [
{"role": cast(Literal["user"], message.role), "content": message.content} for message in args.message
],
"n": args.n,
"temperature": args.temperature,
"top_p": args.top_p,
"stop": args.stop,
# type checkers are not good at inferring union types so we have to set stream afterwards
"stream": False,
}
if args.temperature is not None:
params['temperature'] = args.temperature
if args.stop is not None:
params['stop'] = args.stop
if args.top_p is not None:
params['top_p'] = args.top_p
if args.n is not None:
params['n'] = args.n
if args.stream:
params["stream"] = args.stream # type: ignore
if args.max_tokens is not None: