mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-07 00:36:41 +08:00
feat(llm): add provider URL presets
Expose provider-specific preset endpoints in the setup and system settings flows so users can start from the correct base URL while still editing it manually.
This commit is contained in:
@@ -16,11 +16,17 @@ export interface LlmProviderAuthStatus {
|
|||||||
updated_at?: number | null
|
updated_at?: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LlmProviderUrlPreset {
|
||||||
|
label: string
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface LlmProvider {
|
export interface LlmProvider {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
runtime: string
|
runtime: string
|
||||||
default_base_url: string
|
default_base_url: string
|
||||||
|
base_url_presets?: LlmProviderUrlPreset[]
|
||||||
base_url_editable: boolean
|
base_url_editable: boolean
|
||||||
requires_base_url: boolean
|
requires_base_url: boolean
|
||||||
supports_api_key: boolean
|
supports_api_key: boolean
|
||||||
@@ -96,9 +102,15 @@ export function useLlmProviderDirectory(options: UseLlmProviderDirectoryOptions)
|
|||||||
() => models.value.find(item => item.id === normalizeValue(options.model.value)) || null,
|
() => models.value.find(item => item.id === normalizeValue(options.model.value)) || null,
|
||||||
)
|
)
|
||||||
const providerItems = computed(() => providers.value.map(item => ({ title: item.name, value: item.id })))
|
const providerItems = computed(() => providers.value.map(item => ({ title: item.name, value: item.id })))
|
||||||
|
const baseUrlPresetItems = computed(() =>
|
||||||
|
(selectedProvider.value?.base_url_presets || []).map(item => ({
|
||||||
|
title: item.label,
|
||||||
|
value: item.value,
|
||||||
|
})),
|
||||||
|
)
|
||||||
const providerConnected = computed(() => Boolean(selectedProvider.value?.auth_status?.connected))
|
const providerConnected = computed(() => Boolean(selectedProvider.value?.auth_status?.connected))
|
||||||
const showBaseUrlField = computed(
|
const showBaseUrlField = computed(
|
||||||
() => Boolean(selectedProvider.value?.requires_base_url || selectedProvider.value?.base_url_editable),
|
() => Boolean(selectedProvider.value && (selectedProvider.value.oauth_methods || []).length === 0),
|
||||||
)
|
)
|
||||||
const showApiKeyField = computed(() => selectedProvider.value?.supports_api_key !== false)
|
const showApiKeyField = computed(() => selectedProvider.value?.supports_api_key !== false)
|
||||||
const hasUsableCredential = computed(() => {
|
const hasUsableCredential = computed(() => {
|
||||||
@@ -333,6 +345,7 @@ export function useLlmProviderDirectory(options: UseLlmProviderDirectoryOptions)
|
|||||||
return {
|
return {
|
||||||
providers,
|
providers,
|
||||||
providerItems,
|
providerItems,
|
||||||
|
baseUrlPresetItems,
|
||||||
models,
|
models,
|
||||||
selectedProvider,
|
selectedProvider,
|
||||||
selectedModel,
|
selectedModel,
|
||||||
|
|||||||
@@ -1355,6 +1355,8 @@ export default {
|
|||||||
llmApiKey: 'LLM API Key',
|
llmApiKey: 'LLM API Key',
|
||||||
llmApiKeyHint: 'API key from the LLM service provider for authentication',
|
llmApiKeyHint: 'API key from the LLM service provider for authentication',
|
||||||
llmApiKeyPlaceholder: 'Please enter API key',
|
llmApiKeyPlaceholder: 'Please enter API key',
|
||||||
|
llmBaseUrlPreset: 'LLM URL Preset',
|
||||||
|
llmBaseUrlPresetHint: 'Start with a provider preset URL, then edit the actual request URL below if needed',
|
||||||
llmBaseUrl: 'LLM Base URL',
|
llmBaseUrl: 'LLM Base URL',
|
||||||
llmBaseUrlHint: 'Base URL for LLM API, used for custom API endpoints',
|
llmBaseUrlHint: 'Base URL for LLM API, used for custom API endpoints',
|
||||||
llmProviderAuth: 'Provider Authorization',
|
llmProviderAuth: 'Provider Authorization',
|
||||||
|
|||||||
@@ -1348,6 +1348,8 @@ export default {
|
|||||||
llmApiKey: 'LLM API密钥',
|
llmApiKey: 'LLM API密钥',
|
||||||
llmApiKeyHint: 'LLM服务提供商的API密钥,用于身份验证',
|
llmApiKeyHint: 'LLM服务提供商的API密钥,用于身份验证',
|
||||||
llmApiKeyPlaceholder: '请输入API密钥',
|
llmApiKeyPlaceholder: '请输入API密钥',
|
||||||
|
llmBaseUrlPreset: 'LLM地址预设',
|
||||||
|
llmBaseUrlPresetHint: '可先选择供应商预设地址,再按需修改下方实际调用地址',
|
||||||
llmBaseUrl: 'LLM基础URL',
|
llmBaseUrl: 'LLM基础URL',
|
||||||
llmBaseUrlHint: 'LLM API的基础URL地址,用于自定义API端点',
|
llmBaseUrlHint: 'LLM API的基础URL地址,用于自定义API端点',
|
||||||
llmProviderAuth: '提供商授权',
|
llmProviderAuth: '提供商授权',
|
||||||
|
|||||||
@@ -1350,6 +1350,8 @@ export default {
|
|||||||
llmApiKey: 'LLM API密鑰',
|
llmApiKey: 'LLM API密鑰',
|
||||||
llmApiKeyHint: 'LLM服務提供商的API密鑰,用於身份驗證',
|
llmApiKeyHint: 'LLM服務提供商的API密鑰,用於身份驗證',
|
||||||
llmApiKeyPlaceholder: '請輸入API密鑰',
|
llmApiKeyPlaceholder: '請輸入API密鑰',
|
||||||
|
llmBaseUrlPreset: 'LLM位址預設',
|
||||||
|
llmBaseUrlPresetHint: '可先選擇提供商預設位址,再按需修改下方實際調用位址',
|
||||||
llmBaseUrl: 'LLM基礎URL',
|
llmBaseUrl: 'LLM基礎URL',
|
||||||
llmBaseUrlHint: 'LLM API的基礎URL地址,用於自定義API端點',
|
llmBaseUrlHint: 'LLM API的基礎URL地址,用於自定義API端點',
|
||||||
llmProviderAuth: '提供商授權',
|
llmProviderAuth: '提供商授權',
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ const llmMaxContextRef = computed({
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
providerItems: llmProviderItems,
|
providerItems: llmProviderItems,
|
||||||
|
baseUrlPresetItems: llmBaseUrlPresetItems,
|
||||||
models: llmModels,
|
models: llmModels,
|
||||||
selectedProvider: selectedLlmProvider,
|
selectedProvider: selectedLlmProvider,
|
||||||
selectedModel: selectedLlmModel,
|
selectedModel: selectedLlmModel,
|
||||||
@@ -1015,11 +1016,24 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => {
|
|||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && showBaseUrlField" cols="12" md="6">
|
<VCol v-if="SystemSettings.Basic.AI_AGENT_ENABLE && showBaseUrlField" cols="12" md="6">
|
||||||
|
<VSelect
|
||||||
|
v-if="llmBaseUrlPresetItems.length > 0"
|
||||||
|
:model-value="SystemSettings.Basic.LLM_BASE_URL"
|
||||||
|
@update:model-value="(value: any) => {
|
||||||
|
SystemSettings.Basic.LLM_BASE_URL = value || '';
|
||||||
|
}"
|
||||||
|
:label="t('setting.system.llmBaseUrlPreset')"
|
||||||
|
:hint="t('setting.system.llmBaseUrlPresetHint')"
|
||||||
|
:items="llmBaseUrlPresetItems"
|
||||||
|
persistent-hint
|
||||||
|
prepend-inner-icon="mdi-format-list-bulleted-square"
|
||||||
|
class="mb-3"
|
||||||
|
/>
|
||||||
<VTextField
|
<VTextField
|
||||||
v-model="SystemSettings.Basic.LLM_BASE_URL"
|
v-model="SystemSettings.Basic.LLM_BASE_URL"
|
||||||
:label="t('setting.system.llmBaseUrl')"
|
:label="t('setting.system.llmBaseUrl')"
|
||||||
:hint="t('setting.system.llmBaseUrlHint')"
|
:hint="t('setting.system.llmBaseUrlHint')"
|
||||||
placeholder="https://api.deepseek.com"
|
:placeholder="selectedLlmProvider?.default_base_url || 'https://api.deepseek.com'"
|
||||||
persistent-hint
|
persistent-hint
|
||||||
prepend-inner-icon="mdi-link"
|
prepend-inner-icon="mdi-link"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ const authConnectedRef = computed({
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
providerItems,
|
providerItems,
|
||||||
|
baseUrlPresetItems,
|
||||||
models: llmModels,
|
models: llmModels,
|
||||||
selectedProvider,
|
selectedProvider,
|
||||||
selectedModel,
|
selectedModel,
|
||||||
@@ -228,11 +229,24 @@ onMounted(async () => {
|
|||||||
</VCol>
|
</VCol>
|
||||||
|
|
||||||
<VCol v-if="showBaseUrlField" cols="12" md="6">
|
<VCol v-if="showBaseUrlField" cols="12" md="6">
|
||||||
|
<VSelect
|
||||||
|
v-if="baseUrlPresetItems.length > 0"
|
||||||
|
:model-value="wizardData.agent.baseUrl"
|
||||||
|
@update:model-value="(value: any) => {
|
||||||
|
wizardData.agent.baseUrl = value || '';
|
||||||
|
}"
|
||||||
|
:label="t('setting.system.llmBaseUrlPreset')"
|
||||||
|
:hint="t('setting.system.llmBaseUrlPresetHint')"
|
||||||
|
:items="baseUrlPresetItems"
|
||||||
|
persistent-hint
|
||||||
|
prepend-inner-icon="mdi-format-list-bulleted-square"
|
||||||
|
class="mb-3"
|
||||||
|
/>
|
||||||
<VTextField
|
<VTextField
|
||||||
v-model="wizardData.agent.baseUrl"
|
v-model="wizardData.agent.baseUrl"
|
||||||
:label="t('setting.system.llmBaseUrl')"
|
:label="t('setting.system.llmBaseUrl')"
|
||||||
:hint="t('setting.system.llmBaseUrlHint')"
|
:hint="t('setting.system.llmBaseUrlHint')"
|
||||||
placeholder="https://api.deepseek.com"
|
:placeholder="selectedProvider?.default_base_url || 'https://api.deepseek.com'"
|
||||||
persistent-hint
|
persistent-hint
|
||||||
prepend-inner-icon="mdi-link-variant"
|
prepend-inner-icon="mdi-link-variant"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user