feat(i18n): update WeKnoraCloud integration and enhance model management

- Revised usage steps in English, Korean, Russian, and Chinese localization files for clarity on saving credentials and adding cloud models.
- Introduced a new section in WeKnoraCloudSettings.vue to display the status of cloud model integration based on credential configuration.
- Added utility functions for managing WeKnoraCloud models, including model configuration and existing model checks.
- Enhanced ModelSettings.vue to improve model management actions and confirm deletion prompts.
- Implemented logic to handle adding cloud models with success and failure notifications.
This commit is contained in:
wizardchen
2026-06-10 20:26:19 +08:00
committed by lyingbug
parent bb220db4e4
commit ad27ed134e
7 changed files with 512 additions and 33 deletions
+72
View File
@@ -0,0 +1,72 @@
import type { ModelConfig } from '@/api/model'
export const WEKNORA_CLOUD_BASE_URL = 'https://weknora.weixin.qq.com'
export const WEKNORA_CLOUD_PROVIDER = 'weknoracloud'
export type WkcModelKind = 'chat' | 'embedding' | 'rerank' | 'vllm'
const BACKEND_TYPE_BY_KIND: Record<WkcModelKind, ModelConfig['type']> = {
chat: 'KnowledgeQA',
embedding: 'Embedding',
rerank: 'Rerank',
vllm: 'VLLM',
}
export const WKC_MODEL_NAME_BY_KIND: Record<WkcModelKind, string> = {
chat: 'chat',
embedding: 'embedding',
rerank: 'rerank',
vllm: 'vlm',
}
export const WKC_MODEL_KINDS: WkcModelKind[] = ['chat', 'embedding', 'rerank', 'vllm']
export function isWeKnoraCloudModel(model: ModelConfig): boolean {
return model.parameters?.provider === WEKNORA_CLOUD_PROVIDER
}
/** Returns kinds that already have a WeKnoraCloud model of the matching backend type. */
export function existingWkcKinds(models: ModelConfig[]): Set<WkcModelKind> {
const found = new Set<WkcModelKind>()
for (const model of models) {
if (!isWeKnoraCloudModel(model)) continue
for (const kind of WKC_MODEL_KINDS) {
if (model.type === BACKEND_TYPE_BY_KIND[kind]) {
found.add(kind)
}
}
}
return found
}
export function buildWkcModelConfig(
kind: WkcModelKind,
displayName: string,
dimension?: number,
): ModelConfig {
const name = WKC_MODEL_NAME_BY_KIND[kind]
const type = BACKEND_TYPE_BY_KIND[kind]
const parameters: ModelConfig['parameters'] = {
base_url: WEKNORA_CLOUD_BASE_URL,
provider: WEKNORA_CLOUD_PROVIDER,
}
if (kind === 'embedding' && dimension) {
parameters.embedding_parameters = {
dimension,
truncate_prompt_tokens: 0,
}
}
if (kind === 'vllm') {
parameters.supports_vision = true
}
return {
name,
display_name: displayName,
type,
source: 'remote',
description: '',
parameters,
}
}