refactor(frontend): streamline knowledge base and agent handling with chat resources store
- Updated components to utilize the new `useChatResourcesStore` for managing knowledge bases and agents, improving data fetching and caching mechanisms. - Refactored `AgentSelector`, `IMChannelPanel`, `Input-field`, and `menu` components to replace direct API calls with store methods, enhancing maintainability and performance. - Adjusted knowledge base loading logic to ensure consistency across components and reduce redundant API requests. - Improved session state handling in `settings` store to prevent overwriting user selections during state restoration.
This commit is contained in:
@@ -1,20 +1,23 @@
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useChatResourcesStore } from '@/stores/chatResources'
|
||||
import {
|
||||
fetchTenantModelReadiness,
|
||||
evaluateTenantModelReadiness,
|
||||
type TenantModelReadiness,
|
||||
} from '@/utils/tenantModelReadiness'
|
||||
|
||||
export function useTenantModelReadiness() {
|
||||
const uiStore = useUIStore()
|
||||
const chatResources = useChatResourcesStore()
|
||||
const readiness = ref<TenantModelReadiness | null>(null)
|
||||
const loaded = ref(false)
|
||||
const loading = ref(false)
|
||||
|
||||
const refresh = async () => {
|
||||
const refresh = async (force = false) => {
|
||||
loading.value = true
|
||||
try {
|
||||
readiness.value = await fetchTenantModelReadiness()
|
||||
await chatResources.ensureModels(force)
|
||||
readiness.value = evaluateTenantModelReadiness(chatResources.allModels)
|
||||
} finally {
|
||||
loading.value = false
|
||||
loaded.value = true
|
||||
@@ -29,7 +32,7 @@ export function useTenantModelReadiness() {
|
||||
() => uiStore.showSettingsModal,
|
||||
(open, wasOpen) => {
|
||||
if (wasOpen && !open) {
|
||||
refresh()
|
||||
refresh(true)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user