feat: add data-service layer

This commit is contained in:
Dustin Healy 2025-08-09 10:27:28 -07:00
parent fb89f60470
commit 30e1b421ba
3 changed files with 22 additions and 0 deletions

View file

@ -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}`;

View file

@ -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));
}

View file

@ -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;
}>;
};