mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-29 14:48:51 +01:00
feat: add data-service layer
This commit is contained in:
parent
fb89f60470
commit
30e1b421ba
3 changed files with 22 additions and 0 deletions
|
|
@ -66,6 +66,9 @@ export const messages = (params: q.MessagesListParams) => {
|
|||
|
||||
export const messagesArtifacts = (messageId: string) => `${messagesRoot}/artifacts/${messageId}`;
|
||||
|
||||
export const conversationCosts = (conversationId: string) =>
|
||||
`/api/messages/${conversationId}/costs`;
|
||||
|
||||
const shareRoot = `${BASE_URL}/api/share`;
|
||||
export const shareMessages = (shareId: string) => `${shareRoot}/${shareId}`;
|
||||
export const getSharedLink = (conversationId: string) => `${shareRoot}/link/${conversationId}`;
|
||||
|
|
|
|||
|
|
@ -697,6 +697,10 @@ export function getMessagesByConvoId(conversationId: string): Promise<s.TMessage
|
|||
return request.get(endpoints.messages({ conversationId }));
|
||||
}
|
||||
|
||||
export function getConversationCosts(conversationId: string): Promise<t.TConversationCosts> {
|
||||
return request.get(endpoints.conversationCosts(conversationId));
|
||||
}
|
||||
|
||||
export function getPrompt(id: string): Promise<{ prompt: t.TPrompt }> {
|
||||
return request.get(endpoints.getPrompt(id));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -653,3 +653,18 @@ export type TBalanceResponse = {
|
|||
lastRefill?: Date;
|
||||
refillAmount?: number;
|
||||
};
|
||||
|
||||
export 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;
|
||||
}>;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue