mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-25 19:56:13 +01:00
refactor: swap conversationCosts query hooks out for new modelCosts query and move to react-query-service
This commit is contained in:
parent
4fb9d7bdff
commit
95ebef13df
2 changed files with 17 additions and 33 deletions
|
|
@ -32,20 +32,6 @@ import type {
|
|||
} from 'librechat-data-provider';
|
||||
import type { ConversationCursorData } from '~/utils/convos';
|
||||
import { findConversationInInfinite } from '~/utils';
|
||||
type TConversationCosts = {
|
||||
conversationId: string;
|
||||
totals: {
|
||||
prompt: { usd: number; tokenCount: number };
|
||||
completion: { usd: number; tokenCount: number };
|
||||
total: { usd: number; tokenCount: number };
|
||||
};
|
||||
perMessage: Array<{
|
||||
messageId: string;
|
||||
tokenType: 'prompt' | 'completion';
|
||||
tokenCount: number;
|
||||
usd: number;
|
||||
}>;
|
||||
};
|
||||
|
||||
export const useGetPresetsQuery = (
|
||||
config?: UseQueryOptions<TPreset[]>,
|
||||
|
|
@ -90,25 +76,6 @@ export const useGetConvoIdQuery = (
|
|||
);
|
||||
};
|
||||
|
||||
export const useGetConversationCosts = (
|
||||
conversationId: string,
|
||||
config?: UseQueryOptions<TConversationCosts>,
|
||||
): QueryObserverResult<TConversationCosts> => {
|
||||
return useQuery<TConversationCosts>(
|
||||
[QueryKeys.conversation, conversationId, 'costs'],
|
||||
() => {
|
||||
return dataService.getConversationCosts(conversationId) as unknown as TConversationCosts;
|
||||
},
|
||||
{
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
refetchOnMount: false,
|
||||
enabled: !!conversationId && conversationId !== 'new',
|
||||
...config,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const useConversationsInfiniteQuery = (
|
||||
params: ConversationListParams,
|
||||
config?: UseInfiniteQueryOptions<ConversationListResponse, unknown>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue