mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 13:23:15 +00:00
Centralize use of useUserConfig and use that to retrieve default model and chat model options
This commit is contained in:
@@ -90,15 +90,16 @@ export interface UserConfig {
|
||||
export function useUserConfig(detailed: boolean = false) {
|
||||
const url = `/api/settings?detailed=${detailed}`;
|
||||
const {
|
||||
data: userConfig,
|
||||
data,
|
||||
error,
|
||||
isLoading: isLoadingUserConfig,
|
||||
isLoading,
|
||||
} = useSWR<UserConfig>(url, fetcher, { revalidateOnFocus: false });
|
||||
|
||||
if (error || !userConfig || userConfig?.detail === "Forbidden")
|
||||
return { userConfig: null, isLoadingUserConfig };
|
||||
if (error || !data || data?.detail === "Forbidden") {
|
||||
return { data: null, error, isLoading };
|
||||
}
|
||||
|
||||
return { userConfig, isLoadingUserConfig };
|
||||
return { data, error, isLoading };
|
||||
}
|
||||
|
||||
export function useChatModelOptions() {
|
||||
|
||||
Reference in New Issue
Block a user