Refactor: replace endpointsConfig recoil store with react query (#1085)

This commit is contained in:
Danny Avila 2023-10-21 13:50:29 -04:00 committed by GitHub
parent 7d6a1d260f
commit 4073b7d05d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 83 additions and 49 deletions

View file

@ -101,7 +101,7 @@ export const searchConversations = async (
return request.get(endpoints.search(q, pageNumber));
};
export const getAIEndpoints = () => {
export const getAIEndpoints = (): Promise<t.TEndpointsConfig> => {
return request.get(endpoints.aiEndpoints());
};

View file

@ -230,12 +230,19 @@ export const useGetSearchEnabledQuery = (
});
};
export const useGetEndpointsQuery = (): QueryObserverResult<t.TEndpointsConfig> => {
return useQuery([QueryKeys.endpoints], () => dataService.getAIEndpoints(), {
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
});
export const useGetEndpointsQuery = <TData = t.TEndpointsConfig>(
config?: UseQueryOptions<t.TEndpointsConfig, unknown, TData>,
): QueryObserverResult<TData> => {
return useQuery<t.TEndpointsConfig, unknown, TData>(
[QueryKeys.endpoints],
() => dataService.getAIEndpoints(),
{
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
...config,
},
);
};
export const useGetModelsQuery = (

View file

@ -120,7 +120,7 @@ export type TConfig = {
availableModels?: [];
userProvide?: boolean | null;
availableTools?: [];
plugins?: [];
plugins?: Record<string, string>;
azure?: boolean;
};