移除空格,增加custom_models 容错性

This commit is contained in:
Q.A.zh 2024-12-30 02:54:15 +00:00 committed by GitHub
parent 3b5b496599
commit 69fcb92a3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -76,6 +76,7 @@ export function collectModelTable(
// server custom models // server custom models
customModels customModels
.split(",") .split(",")
.map((v) => v.trim())
.filter((v) => !!v && v.length > 0) .filter((v) => !!v && v.length > 0)
.forEach((m) => { .forEach((m) => {
const available = !m.startsWith("-"); const available = !m.startsWith("-");

View File

@ -127,7 +127,7 @@ describe('collectModelTable', () => {
}); });
test('All models except OpenAI should be excluded, and additional models should be added when customized as "-all, +*openai,gpt-4o@azure"', () => { test('All models except OpenAI should be excluded, and additional models should be added when customized as "-all, +*openai,gpt-4o@azure"', () => {
const customModels = '-all, +*openai,gpt-4o@azure'; const customModels = '-all,+*openai,gpt-4o@azure';
const result = collectModelTable(mockModels, customModels); const result = collectModelTable(mockModels, customModels);
expect(result['gpt-3.5-turbo@openai'].available).toBe(true); expect(result['gpt-3.5-turbo@openai'].available).toBe(true);