feat: modelscope provider (#493)
This commit is contained in:
@@ -406,6 +406,9 @@ pages:
|
||||
moonshot:
|
||||
description: moonshot.ai
|
||||
title: Moonshot AI
|
||||
modelscope:
|
||||
description: modelscope.cn
|
||||
title: ModelScope
|
||||
novita:
|
||||
description: novita.ai
|
||||
title: Novita
|
||||
|
||||
@@ -403,6 +403,9 @@ pages:
|
||||
moonshot:
|
||||
description: moonshot.ai
|
||||
title: Moonshot AI
|
||||
modelscope:
|
||||
description: modelscope.cn
|
||||
title: ModelScope
|
||||
novita:
|
||||
description: novita.ai
|
||||
title: Novita
|
||||
|
||||
@@ -375,6 +375,9 @@ pages:
|
||||
moonshot:
|
||||
description: Moonshot.ai
|
||||
title: 月之暗面
|
||||
modelscope:
|
||||
description: modelscope.cn
|
||||
title: 魔搭社区 ModelScope
|
||||
novita:
|
||||
description: novita.ai
|
||||
title: Novita
|
||||
|
||||
@@ -119,6 +119,7 @@ function getApiKeyPlaceholder(_providerId: string): string {
|
||||
'together-ai': 'togetherapi-...',
|
||||
'mistral-ai': 'mis-...',
|
||||
'moonshot-ai': 'ms-...',
|
||||
'modelscope': 'ms-...',
|
||||
'fireworks-ai': 'fw-...',
|
||||
'featherless-ai': 'fw-...',
|
||||
'novita-ai': 'nvt-...',
|
||||
|
||||
@@ -2140,6 +2140,50 @@ export const useProvidersStore = defineStore('providers', () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
'modelscope': {
|
||||
id: 'modelscope',
|
||||
category: 'chat',
|
||||
tasks: ['text-generation'],
|
||||
nameKey: 'settings.pages.providers.provider.modelscope.title',
|
||||
name: 'ModelScope',
|
||||
descriptionKey: 'settings.pages.providers.provider.modelscope.description',
|
||||
description: 'modelscope',
|
||||
icon: 'i-lobe-icons:modelscope',
|
||||
defaultOptions: () => ({
|
||||
baseUrl: 'https://api-inference.modelscope.cn/v1/',
|
||||
}),
|
||||
createProvider: async config => createOpenAI((config.apiKey as string).trim(), (config.baseUrl as string).trim()),
|
||||
capabilities: {
|
||||
listModels: async (config) => {
|
||||
return (await listModels({
|
||||
...createOpenAI((config.apiKey as string).trim(), (config.baseUrl as string).trim()).model(),
|
||||
})).map((model) => {
|
||||
return {
|
||||
id: model.id,
|
||||
name: model.id,
|
||||
provider: 'modelscope',
|
||||
description: '',
|
||||
contextLength: 0,
|
||||
deprecated: false,
|
||||
} satisfies ModelInfo
|
||||
})
|
||||
},
|
||||
},
|
||||
validators: {
|
||||
validateProviderConfig: (config) => {
|
||||
const errors = [
|
||||
!config.apiKey && new Error('API key is required.'),
|
||||
!config.baseUrl && new Error('Base URL is required.'),
|
||||
].filter(Boolean)
|
||||
|
||||
return {
|
||||
errors,
|
||||
reason: errors.filter(e => e).map(e => String(e)).join(', ') || '',
|
||||
valid: !!config.apiKey && !!config.baseUrl,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
'player2': {
|
||||
id: 'player2',
|
||||
category: 'chat',
|
||||
|
||||
Reference in New Issue
Block a user