From ef39a3b8e4ed0b5741b241eb907780dcfd22a4a2 Mon Sep 17 00:00:00 2001 From: Ilya Bondar Date: Fri, 16 Feb 2024 15:18:57 +0100 Subject: [PATCH] fix(chat): fix applying temperature (Issue #588) --- src/constants/default-settings.ts | 2 +- src/pages/api/chat.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/constants/default-settings.ts b/src/constants/default-settings.ts index b90934fb51..ec47d8f1a7 100644 --- a/src/constants/default-settings.ts +++ b/src/constants/default-settings.ts @@ -6,7 +6,7 @@ export const DEFAULT_SYSTEM_PROMPT = export const DIAL_API_HOST = process.env.DIAL_API_HOST; export const DEFAULT_TEMPERATURE = parseFloat( - process.env.NEXT_PUBLIC_DEFAULT_TEMPERATURE || '1', + process.env.NEXT_PUBLIC_DEFAULT_TEMPERATURE ?? '1', ); export const DEFAULT_CONVERSATION_NAME = 'New conversation'; diff --git a/src/pages/api/chat.ts b/src/pages/api/chat.ts index 36c06eaeb1..b8ebade737 100644 --- a/src/pages/api/chat.ts +++ b/src/pages/api/chat.ts @@ -141,7 +141,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { } let temperatureToUse = temperature; - if (temperatureToUse && model.type !== EntityType.Application) { + if (!temperatureToUse + && temperatureToUse !== 0 + && model.type !== EntityType.Application) { temperatureToUse = DEFAULT_TEMPERATURE; }