diff options
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index ec596ce..5ef9c22 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -49,6 +49,22 @@ export interface TranscriptEntry { isFinal: boolean; } +// Chart types for visualization +export type ChartType = "line" | "bar" | "pie" | "area"; + +// Body element types for structured content +export type BodyElement = + | { type: "heading"; level: number; text: string } + | { type: "paragraph"; text: string } + | { + type: "chart"; + chartType: ChartType; + title?: string; + data: Record<string, unknown>[]; + config?: Record<string, unknown>; + } + | { type: "image"; src: string; alt?: string; caption?: string }; + export interface FileSummary { id: string; name: string; @@ -66,6 +82,8 @@ export interface FileDetail { description: string | null; transcript: TranscriptEntry[]; location: string | null; + summary: string | null; + body: BodyElement[]; createdAt: string; updatedAt: string; } @@ -86,6 +104,28 @@ export interface UpdateFileRequest { name?: string; description?: string; transcript?: TranscriptEntry[]; + summary?: string; + body?: BodyElement[]; +} + +// Chat API types +export interface ChatRequest { + message: string; +} + +export interface ToolCallInfo { + name: string; + result: { + success: boolean; + message: string; + }; +} + +export interface ChatResponse { + response: string; + toolCalls: ToolCallInfo[]; + updatedBody: BodyElement[]; + updatedSummary: string | null; } // File API functions @@ -140,3 +180,20 @@ export async function deleteFile(id: string): Promise<void> { throw new Error(`Failed to delete file: ${res.statusText}`); } } + +// Chat API function +export async function chatWithFile( + id: string, + message: string +): Promise<ChatResponse> { + const res = await fetch(`${API_BASE}/api/v1/files/${id}/chat`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ message }), + }); + if (!res.ok) { + const errorText = await res.text(); + throw new Error(`Chat failed: ${errorText || res.statusText}`); + } + return res.json(); +} |
