feat: add AI provider SiliconFlow

This commit is contained in:
AnotiaWang
2025-02-18 11:32:47 +08:00
parent 016aaf1a37
commit 7f7a08926d
5 changed files with 52 additions and 15 deletions

View File

@ -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)