Skip to content

Commit 41ba873

Browse files
author
Kerwin
committed
fix: the specified model is invalid
1 parent 30c77e7 commit 41ba873

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

service/src/chatgpt/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ async function randomKeyConfig(keys: KeyConfig[]): Promise < KeyConfig | null >
326326
return thisKey
327327
}
328328

329-
async function getRandomApiKey(user: UserInfo): Promise<KeyConfig | undefined> {
329+
async function getRandomApiKey(user: UserInfo, chatModel: CHATMODEL): Promise<KeyConfig | undefined> {
330330
const keys = (await getCacheApiKeys()).filter(d => hasAnyRole(d.userRoles, user.roles))
331-
return randomKeyConfig(keys)
331+
return randomKeyConfig(keys.filter(d => d.chatModels.includes(chatModel)))
332332
}
333333

334334
async function releaseApiKey(key: KeyConfig) {

service/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
430430
temperature,
431431
top_p,
432432
chatModel: user.config.chatModel,
433-
key: await getRandomApiKey(user),
433+
key: await getRandomApiKey(user, user.config.chatModel),
434434
})
435435
// return the whole response including usage
436436
res.write(`\n${JSON.stringify(result.data)}`)

0 commit comments

Comments
 (0)