mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-22 10:16:13 +01:00
add RQ tokenizer
This commit is contained in:
parent
48e33fe1e9
commit
83df28f45d
4 changed files with 34 additions and 14 deletions
|
|
@ -60,3 +60,7 @@ export const searchConversations = async(q: string, pageNumber: string): Promise
|
|||
export const getAIEndpoints = () => {
|
||||
return request.get(endpoints.aiEndpoints());
|
||||
}
|
||||
|
||||
export const updateTokenCount = (text: string) => {
|
||||
return request.post(endpoints.tokenizer(), {arg: {text}});
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ export enum QueryKeys {
|
|||
endpoints = "endpoints",
|
||||
presets = "presets",
|
||||
searchResults = "searchResults",
|
||||
tokenCount = "tokenCount",
|
||||
}
|
||||
|
||||
export const useGetUserQuery = (): QueryObserverResult<t.TUser> => {
|
||||
|
|
@ -199,7 +200,6 @@ export const useSearchQuery = (
|
|||
pageNumber: string,
|
||||
config?: UseQueryOptions<t.TSearchResults>
|
||||
): QueryObserverResult<t.TSearchResults> => {
|
||||
console.log('useSearchFetcher', searchQuery, pageNumber)
|
||||
return useQuery<t.TSearchResults>([QueryKeys.searchResults, pageNumber, searchQuery], () =>
|
||||
dataService.searchConversations(searchQuery, pageNumber), {
|
||||
refetchOnWindowFocus: false,
|
||||
|
|
@ -208,4 +208,17 @@ export const useSearchQuery = (
|
|||
...config
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const useUpdateTokenCountMutation = (): UseMutationResult<t.TUpdateTokenCountResponse, unknown, string, unknown> => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation(
|
||||
(text: string) =>
|
||||
dataService.updateTokenCount(text),
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries([QueryKeys.tokenCount]);
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -139,4 +139,8 @@ export type TEndpoints = {
|
|||
OpenAI: {
|
||||
availableModels: []
|
||||
}
|
||||
};
|
||||
|
||||
export type TUpdateTokenCountResponse = {
|
||||
count: number,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue