Skip to content

Commit d3debcc

Browse files
committed
fix: Wrong model name given to ai api call when using prompt with model
1 parent bef6d4d commit d3debcc

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

src/client/components/ChatV2/ChatV2.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ const ChatV2Content = () => {
157157
const { usage, limit } = userStatus
158158
const tokenUsageExceeded = usage >= limit
159159

160-
if (tokenUsageExceeded && activeModel !== FREE_MODEL) {
160+
const acualModel = (promptInfo.type === 'saved' ? promptInfo.model : null) ?? activeModel
161+
162+
if (tokenUsageExceeded && acualModel !== FREE_MODEL) {
161163
enqueueSnackbar(t('chat:errorInstructions'), { variant: 'error' })
162164
handleCancel()
163165
return
@@ -191,7 +193,7 @@ const ChatV2Content = () => {
191193
chatScroll.beginAutoscroll()
192194

193195
const generationInfo: MessageGenerationInfo = {
194-
model: activeModel,
196+
model: acualModel,
195197
promptInfo,
196198
}
197199

src/client/components/Rag/Chunk.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/shared/chat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import z from 'zod/v4'
22
import type { ChatToolDef } from './tools'
3-
import { validModels } from '../config'
3+
import { ValidModelNameSchema, validModels } from '../config'
44

55
/**
66
* Event emitted when text is added to a chat message
@@ -65,7 +65,7 @@ export const MessageGenerationInfoSchema = z.object({
6565
id: z.string(),
6666
name: z.string(),
6767
systemMessage: z.string().optional(),
68-
model: z.string().optional().nullable(),
68+
model: ValidModelNameSchema.optional().nullable(),
6969
temperature: z.number().min(0).max(1).optional().nullable(),
7070
}),
7171
z.object({

0 commit comments

Comments
 (0)