fix(stage-ui): localize Volcengine model descriptions (#2323)
This commit is contained in:
@@ -1422,6 +1422,11 @@ pages:
|
|||||||
title: Volcano Engine
|
title: Volcano Engine
|
||||||
volcengine-coding-plan:
|
volcengine-coding-plan:
|
||||||
description: Volcengine Coding Plan
|
description: Volcengine Coding Plan
|
||||||
|
models:
|
||||||
|
ark-code-latest:
|
||||||
|
description: Uses the model selected in the Coding Plan console, including Auto; changes apply in 3–5 minutes.
|
||||||
|
legacy:
|
||||||
|
description: Legacy Coding Plan model scheduled for retirement. Switch to a currently supported model.
|
||||||
title: Volcengine Coding Plan
|
title: Volcengine Coding Plan
|
||||||
byteplus:
|
byteplus:
|
||||||
description: byteplus.com
|
description: byteplus.com
|
||||||
|
|||||||
@@ -38,7 +38,13 @@ describe('ark chat provider definitions', () => {
|
|||||||
const chatConfig = providerInstance.chat('volcengine-coding-plan/doubao-seed-2.1-turbo')
|
const chatConfig = providerInstance.chat('volcengine-coding-plan/doubao-seed-2.1-turbo')
|
||||||
expect(chatConfig.model).toBe('doubao-seed-2.1-turbo')
|
expect(chatConfig.model).toBe('doubao-seed-2.1-turbo')
|
||||||
|
|
||||||
const listedModels = await provider!.extraMethods!.listModels!(parsedConfig, providerInstance)
|
const descriptions: Record<string, string> = {
|
||||||
|
'settings.pages.providers.provider.volcengine-coding-plan.models.ark-code-latest.description': 'Localized current model description.',
|
||||||
|
'settings.pages.providers.provider.volcengine-coding-plan.models.legacy.description': 'Localized legacy model description.',
|
||||||
|
}
|
||||||
|
const listedModels = await provider!.extraMethods!.listModels!(parsedConfig, providerInstance, {
|
||||||
|
t: input => descriptions[input] ?? input,
|
||||||
|
})
|
||||||
expect(listedModels.map(model => model.id)).toEqual([
|
expect(listedModels.map(model => model.id)).toEqual([
|
||||||
'volcengine-coding-plan/ark-code-latest',
|
'volcengine-coding-plan/ark-code-latest',
|
||||||
'volcengine-coding-plan/doubao-seed-2.1-turbo',
|
'volcengine-coding-plan/doubao-seed-2.1-turbo',
|
||||||
@@ -53,7 +59,7 @@ describe('ark chat provider definitions', () => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
expect(listedModels[0]).toEqual({
|
expect(listedModels[0]).toEqual({
|
||||||
description: 'Uses the model selected in the Coding Plan console, including Auto; changes apply in 3–5 minutes.',
|
description: 'Localized current model description.',
|
||||||
id: 'volcengine-coding-plan/ark-code-latest',
|
id: 'volcengine-coding-plan/ark-code-latest',
|
||||||
name: 'ark-code-latest',
|
name: 'ark-code-latest',
|
||||||
provider: 'volcengine-coding-plan',
|
provider: 'volcengine-coding-plan',
|
||||||
@@ -62,7 +68,7 @@ describe('ark chat provider definitions', () => {
|
|||||||
{
|
{
|
||||||
contextLength: 256000,
|
contextLength: 256000,
|
||||||
deprecated: true,
|
deprecated: true,
|
||||||
description: 'Legacy Coding Plan model scheduled for retirement. Switch to a currently supported model.',
|
description: 'Localized legacy model description.',
|
||||||
id: 'volcengine-coding-plan/doubao-seed-2.0-code',
|
id: 'volcengine-coding-plan/doubao-seed-2.0-code',
|
||||||
name: 'doubao-seed-2.0-code',
|
name: 'doubao-seed-2.0-code',
|
||||||
provider: 'volcengine-coding-plan',
|
provider: 'volcengine-coding-plan',
|
||||||
@@ -70,7 +76,7 @@ describe('ark chat provider definitions', () => {
|
|||||||
{
|
{
|
||||||
contextLength: 256000,
|
contextLength: 256000,
|
||||||
deprecated: true,
|
deprecated: true,
|
||||||
description: 'Legacy Coding Plan model scheduled for retirement. Switch to a currently supported model.',
|
description: 'Localized legacy model description.',
|
||||||
id: 'volcengine-coding-plan/doubao-seed-2.0-pro',
|
id: 'volcengine-coding-plan/doubao-seed-2.0-pro',
|
||||||
name: 'doubao-seed-2.0-pro',
|
name: 'doubao-seed-2.0-pro',
|
||||||
provider: 'volcengine-coding-plan',
|
provider: 'volcengine-coding-plan',
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ interface ArkModelSpec {
|
|||||||
id: string
|
id: string
|
||||||
contextLength?: number
|
contextLength?: number
|
||||||
deprecated?: boolean
|
deprecated?: boolean
|
||||||
description?: string
|
descriptionKey?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ArkProviderDefinitionOptions {
|
interface ArkProviderDefinitionOptions {
|
||||||
@@ -93,7 +93,7 @@ export function createArkChatProviderDefinition(options: ArkProviderDefinitionOp
|
|||||||
},
|
},
|
||||||
|
|
||||||
extraMethods: {
|
extraMethods: {
|
||||||
listModels: async () => models.map((model) => {
|
listModels: async (_config, _provider, contextOptions) => models.map((model) => {
|
||||||
const modelInfo: ModelInfo = {
|
const modelInfo: ModelInfo = {
|
||||||
id: `${modelPrefix}${model.id}`,
|
id: `${modelPrefix}${model.id}`,
|
||||||
name: model.id,
|
name: model.id,
|
||||||
@@ -105,8 +105,8 @@ export function createArkChatProviderDefinition(options: ArkProviderDefinitionOp
|
|||||||
if (model.deprecated !== undefined) {
|
if (model.deprecated !== undefined) {
|
||||||
modelInfo.deprecated = model.deprecated
|
modelInfo.deprecated = model.deprecated
|
||||||
}
|
}
|
||||||
if (model.description !== undefined) {
|
if (model.descriptionKey !== undefined && contextOptions) {
|
||||||
modelInfo.description = model.description
|
modelInfo.description = contextOptions.t(model.descriptionKey)
|
||||||
}
|
}
|
||||||
return modelInfo
|
return modelInfo
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const providerVolcengineCodingPlan = createArkChatProviderDefinition({
|
|||||||
models: [
|
models: [
|
||||||
{
|
{
|
||||||
id: 'ark-code-latest',
|
id: 'ark-code-latest',
|
||||||
description: 'Uses the model selected in the Coding Plan console, including Auto; changes apply in 3–5 minutes.',
|
descriptionKey: 'settings.pages.providers.provider.volcengine-coding-plan.models.ark-code-latest.description',
|
||||||
},
|
},
|
||||||
{ id: 'doubao-seed-2.1-turbo', contextLength: 256000 },
|
{ id: 'doubao-seed-2.1-turbo', contextLength: 256000 },
|
||||||
{ id: 'doubao-seed-2.0-lite', contextLength: 256000 },
|
{ id: 'doubao-seed-2.0-lite', contextLength: 256000 },
|
||||||
@@ -27,13 +27,13 @@ export const providerVolcengineCodingPlan = createArkChatProviderDefinition({
|
|||||||
id: 'doubao-seed-2.0-code',
|
id: 'doubao-seed-2.0-code',
|
||||||
contextLength: 256000,
|
contextLength: 256000,
|
||||||
deprecated: true,
|
deprecated: true,
|
||||||
description: 'Legacy Coding Plan model scheduled for retirement. Switch to a currently supported model.',
|
descriptionKey: 'settings.pages.providers.provider.volcengine-coding-plan.models.legacy.description',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'doubao-seed-2.0-pro',
|
id: 'doubao-seed-2.0-pro',
|
||||||
contextLength: 256000,
|
contextLength: 256000,
|
||||||
deprecated: true,
|
deprecated: true,
|
||||||
description: 'Legacy Coding Plan model scheduled for retirement. Switch to a currently supported model.',
|
descriptionKey: 'settings.pages.providers.provider.volcengine-coding-plan.models.legacy.description',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export interface ProviderOnboardingField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ProviderExtraMethods<TConfig> {
|
export interface ProviderExtraMethods<TConfig> {
|
||||||
listModels?: (config: TConfig, provider: ProviderInstance) => Promise<ModelInfo[]>
|
listModels?: (config: TConfig, provider: ProviderInstance, contextOptions?: { t: (input: string) => string }) => Promise<ModelInfo[]>
|
||||||
/**
|
/**
|
||||||
* Returns the voice catalogue. `model` lets providers whose voices vary by
|
* Returns the voice catalogue. `model` lets providers whose voices vary by
|
||||||
* model variant (Volcengine streaming TTS 1.0 vs 2.0 differ in catalogue)
|
* model variant (Volcengine streaming TTS 1.0 vs 2.0 differ in catalogue)
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ export const useProviderStore = defineStore('provider', () => {
|
|||||||
const provider = await definition.createProvider(config)
|
const provider = await definition.createProvider(config)
|
||||||
try {
|
try {
|
||||||
if (definition.extraMethods?.listModels) {
|
if (definition.extraMethods?.listModels) {
|
||||||
const models = await definition.extraMethods.listModels(config, provider)
|
const models = await definition.extraMethods.listModels(config, provider, { t })
|
||||||
return normalizeProviderModels(providerId, models)
|
return normalizeProviderModels(providerId, models)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user