Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 build: support to ignore \n with XXX_MODEL_LIST env #4660

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/utils/__snapshots__/parseModels.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ exports[`parseModelString > duplicate naming model 1`] = `
}
`;

exports[`parseModelString > empty string model 1`] = `
{
"add": [
{
"displayName": "gpt-4-turbo",
"id": "gpt-4-1106-preview",
},
{
"displayName": undefined,
"id": "claude-2",
},
],
"removeAll": false,
"removed": [],
}
`;

exports[`parseModelString > only add the model 1`] = `
{
"add": [
Expand Down
5 changes: 5 additions & 0 deletions src/utils/parseModels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ describe('parseModelString', () => {
expect(result).toMatchSnapshot();
});

it('empty string model', () => {
const result = parseModelString('gpt-4-1106-preview=gpt-4-turbo,, ,\n ,+claude-2');
expect(result).toMatchSnapshot();
});

describe('extension capabilities', () => {
it('with token', () => {
const result = parseModelString('chatglm-6b=ChatGLM 6B<4096>');
Expand Down
5 changes: 5 additions & 0 deletions src/utils/parseModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export const parseModelString = (modelString: string = '', withDeploymentName =
continue;
}

// remove empty model name
if (!item.trim().length) {
continue;
}

// Remove duplicate model entries.
const existingIndex = models.findIndex(({ id: n }) => n === id);
if (existingIndex !== -1) {
Expand Down
Loading