refactor: move general utils to shared directory

This commit is contained in:
AnotiaWang
2025-03-23 14:55:19 +08:00
parent ff1e79603d
commit 60f6f227c3
11 changed files with 124 additions and 63 deletions

View File

@ -272,6 +272,7 @@
retryNode,
currentDepth,
breadth,
aiConfig: config.ai,
maxDepth: form.value.depth,
languageCode: locale.value,
searchLanguageCode: config.webSearch.searchLanguage,

View File

@ -1,9 +1,6 @@
<script setup lang="ts">
const { locale: globalLocale, availableLocales, t, setLocale } = useI18n()
export type Locale = (typeof globalLocale)['value']
export type AvailableLocales = Locale[]
const props = defineProps<{
/** Override display locale */
value?: Locale

View File

@ -19,7 +19,7 @@
}>()
const { t, locale } = useI18n()
const { showConfigManager, isConfigValid } = storeToRefs(useConfigStore())
const { showConfigManager, isConfigValid, config } = storeToRefs(useConfigStore())
const toast = useToast()
const reasoningContent = ref('')
@ -57,6 +57,7 @@
query: form.value.query,
numQuestions: form.value.numQuestions,
language: t('language', {}, { locale: locale.value }),
aiConfig: config.value.ai,
})) {
if (f.type === 'reasoning') {
reasoningContent.value += f.delta

View File

@ -8,6 +8,7 @@
} from '~/constants/injection-keys'
const { t, locale } = useI18n()
const { config } = storeToRefs(useConfigStore())
const toast = useToast()
const error = ref('')
@ -156,6 +157,7 @@
prompt: getCombinedQuery(form.value, feedback.value),
language: t('language', {}, { locale: locale.value }),
learnings,
aiConfig: config.value.ai,
})
for await (const chunk of fullStream) {
if (chunk.type === 'reasoning') {

View File

@ -1,5 +1,5 @@
import { skipHydrate } from 'pinia'
import type { Locale } from '@/components/LangSwitcher.vue'
import { getApiBase } from '~~/shared/utils/ai-model'
export type ConfigAiProvider =
| 'openai-compatible'
@ -71,25 +71,7 @@ export const useConfigStore = defineStore('config', () => {
)
const isConfigValid = computed(() => validateConfig(config.value))
const aiApiBase = computed(() => {
const { ai } = config.value
if (ai.provider === 'openrouter') {
return ai.apiBase || 'https://openrouter.ai/api/v1'
}
if (ai.provider === 'deepseek') {
return ai.apiBase || 'https://api.deepseek.com/v1'
}
if (ai.provider === 'ollama') {
return ai.apiBase || 'http://localhost:11434/v1'
}
if (ai.provider === 'siliconflow') {
return ai.apiBase || 'https://api.siliconflow.cn/v1'
}
if (ai.provider === 'infiniai') {
return ai.apiBase || 'https://cloud.infini-ai.com/maas/v1'
}
return ai.apiBase || 'https://api.openai.com/v1'
})
const aiApiBase = computed(() => getApiBase(config.value.ai))
const webSearchApiBase = computed(() => {
const { webSearch } = config.value
if (webSearch.provider === 'tavily') {