fix: storeToRefs
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
data: OpenAICompatibleModel[]
|
data: OpenAICompatibleModel[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const { config, aiApiBase } = useConfigStore()
|
const { config, aiApiBase } = storeToRefs(useConfigStore())
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const showModal = ref(false)
|
const showModal = ref(false)
|
||||||
@ -26,36 +26,36 @@
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
const selectedAiProvider = computed(() =>
|
const selectedAiProvider = computed(() =>
|
||||||
aiProviderOptions.value.find((o) => o.value === config.ai.provider),
|
aiProviderOptions.value.find((o) => o.value === config.value.ai.provider),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Try to find available AI models based on selected provider
|
// Try to find available AI models based on selected provider
|
||||||
const debouncedListAiModels = useDebounceFn(async () => {
|
const debouncedListAiModels = useDebounceFn(async () => {
|
||||||
if (!config.ai.apiKey) return
|
if (!config.value.ai.apiKey) return
|
||||||
if (!aiApiBase || !aiApiBase.startsWith('http')) return
|
if (!aiApiBase.value || !aiApiBase.value.startsWith('http')) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadingAiModels.value = true
|
loadingAiModels.value = true
|
||||||
const result: OpenAICompatibleModelsResponse = await $fetch(
|
const result: OpenAICompatibleModelsResponse = await $fetch(
|
||||||
`${aiApiBase}/models`,
|
`${aiApiBase.value}/models`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${config.ai.apiKey}`,
|
Authorization: `Bearer ${config.value.ai.apiKey}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
console.log(
|
console.log(
|
||||||
`Found ${result.data.length} AI models for provider ${config.ai.provider}`,
|
`Found ${result.data.length} AI models for provider ${config.value.ai.provider}`,
|
||||||
)
|
)
|
||||||
aiModelOptions.value = result.data.map((m) => m.id)
|
aiModelOptions.value = result.data.map((m) => m.id)
|
||||||
// Auto-select the current model
|
// Auto-select the current model
|
||||||
if (!aiModelOptions.value.includes(config.ai.model)) {
|
if (!aiModelOptions.value.includes(config.value.ai.model)) {
|
||||||
aiModelOptions.value.unshift(config.ai.model)
|
aiModelOptions.value.unshift(config.value.ai.model)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Fetch AI models failed`, error)
|
console.error(`Fetch AI models failed`, error)
|
||||||
if (config.ai.model) {
|
if (config.value.ai.model) {
|
||||||
aiModelOptions.value = [config.ai.model]
|
aiModelOptions.value = [config.value.ai.model]
|
||||||
} else {
|
} else {
|
||||||
aiModelOptions.value = []
|
aiModelOptions.value = []
|
||||||
}
|
}
|
||||||
@ -65,9 +65,9 @@
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [
|
() => [
|
||||||
config.ai.provider,
|
config.value.ai.provider,
|
||||||
config.ai.apiKey,
|
config.value.ai.apiKey,
|
||||||
config.ai.apiBase,
|
config.value.ai.apiBase,
|
||||||
showModal.value,
|
showModal.value,
|
||||||
],
|
],
|
||||||
() => {
|
() => {
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
import type { ResearchResult } from '~/lib/deep-research'
|
import type { ResearchResult } from '~/lib/deep-research'
|
||||||
|
|
||||||
const { t, locale } = useI18n()
|
const { t, locale } = useI18n()
|
||||||
const { config } = useConfigStore()
|
const { config } = storeToRefs(useConfigStore())
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
const configManagerRef = ref<InstanceType<typeof ConfigManager>>()
|
const configManagerRef = ref<InstanceType<typeof ConfigManager>>()
|
||||||
@ -77,8 +77,8 @@ ${feedback.value
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function generateFeedback(data: ResearchInputData) {
|
async function generateFeedback(data: ResearchInputData) {
|
||||||
const aiConfig = config.ai
|
const aiConfig = config.value.ai
|
||||||
const webSearchConfig = config.webSearch
|
const webSearchConfig = config.value.webSearch
|
||||||
|
|
||||||
if (!aiConfig.model || !aiConfig.apiKey || !webSearchConfig.apiKey) {
|
if (!aiConfig.model || !aiConfig.apiKey || !webSearchConfig.apiKey) {
|
||||||
toast.add({
|
toast.add({
|
||||||
|
Reference in New Issue
Block a user