summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib/api.ts
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2025-12-23 14:43:23 +0000
committersoryu <soryu@soryu.co>2025-12-23 14:47:18 +0000
commit555061b179b8ec034cb70f9a2dd6c823ced0f637 (patch)
tree0545b4395dab6d957884d8d36bf15b8da529dc1f /makima/frontend/src/lib/api.ts
parenta32dc56d2e5447ef8988cb98b8686476cc94e70c (diff)
downloadsoryu-555061b179b8ec034cb70f9a2dd6c823ced0f637.tar.gz
soryu-555061b179b8ec034cb70f9a2dd6c823ced0f637.zip
Add file body and initial tool call system
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
-rw-r--r--makima/frontend/src/lib/api.ts57
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();
+}