diff --git a/packages/client/src/stores/hermes/app.ts b/packages/client/src/stores/hermes/app.ts index a4bd511..b3d6099 100644 --- a/packages/client/src/stores/hermes/app.ts +++ b/packages/client/src/stores/hermes/app.ts @@ -12,6 +12,7 @@ import { type ModelVisibility, type ModelVisibilityRule, } from '@/api/hermes/system' +import { hasApiKey } from '@/api/client' const WEB_UI_VERSION = __APP_VERSION__ @@ -128,6 +129,7 @@ export const useAppStore = defineStore('app', () => { } async function loadModels() { + if (!hasApiKey()) return try { const res = await fetchAvailableModels() applyAvailableModelsResponse(res) diff --git a/packages/client/src/stores/hermes/models.ts b/packages/client/src/stores/hermes/models.ts index 9ab087b..98c6b7f 100644 --- a/packages/client/src/stores/hermes/models.ts +++ b/packages/client/src/stores/hermes/models.ts @@ -2,6 +2,7 @@ import { defineStore } from 'pinia' import { ref, computed } from 'vue' import * as systemApi from '@/api/hermes/system' import type { AvailableModelGroup, CustomProvider } from '@/api/hermes/system' +import { hasApiKey } from '@/api/client' import { useAppStore } from './app' export const useModelsStore = defineStore('models', () => { @@ -31,6 +32,7 @@ export const useModelsStore = defineStore('models', () => { ) async function fetchProviders() { + if (!hasApiKey()) return loading.value = true try { const res = await systemApi.fetchAvailableModels() diff --git a/tests/client/app-store.test.ts b/tests/client/app-store.test.ts index 0dcd78a..c11d202 100644 --- a/tests/client/app-store.test.ts +++ b/tests/client/app-store.test.ts @@ -12,6 +12,7 @@ const mockSystemApi = vi.hoisted(() => ({ })) vi.mock('@/api/hermes/system', () => mockSystemApi) +vi.mock('@/api/client', () => ({ hasApiKey: () => true })) import { useAppStore } from '@/stores/hermes/app' diff --git a/tests/client/models-store.test.ts b/tests/client/models-store.test.ts index 0138aba..3ea0bf3 100644 --- a/tests/client/models-store.test.ts +++ b/tests/client/models-store.test.ts @@ -10,6 +10,7 @@ const mockSystemApi = vi.hoisted(() => ({ })) vi.mock('@/api/hermes/system', () => mockSystemApi) +vi.mock('@/api/client', () => ({ hasApiKey: () => true })) import { useAppStore } from '@/stores/hermes/app' import { useModelsStore } from '@/stores/hermes/models'