feat(lkeap): integrate Tencent Cloud LKEAP Rerank support
- Added support for Tencent Cloud LKEAP Rerank, including new configuration options for SecretId and SecretKey. - Updated frontend components to handle LKEAP-specific fields and enhance user experience with appropriate labels and placeholders. - Enhanced backend logic to manage LKEAP credentials and integrate with the new rerank API. - Improved localization for LKEAP-related terms across multiple languages, ensuring clarity and consistency in user-facing messages. - Introduced tests for LKEAP Reranker functionality to ensure reliability and correctness in handling requests.
This commit is contained in:
@@ -276,6 +276,8 @@ interface BaseModelTestPayload {
|
||||
customHeaders?: Record<string, string>;
|
||||
extraConfig?: Record<string, string>;
|
||||
interfaceType?: string;
|
||||
/** 第二段密钥(如 LKEAP Rerank 的腾讯云 SecretKey) */
|
||||
appSecret?: string;
|
||||
}
|
||||
|
||||
// 检查远程API模型
|
||||
|
||||
@@ -215,7 +215,9 @@
|
||||
</div>
|
||||
|
||||
<div v-if="formData.provider !== 'weknoracloud'" class="form-item">
|
||||
<label class="form-label">{{ $t('model.editor.apiKeyOptional') }}</label>
|
||||
<label class="form-label">{{
|
||||
isLkeapRerank ? $t('model.editor.lkeap.secretIdLabel') : $t('model.editor.apiKeyOptional')
|
||||
}}</label>
|
||||
<!--
|
||||
Edit mode: credentials live behind the /credentials subresource
|
||||
of the model — managed by the shared CredentialResource card,
|
||||
@@ -230,7 +232,8 @@
|
||||
<CredentialResource v-if="isEdit && props.modelData?.id" :api="credentialApi" :fields="credentialFields"
|
||||
:meta="credentialMeta" />
|
||||
<t-input v-else v-model="formData.apiKey" :type="showApiKey ? 'text' : 'password'"
|
||||
:placeholder="apiKeyPlaceholder" class="api-key-input" autocomplete="off" spellcheck="false">
|
||||
:placeholder="isLkeapRerank ? $t('model.editor.lkeap.secretIdPlaceholder') : apiKeyPlaceholder"
|
||||
class="api-key-input" autocomplete="off" spellcheck="false">
|
||||
<template #prefix-icon><t-icon name="lock-on" /></template>
|
||||
<template #suffix-icon>
|
||||
<t-icon
|
||||
@@ -241,6 +244,22 @@
|
||||
/>
|
||||
</template>
|
||||
</t-input>
|
||||
<p v-if="isLkeapRerank" class="form-desc">{{ $t('model.editor.lkeap.rerankCredentialHint') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- LKEAP Rerank 创建模式:SecretKey(编辑模式由 CredentialResource 管理) -->
|
||||
<div v-if="isLkeapRerank && !isEdit" class="form-item">
|
||||
<label class="form-label required">{{ $t('model.editor.lkeap.secretKeyLabel') }}</label>
|
||||
<t-input v-model="formData.appSecret" type="password"
|
||||
:placeholder="$t('model.editor.lkeap.secretKeyPlaceholder')" autocomplete="off" spellcheck="false">
|
||||
<template #prefix-icon><t-icon name="lock-on" /></template>
|
||||
</t-input>
|
||||
</div>
|
||||
|
||||
<div v-if="isLkeapRerank" class="form-item">
|
||||
<label class="form-label">{{ $t('model.editor.lkeap.regionLabel') }}</label>
|
||||
<t-input v-model="formData.lkeapRegion" :placeholder="$t('model.editor.lkeap.regionPlaceholder')" />
|
||||
<p class="form-desc">{{ $t('model.editor.lkeap.regionDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- 自定义 HTTP Header(类似 OpenAI Python SDK 的 extra_headers) -->
|
||||
@@ -350,6 +369,10 @@ interface ModelFormData {
|
||||
supportsVision?: boolean
|
||||
// 自定义 HTTP 请求头(类似 OpenAI Python SDK 的 extra_headers)
|
||||
customHeaders?: CustomHeaderItem[]
|
||||
/** LKEAP Rerank:腾讯云 SecretKey(创建时写入 app_secret) */
|
||||
appSecret?: string
|
||||
/** LKEAP Rerank:地域,如 ap-guangzhou */
|
||||
lkeapRegion?: string
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -555,17 +578,24 @@ const modelTypeIcon = computed(() => {
|
||||
return map[props.modelType] || 'setting'
|
||||
})
|
||||
|
||||
const isLkeapRerank = computed(
|
||||
() => props.modelType === 'rerank' && formData.value.provider === 'lkeap',
|
||||
)
|
||||
|
||||
// Credential resource binding for the shared <CredentialResource> component.
|
||||
// "app_secret" is only relevant for the WeKnora Cloud provider; the visible
|
||||
// fields collapse to just api_key for every other provider. We always pass
|
||||
// both keys to the backend (it returns metadata for each), but only render
|
||||
// the ones meaningful to the current provider.
|
||||
const credentialFields = computed<CredentialFieldDef<ModelCredentialField>[]>(() => {
|
||||
const fields: CredentialFieldDef<ModelCredentialField>[] = [
|
||||
{ key: 'api_key', label: t('model.editor.apiKeyOptional') as string },
|
||||
{
|
||||
key: 'api_key',
|
||||
label: (isLkeapRerank.value
|
||||
? t('model.editor.lkeap.secretIdLabel')
|
||||
: t('model.editor.apiKeyOptional')) as string,
|
||||
},
|
||||
]
|
||||
if (formData.value.provider === 'weknoracloud') {
|
||||
fields.push({ key: 'app_secret', label: 'App Secret' })
|
||||
} else if (isLkeapRerank.value) {
|
||||
fields.push({ key: 'app_secret', label: t('model.editor.lkeap.secretKeyLabel') as string })
|
||||
}
|
||||
return fields
|
||||
})
|
||||
@@ -667,7 +697,9 @@ const formData = ref<ModelFormData>({
|
||||
interfaceType: 'ollama',
|
||||
isDefault: false,
|
||||
supportsVision: false,
|
||||
customHeaders: []
|
||||
customHeaders: [],
|
||||
appSecret: '',
|
||||
lkeapRegion: 'ap-guangzhou',
|
||||
})
|
||||
|
||||
const rules = computed(() => ({
|
||||
@@ -852,7 +884,9 @@ const resetForm = () => {
|
||||
interfaceType: undefined,
|
||||
isDefault: false,
|
||||
supportsVision: false,
|
||||
customHeaders: []
|
||||
customHeaders: [],
|
||||
appSecret: '',
|
||||
lkeapRegion: 'ap-guangzhou',
|
||||
}
|
||||
modelChecked.value = false
|
||||
modelAvailable.value = false
|
||||
@@ -874,6 +908,9 @@ const handleProviderChange = (value: string) => {
|
||||
if (defaultUrl) {
|
||||
formData.value.baseUrl = defaultUrl
|
||||
}
|
||||
if (value === 'lkeap' && props.modelType === 'rerank' && !formData.value.modelName?.trim()) {
|
||||
formData.value.modelName = 'lke-reranker-base'
|
||||
}
|
||||
// 重置校验状态
|
||||
remoteChecked.value = false
|
||||
remoteAvailable.value = false
|
||||
@@ -1097,8 +1134,17 @@ const checkRemoteAPI = async () => {
|
||||
}
|
||||
break
|
||||
|
||||
case 'rerank':
|
||||
// Rerank 模型
|
||||
case 'rerank': {
|
||||
const lkeapExtra = isLkeapRerank.value
|
||||
? {
|
||||
extraConfig: {
|
||||
region: (formData.value.lkeapRegion || 'ap-guangzhou').trim(),
|
||||
},
|
||||
...(formData.value.appSecret?.trim()
|
||||
? { appSecret: formData.value.appSecret.trim() }
|
||||
: {}),
|
||||
}
|
||||
: {}
|
||||
result = await checkRerankModel({
|
||||
modelName: formData.value.modelName,
|
||||
baseUrl: formData.value.baseUrl,
|
||||
@@ -1106,8 +1152,10 @@ const checkRemoteAPI = async () => {
|
||||
provider: formData.value.provider,
|
||||
...idPayload,
|
||||
...headerPayload,
|
||||
...lkeapExtra,
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
case 'vllm':
|
||||
// VLLM 模型(多模态)
|
||||
|
||||
@@ -3292,6 +3292,17 @@ export default {
|
||||
baseUrlPlaceholderAsr: 'e.g. https://api.openai.com/v1',
|
||||
apiKeyOptional: 'API Key (optional)',
|
||||
apiKeyPlaceholder: 'Enter API Key',
|
||||
lkeap: {
|
||||
secretIdLabel: 'SecretId',
|
||||
secretIdPlaceholder: 'Tencent Cloud API SecretId',
|
||||
secretKeyLabel: 'SecretKey',
|
||||
secretKeyPlaceholder: 'Tencent Cloud API SecretKey',
|
||||
regionLabel: 'Region',
|
||||
regionPlaceholder: 'ap-guangzhou',
|
||||
regionDesc: 'RunRerank supports ap-beijing, ap-guangzhou, etc. Default: ap-guangzhou',
|
||||
rerankCredentialHint:
|
||||
'Rerank uses Tencent Cloud API signature (not the OpenAI-style LKEAP API key). Create SecretId/SecretKey in the CAM console.',
|
||||
},
|
||||
customHeadersLabel: 'Custom Request Headers (optional)',
|
||||
customHeadersDesc: 'Extra HTTP headers appended to requests to the remote model API (e.g. for enterprise gateway auth or tracing). Reserved headers like Authorization / Content-Type are ignored.',
|
||||
customHeadersAdd: 'Add Header',
|
||||
@@ -3425,7 +3436,7 @@ export default {
|
||||
},
|
||||
lkeap: {
|
||||
label: 'Tencent Cloud LKEAP',
|
||||
description: 'DeepSeek-R1, DeepSeek-V3 series with chain-of-thought',
|
||||
description: 'DeepSeek-R1, DeepSeek-V3, lke-reranker-base, etc.',
|
||||
},
|
||||
nvidia: {
|
||||
label: "NVIDIA",
|
||||
|
||||
@@ -2654,7 +2654,7 @@ export default {
|
||||
},
|
||||
lkeap: {
|
||||
label: "텐센트 클라우드 LKEAP",
|
||||
description: "DeepSeek-R1, DeepSeek-V3 시리즈, 사고 체인 지원",
|
||||
description: "DeepSeek-R1, DeepSeek-V3, lke-reranker-base 등",
|
||||
},
|
||||
nvidia: {
|
||||
label: "NVIDIA",
|
||||
|
||||
@@ -2368,7 +2368,7 @@ export default {
|
||||
},
|
||||
lkeap: {
|
||||
label: 'Tencent Cloud LKEAP',
|
||||
description: 'DeepSeek-R1, DeepSeek-V3 с поддержкой цепочки рассуждений'
|
||||
description: 'DeepSeek-R1, DeepSeek-V3, lke-reranker-base и др.'
|
||||
},
|
||||
nvidia: {
|
||||
label: "NVIDIA",
|
||||
|
||||
@@ -2509,6 +2509,17 @@ export default {
|
||||
baseUrlPlaceholderAsr: "例如:https://api.openai.com/v1",
|
||||
apiKeyOptional: "API Key(可选)",
|
||||
apiKeyPlaceholder: "输入 API Key",
|
||||
lkeap: {
|
||||
secretIdLabel: "SecretId",
|
||||
secretIdPlaceholder: "腾讯云 API 密钥 SecretId",
|
||||
secretKeyLabel: "SecretKey",
|
||||
secretKeyPlaceholder: "腾讯云 API 密钥 SecretKey",
|
||||
regionLabel: "地域",
|
||||
regionPlaceholder: "ap-guangzhou",
|
||||
regionDesc: "RunRerank 支持 ap-beijing、ap-guangzhou 等,默认 ap-guangzhou",
|
||||
rerankCredentialHint:
|
||||
"Rerank 使用腾讯云 API 签名(非 OpenAI API Key)。请在云 API 密钥控制台创建 SecretId/SecretKey。",
|
||||
},
|
||||
customHeadersLabel: "自定义请求头(可选)",
|
||||
customHeadersDesc: "调用远程模型 API 时附加的 HTTP 请求头,常用于企业网关鉴权、链路追踪等场景;Authorization、Content-Type 等保留头会被自动忽略。",
|
||||
customHeadersAdd: "添加请求头",
|
||||
@@ -2642,7 +2653,7 @@ export default {
|
||||
},
|
||||
lkeap: {
|
||||
label: "腾讯云 LKEAP",
|
||||
description: "DeepSeek-R1, DeepSeek-V3 系列模型,支持思维链",
|
||||
description: "DeepSeek-R1、DeepSeek-V3、lke-reranker-base 等",
|
||||
},
|
||||
nvidia: {
|
||||
label: "NVIDIA",
|
||||
|
||||
@@ -161,6 +161,7 @@ function convertToLegacyFormat(model: ModelConfig) {
|
||||
customHeaders: model.parameters.custom_headers
|
||||
? Object.entries(model.parameters.custom_headers).map(([key, value]) => ({ key, value: String(value) }))
|
||||
: [],
|
||||
lkeapRegion: model.parameters.extra_config?.region || 'ap-guangzhou',
|
||||
_modelType: backendTypeToModelType[model.type] || 'chat' as ModelType,
|
||||
// Preserve the credential metadata map so the editor dialog can render
|
||||
// the "Configured" state without an extra round-trip.
|
||||
@@ -371,6 +372,17 @@ const handleModelSave = async (modelData: any) => {
|
||||
const trimmedApiKey = (modelData.apiKey ?? '').trim()
|
||||
const apiKeyFields: { api_key?: string } =
|
||||
!editingModel.value && trimmedApiKey ? { api_key: trimmedApiKey } : {}
|
||||
const trimmedAppSecret = (modelData.appSecret ?? '').trim()
|
||||
const appSecretFields: { app_secret?: string } =
|
||||
!editingModel.value && trimmedAppSecret ? { app_secret: trimmedAppSecret } : {}
|
||||
const lkeapExtra =
|
||||
modelData.provider === 'lkeap' && currentModelType.value === 'rerank'
|
||||
? {
|
||||
extra_config: {
|
||||
region: (modelData.lkeapRegion || 'ap-guangzhou').trim(),
|
||||
},
|
||||
}
|
||||
: {}
|
||||
|
||||
const apiModelData: ModelConfig = {
|
||||
name: modelData.modelName.trim(),
|
||||
@@ -381,7 +393,9 @@ const handleModelSave = async (modelData: any) => {
|
||||
parameters: {
|
||||
base_url: modelData.baseUrl?.trim() || '',
|
||||
...apiKeyFields,
|
||||
...appSecretFields,
|
||||
provider: modelData.provider || '',
|
||||
...lkeapExtra,
|
||||
...(Object.keys(customHeadersMap).length > 0 ? { custom_headers: customHeadersMap } : {}),
|
||||
...(currentModelType.value === 'embedding' && modelData.dimension ? {
|
||||
embedding_parameters: {
|
||||
|
||||
Reference in New Issue
Block a user