Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 688b223

Browse files
authoredFeb 3, 2025
fix(cli/chat): only send params when set (#2077)
1 parent 7a6517d commit 688b223

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎src/openai/cli/_api/chat/completions.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,17 @@ def create(args: CLIChatCompletionCreateArgs) -> None:
100100
"messages": [
101101
{"role": cast(Literal["user"], message.role), "content": message.content} for message in args.message
102102
],
103-
"n": args.n,
104-
"temperature": args.temperature,
105-
"top_p": args.top_p,
106-
"stop": args.stop,
107103
# type checkers are not good at inferring union types so we have to set stream afterwards
108104
"stream": False,
109105
}
106+
if args.temperature is not None:
107+
params['temperature'] = args.temperature
108+
if args.stop is not None:
109+
params['stop'] = args.stop
110+
if args.top_p is not None:
111+
params['top_p'] = args.top_p
112+
if args.n is not None:
113+
params['n'] = args.n
110114
if args.stream:
111115
params["stream"] = args.stream # type: ignore
112116
if args.max_tokens is not None:

0 commit comments

Comments
 (0)
Please sign in to comment.