feat: add AI provider SiliconFlow
This commit is contained in:
@ -23,9 +23,20 @@
|
||||
const aiProviderOptions = computed(() => [
|
||||
{
|
||||
label: t('settings.ai.providers.openaiCompatible.title'),
|
||||
help: t('settings.ai.providers.openaiCompatible.description'),
|
||||
help: 'settings.ai.providers.openaiCompatible.description',
|
||||
// Only kept for easy reference in i18n Ally
|
||||
_help: t('settings.ai.providers.openaiCompatible.description'),
|
||||
value: 'openai-compatible',
|
||||
},
|
||||
{
|
||||
label: t('settings.ai.providers.siliconflow.title'),
|
||||
help: 'settings.ai.providers.siliconflow.description',
|
||||
// Only kept for easy reference in i18n Ally
|
||||
_help: t('settings.ai.providers.siliconflow.description'),
|
||||
value: 'siliconflow',
|
||||
link: 'https://cloud.siliconflow.cn/i/J0NHrrX8',
|
||||
linkText: 'cloud.siliconflow.cn',
|
||||
},
|
||||
{
|
||||
label: 'DeepSeek',
|
||||
value: 'deepseek',
|
||||
@ -141,14 +152,26 @@
|
||||
<!-- AI provider -->
|
||||
<h3 class="font-bold">{{ $t('settings.ai.provider') }}</h3>
|
||||
<UFormField>
|
||||
<template v-if="selectedAiProvider" #help>
|
||||
<span class="whitespace-pre-wrap">
|
||||
{{ selectedAiProvider.help }}
|
||||
</span>
|
||||
<template v-if="selectedAiProvider?.help" #help>
|
||||
<i18n-t
|
||||
class="whitespace-pre-wrap"
|
||||
:keypath="selectedAiProvider.help"
|
||||
tag="span"
|
||||
>
|
||||
<UButton
|
||||
v-if="selectedAiProvider.link"
|
||||
class="!p-0"
|
||||
:to="selectedAiProvider.link"
|
||||
target="_blank"
|
||||
variant="link"
|
||||
>
|
||||
{{ selectedAiProvider.linkText || selectedAiProvider.link }}
|
||||
</UButton>
|
||||
</i18n-t>
|
||||
</template>
|
||||
<USelect
|
||||
v-model="config.ai.provider"
|
||||
class="w-auto"
|
||||
class="w-full"
|
||||
:items="aiProviderOptions"
|
||||
/>
|
||||
</UFormField>
|
||||
|
@ -21,6 +21,7 @@ export const useAiModel = () => {
|
||||
})
|
||||
} else if (
|
||||
config.ai.provider === 'deepseek' ||
|
||||
config.ai.provider === 'siliconflow' ||
|
||||
// Special case if model name includes 'deepseek'
|
||||
// This ensures compatibilty with providers like Siliconflow
|
||||
config.ai.model?.toLowerCase().includes('deepseek')
|
||||
|
@ -22,7 +22,11 @@
|
||||
"providers": {
|
||||
"openaiCompatible": {
|
||||
"title": "OpenAI Compatible",
|
||||
"description": "e.g. OpenAI, Gemini, Together AI, SiliconCloud, ...\n(Note: DeepSeek, OpenRouter and Ollama now have their own providers.)"
|
||||
"description": "Every provider that is compatible with the OpenAI API. Note: Some providers have their own options for better performance."
|
||||
},
|
||||
"siliconflow": {
|
||||
"title": "SiliconFlow",
|
||||
"description": "Offers ¥14 free credits on register. Get one API key at {0}."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -22,7 +22,11 @@
|
||||
"providers": {
|
||||
"openaiCompatible": {
|
||||
"title": "OpenAI Compatible",
|
||||
"description": "如 OpenAI、Gemini、Together AI、SiliconCloud……\n注:DeepSeek、OpenRouter 和 Ollama 现在已经有了独立选项,请切换使用。"
|
||||
"description": "任意兼容 OpenAI 接口格式的供应商。\n注:为了改进兼容性,部分供应商有单独的选项,请展开查看。"
|
||||
},
|
||||
"siliconflow": {
|
||||
"title": "SiliconFlow 硅基流动",
|
||||
"description": "注册赠送 ¥14 元免费额度。在 {0} 生成一个 API key。"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3,6 +3,7 @@ import type { Locale } from '~/components/LangSwitcher.vue'
|
||||
|
||||
export type ConfigAiProvider =
|
||||
| 'openai-compatible'
|
||||
| 'siliconflow'
|
||||
| 'openrouter'
|
||||
| 'deepseek'
|
||||
| 'ollama'
|
||||
@ -62,16 +63,20 @@ export const useConfigStore = defineStore('config', () => {
|
||||
const isConfigValid = computed(() => validateConfig(config.value))
|
||||
|
||||
const aiApiBase = computed(() => {
|
||||
if (config.value.ai.provider === 'openrouter') {
|
||||
return config.value.ai.apiBase || 'https://openrouter.ai/api/v1'
|
||||
const { ai } = config.value
|
||||
if (ai.provider === 'openrouter') {
|
||||
return ai.apiBase || 'https://openrouter.ai/api/v1'
|
||||
}
|
||||
if (config.value.ai.provider === 'deepseek') {
|
||||
return config.value.ai.apiBase || 'https://api.deepseek.com/v1'
|
||||
if (ai.provider === 'deepseek') {
|
||||
return ai.apiBase || 'https://api.deepseek.com/v1'
|
||||
}
|
||||
if (config.value.ai.provider === 'ollama') {
|
||||
return config.value.ai.apiBase || 'http://localhost:11434/v1'
|
||||
if (ai.provider === 'ollama') {
|
||||
return ai.apiBase || 'http://localhost:11434/v1'
|
||||
}
|
||||
return config.value.ai.apiBase || 'https://api.openai.com/v1'
|
||||
if (ai.provider === 'siliconflow') {
|
||||
return ai.apiBase || 'https://api.siliconflow.cn/v1'
|
||||
}
|
||||
return ai.apiBase || 'https://api.openai.com/v1'
|
||||
})
|
||||
|
||||
const showConfigManager = ref(false)
|
||||
|
Reference in New Issue
Block a user