From 232c07bf1fef2e234edd13e74a8bee51fcde57c9 Mon Sep 17 00:00:00 2001 From: Stefan Daniel Schwarz <52386626+StefanDanielSchwarz@users.noreply.github.com> Date: Thu, 18 Jan 2024 03:58:11 +0100 Subject: [PATCH] API: set do_sample=false when temperature=0 (#5275) --- extensions/openai/script.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/openai/script.py b/extensions/openai/script.py index e8647357..30f14c65 100644 --- a/extensions/openai/script.py +++ b/extensions/openai/script.py @@ -97,6 +97,9 @@ async def openai_completions(request: Request, request_data: CompletionRequest): path = request.url.path is_legacy = "/generate" in path + if request_data.temperature == 0: + request_data.do_sample = False + if request_data.stream: async def generator(): async with streaming_semaphore: @@ -120,6 +123,9 @@ async def openai_chat_completions(request: Request, request_data: ChatCompletion path = request.url.path is_legacy = "/generate" in path + if request_data.temperature == 0: + request_data.do_sample = False + if request_data.stream: async def generator(): async with streaming_semaphore: