Skip to content

Commit

Permalink
✅ add OPENROUTER_CUSTOM_MODELS env var test case
Browse files Browse the repository at this point in the history
  • Loading branch information
danielglh committed Mar 25, 2024
1 parent e9ec4bc commit 19c2c4b
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,125 @@ exports[`modelProviderSelectors > CUSTOM_MODELS > should work correct with gpt-4
},
]
`;

exports[`modelProviderSelectors > OPENROUTER_CUSTOM_MODELS > custom deletion, addition, and renaming of models 1`] = `
[
{
"chatModels": [
{
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务",
"displayName": "GPT-3.5 Turbo",
"functionCall": true,
"id": "gpt-3.5-turbo",
"tokens": 16385,
},
{
"displayName": "GPT-3.5 Turbo (0125)",
"functionCall": true,
"hidden": true,
"id": "gpt-3.5-turbo-0125",
"tokens": 16385,
},
{
"displayName": "GPT-3.5 Turbo (1106)",
"functionCall": true,
"hidden": true,
"id": "gpt-3.5-turbo-1106",
"tokens": 16385,
},
{
"displayName": "GPT-3.5 Turbo Instruct",
"hidden": true,
"id": "gpt-3.5-turbo-instruct",
"tokens": 4096,
},
{
"displayName": "GPT-3.5 Turbo 16K",
"hidden": true,
"id": "gpt-3.5-turbo-16k",
"tokens": 16385,
},
{
"displayName": "GPT-3.5 Turbo (0613)",
"hidden": true,
"id": "gpt-3.5-turbo-0613",
"legacy": true,
"tokens": 4096,
},
{
"displayName": "GPT-3.5 Turbo 16K (0613)",
"hidden": true,
"id": "gpt-3.5-turbo-16k-0613",
"legacy": true,
"tokens": 4096,
},
{
"displayName": "GPT-4 Turbo Preview",
"functionCall": true,
"id": "gpt-4-turbo-preview",
"tokens": 128000,
},
{
"displayName": "GPT-4 Turbo Preview (0125)",
"functionCall": true,
"hidden": true,
"id": "gpt-4-0125-preview",
"tokens": 128000,
},
{
"description": "GPT-4 视觉预览版,支持视觉任务",
"displayName": "GPT-4 Turbo Vision Preview",
"id": "gpt-4-vision-preview",
"tokens": 128000,
"vision": true,
},
{
"displayName": "GPT-4 Turbo Preview (1106)",
"functionCall": true,
"hidden": true,
"id": "gpt-4-1106-preview",
"tokens": 128000,
},
{
"displayName": "GPT-4",
"functionCall": true,
"hidden": true,
"id": "gpt-4",
"tokens": 8192,
},
{
"displayName": "GPT-4 (0613)",
"functionCall": true,
"hidden": true,
"id": "gpt-4-0613",
"tokens": 8192,
},
{
"displayName": "GPT-4 32K",
"functionCall": true,
"hidden": true,
"id": "gpt-4-32k",
"tokens": 32768,
},
{
"displayName": "GPT-4 32K (0613)",
"functionCall": true,
"hidden": true,
"id": "gpt-4-32k-0613",
"tokens": 32768,
},
{
"displayName": "GPT-4 ALL",
"files": true,
"functionCall": true,
"hidden": true,
"id": "gpt-4-all",
"tokens": 32768,
"vision": true,
},
],
"enabled": true,
"id": "openai",
},
]
`;
18 changes: 18 additions & 0 deletions src/store/global/slices/settings/selectors/modelProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,24 @@ describe('modelProviderSelectors', () => {
});
});

describe('OPENROUTER_CUSTOM_MODELS', () => {
it('custom deletion, addition, and renaming of models', () => {
const s = merge(initialSettingsState, {
serverConfig: {
languageModel: {
openrouter: {
customModelName:
'-all,+google/gemma-7b-it,+mistralai/mistral-7b-instruct',
},
}
},
}) as unknown as GlobalStore;

const result = modelProviderSelectors.modelSelectList(s).filter((r) => r.enabled);
expect(result).toMatchSnapshot();
});
});

describe('modelEnabledVision', () => {
it('should return true if the model has vision ability', () => {
const hasAbility = modelProviderSelectors.modelEnabledVision('gpt-4-vision-preview')(
Expand Down

0 comments on commit 19c2c4b

Please sign in to comment.