Download src/lib/api/chatHistory.ts from asnannp/DocDoeAI: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/spaces/asnannp/DocDoeAI/resolve/main/src/lib/api/chatHistory.ts
- Command line
-
hf download hf://spaces/asnannp/DocDoeAI/src/lib/api/chatHistory.ts
-
curl -L -o chatHistory.ts https://huggingface.co/spaces/asnannp/DocDoeAI/resolve/main/src/lib/api/chatHistory.ts
2.17 kB
| import { apiDelete, apiGet, apiPost } from "@/lib/api/client"; | |
| import type { | |
| StudyChatAcademicContext, | |
| StudyChatEvidence, | |
| StudyChatMode, | |
| WebSource, | |
| } from "@/lib/api/chat"; | |
| export type ChatSessionOut = { | |
| id: string; | |
| source_id: string | null; | |
| subject: string; | |
| title: string; | |
| context_data: StudyChatAcademicContext | null; | |
| active_source_ids: string[]; | |
| mode: StudyChatMode; | |
| message_count: number; | |
| created_at: string; | |
| updated_at: string; | |
| }; | |
| export type ChatMessageOut = { | |
| id: string; | |
| role: "user" | "assistant"; | |
| content: string; | |
| intent: string | null; | |
| evidence_label?: string | null; | |
| client_turn_id?: string | null; | |
| web_sources?: WebSource[]; | |
| evidence?: StudyChatEvidence | null; | |
| created_at: string; | |
| }; | |
| export type ChatSessionDetail = { | |
| id: string; | |
| source_id: string | null; | |
| subject: string; | |
| title: string; | |
| context_data: StudyChatAcademicContext | null; | |
| active_source_ids: string[]; | |
| mode: StudyChatMode; | |
| messages: ChatMessageOut[]; | |
| created_at: string; | |
| updated_at: string; | |
| }; | |
| export function listChatSessions(sourceId?: string | null) { | |
| const query = sourceId ? `?source_id=${encodeURIComponent(sourceId)}` : ""; | |
| return apiGet<ChatSessionOut[]>(`/chat/sessions${query}`); | |
| } | |
| export function getChatSession(sessionId: string) { | |
| return apiGet<ChatSessionDetail>(`/chat/sessions/${sessionId}`); | |
| } | |
| export function createChatSession(body: { | |
| source_id?: string | null; | |
| subject?: string; | |
| title?: string; | |
| context_data?: StudyChatAcademicContext | null; | |
| active_source_ids?: string[]; | |
| mode?: StudyChatMode; | |
| }) { | |
| return apiPost<ChatSessionOut, typeof body>("/chat/sessions", body); | |
| } | |
| export function appendChatMessages( | |
| sessionId: string, | |
| body: { | |
| user_content: string; | |
| assistant_content: string; | |
| client_turn_id?: string; | |
| intent?: string; | |
| evidence_label?: string | null; | |
| web_sources?: WebSource[]; | |
| evidence?: StudyChatEvidence | null; | |
| }, | |
| ) { | |
| return apiPost<ChatMessageOut[], typeof body>( | |
| `/chat/sessions/${sessionId}/messages`, | |
| body, | |
| ); | |
| } | |
| export function deleteChatSession(sessionId: string) { | |
| return apiDelete(`/chat/sessions/${sessionId}`); | |
| } | |