From 297d0b52612e8f997e922670f3bb6e522d784645 Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Mon, 3 Feb 2025 11:52:46 +0000 Subject: [PATCH] fix(cli/chat): only send params when set --- src/openai/cli/_api/chat/completions.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/openai/cli/_api/chat/completions.py b/src/openai/cli/_api/chat/completions.py index c299741fe0..feedb5ccab 100644 --- a/src/openai/cli/_api/chat/completions.py +++ b/src/openai/cli/_api/chat/completions.py @@ -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: