Skip to content

Commit 79d27f2

Browse files
corbtCursor Bot
andauthored
Fix OpenAI temperature handling (#526)
* Fix OpenAI temperature handling * Simplify temperature default * Inline temperature default * Inline temperature default (one-line) * Fix type error in temperature handling Use walrus operator to properly narrow type from float | None to float, while still allowing temperature=0 and defaulting to 1.0 when None. --------- Co-authored-by: Cursor Bot <bot@cursor.com>
1 parent 1d46ca0 commit 79d27f2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/art/tinker/service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ async def chat_completions(
339339
max_tokens=body.get("max_completion_tokens")
340340
or body.get("max_tokens"),
341341
seed=body.get("seed"),
342-
temperature=body.get("temperature") or 1.0,
342+
temperature=t
343+
if (t := body.get("temperature")) is not None
344+
else 1.0,
343345
top_k=body.get("top_k") or -1,
344346
top_p=body.get("top_p") or 1.0,
345347
),

0 commit comments

Comments
 (0)