Skip to content

Commit b1e0d0f

Browse files
fix(chat): skip temperature sending when such feature is disabled (Issue #6449) (#6460)
1 parent 5c1d683 commit b1e0d0f

6 files changed

Lines changed: 1071 additions & 355 deletions

File tree

.trivyignore

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
1+
12
# node:24-alpine vulnerabilities in https://hub.docker.com/layers/library/node/24-alpine
2-
CVE-2026-22184 exp:2026-05-20
3+
4+
# zlib
5+
CVE-2026-22184 exp:2026-05-20
6+
7+
# tar
8+
CVE-2026-31802 exp:2026-05-20
9+
CVE-2026-29786 exp:2026-05-20
10+
CVE-2026-26960 exp:2026-05-20
11+
12+
# minimatch
13+
CVE-2026-26996 exp:2026-05-20
14+
CVE-2026-27903 exp:2026-05-20
15+
CVE-2026-27904 exp:2026-05-20
16+
17+
# picomatch
18+
CVE-2026-33671 exp:2026-05-20
19+
20+
# libcrypto3 libssl3
21+
CVE-2026-28390 exp:2026-05-20
22+
23+
# musl musl-utils
24+
CVE-2026-40200 exp:2026-05-20

apps/chat/src/pages/api/chat.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ import { ChatBody } from '@/src/types/chat';
2323
import { EntityType } from '@/src/types/common';
2424

2525
import { DEFAULT_SYSTEM_PROMPT } from '@/src/constants/default-server-settings';
26-
import {
27-
DEFAULT_TEMPERATURE,
28-
FALLBACK_TEMPERATURE,
29-
} from '@/src/constants/default-ui-settings';
26+
import { DEFAULT_TEMPERATURE } from '@/src/constants/default-ui-settings';
3027
import { errorsMessages } from '@/src/constants/errors';
3128

3229
import { authOptions } from './auth/[...nextauth]';
@@ -65,9 +62,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
6562
}
6663

6764
let temperatureToUse = temperature;
68-
if (!doesModelAllowTemperature(model)) {
69-
temperatureToUse = FALLBACK_TEMPERATURE;
70-
} else if (
65+
if (
66+
doesModelAllowTemperature(model) &&
7167
!temperatureToUse &&
7268
temperatureToUse !== 0 &&
7369
model.type !== EntityType.Application
@@ -111,7 +107,6 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
111107

112108
const stream = await OpenAIStream({
113109
model,
114-
temperature: temperatureToUse,
115110
messages: messagesToSend,
116111
userJWT: token?.access_token as string,
117112
chatReference: reference ?? id,
@@ -120,6 +115,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
120115
? limits?.maxRequestTokens
121116
: undefined,
122117
configurationSchemaValue: configurationValue,
118+
...(temperatureToUse !== undefined && { temperature: temperatureToUse }),
123119
});
124120
res.setHeader('Transfer-Encoding', 'chunked');
125121

apps/chat/src/store/conversations/conversations.epics.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ import { LOCAL_BUCKET } from '@/src/constants/chat';
119119
import {
120120
DEFAULT_CONVERSATION_NAME,
121121
DEFAULT_TEMPERATURE,
122-
FALLBACK_TEMPERATURE,
123122
} from '@/src/constants/default-ui-settings';
124123
import { errorsMessages } from '@/src/constants/errors';
125124
import { DEFAULT_EXTERNAL_APPS_SCHEMA_ID } from '@/src/constants/external-apps';
@@ -1496,17 +1495,18 @@ const streamMessageEpic: AppEpic = (action$, state$) =>
14961495
const modelsMap = ModelsSelectors.selectModelsMap(state$.value);
14971496
const lastModel = modelsMap[payload.conversation.model.id];
14981497
const conversationModelType = lastModel?.type ?? EntityType.Model;
1499-
let modelAdditionalSettings = {};
1498+
const modelAdditionalSettings: Partial<
1499+
Pick<ChatBody, 'prompt' | 'temperature'>
1500+
> = {};
15001501

15011502
if (conversationModelType === EntityType.Model) {
1502-
modelAdditionalSettings = {
1503-
prompt: doesModelAllowSystemPrompt(lastModel)
1504-
? payload.conversation.prompt
1505-
: undefined,
1506-
temperature: doesModelAllowTemperature(lastModel)
1507-
? payload.conversation.temperature
1508-
: FALLBACK_TEMPERATURE,
1509-
};
1503+
if (doesModelAllowSystemPrompt(lastModel)) {
1504+
modelAdditionalSettings.prompt = payload.conversation.prompt;
1505+
}
1506+
if (doesModelAllowTemperature(lastModel)) {
1507+
modelAdditionalSettings.temperature =
1508+
payload.conversation.temperature;
1509+
}
15101510
}
15111511

15121512
const chatBody: ChatBody = {

apps/chat/src/utils/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ export const OpenAIStream = async ({
6363
configurationSchemaValue,
6464
}: {
6565
model: DialAIEntityModel;
66-
temperature: number | undefined;
6766
messages: Message[];
6867
userJWT: string;
6968
chatReference: string;
7069
jobTitle: string | undefined;
7170
maxRequestTokens: number | undefined;
7271
configurationSchemaValue?: MessageFormValue;
72+
temperature?: number;
7373
}) => {
7474
let messagesToSend = messages;
7575
const url = getUrl(model);

0 commit comments

Comments
 (0)