mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-28 21:49:40 +02:00
- Introduced a new endpoint to check the existence of a global LLM configuration file. - Updated the frontend to utilize this status, affecting onboarding flow and user experience. - Added necessary atoms and types for managing global LLM config status in the application state. - Refactored navigation to ensure proper routing based on the global config status.
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { atomWithQuery } from "jotai-tanstack-query";
|
|
import { modelConnectionsApiService } from "@/lib/apis/model-connections-api.service";
|
|
import { getBearerToken } from "@/lib/auth-utils";
|
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|
import { activeSearchSpaceIdAtom } from "../search-spaces/search-space-query.atoms";
|
|
|
|
export const globalModelConnectionsAtom = atomWithQuery(() => ({
|
|
queryKey: cacheKeys.modelConnections.global(),
|
|
enabled: !!getBearerToken(),
|
|
staleTime: 10 * 60 * 1000,
|
|
queryFn: () => modelConnectionsApiService.getGlobalConnections(),
|
|
}));
|
|
|
|
export const globalLlmConfigStatusAtom = atomWithQuery(() => ({
|
|
queryKey: cacheKeys.modelConnections.globalConfigStatus(),
|
|
enabled: !!getBearerToken(),
|
|
staleTime: 60 * 60 * 1000,
|
|
queryFn: () => modelConnectionsApiService.getGlobalLlmConfigStatus(),
|
|
}));
|
|
|
|
export const modelProvidersAtom = atomWithQuery(() => ({
|
|
queryKey: cacheKeys.modelConnections.providers(),
|
|
enabled: !!getBearerToken(),
|
|
staleTime: 60 * 60 * 1000,
|
|
queryFn: () => modelConnectionsApiService.getModelProviders(),
|
|
}));
|
|
|
|
export const modelConnectionsAtom = atomWithQuery((get) => {
|
|
const searchSpaceId = Number(get(activeSearchSpaceIdAtom));
|
|
return {
|
|
queryKey: cacheKeys.modelConnections.all(searchSpaceId),
|
|
enabled: !!searchSpaceId,
|
|
staleTime: 5 * 60 * 1000,
|
|
queryFn: () => modelConnectionsApiService.getConnections(searchSpaceId),
|
|
};
|
|
});
|
|
|
|
export const modelRolesAtom = atomWithQuery((get) => {
|
|
const searchSpaceId = Number(get(activeSearchSpaceIdAtom));
|
|
return {
|
|
queryKey: cacheKeys.modelConnections.roles(searchSpaceId),
|
|
enabled: !!searchSpaceId,
|
|
staleTime: 5 * 60 * 1000,
|
|
queryFn: () => modelConnectionsApiService.getModelRoles(searchSpaceId),
|
|
};
|
|
});
|