MCPcopy
hub / github.com/OpenBMB/UltraRAG / exportChatDocx

Function exportChatDocx

ui/frontend/src/shared/api/chat.ts:78–109  ·  view source on GitHub ↗
(payload: ExportChatDocxPayload)

Source from the content-addressed store, hash-verified

76}
77
78export async function exportChatDocx(payload: ExportChatDocxPayload): Promise<{
79 blob: Blob;
80 filename: string;
81}> {
82 const response = await fetch(buildApiUrl("/api/chat/export/docx"), {
83 method: "POST",
84 credentials: "include",
85 headers: {
86 "Content-Type": "application/json",
87 },
88 body: JSON.stringify({
89 text: payload.text,
90 question: payload.question ?? "",
91 sources: payload.sources ?? [],
92 }),
93 });
94 if (!response.ok) {
95 let message = response.statusText || "Export docx failed";
96 try {
97 const json = (await response.json()) as { error?: string };
98 message = json.error ?? message;
99 } catch {
100 // no-op
101 }
102 throw new Error(message);
103 }
104 const blob = await response.blob();
105 return {
106 blob,
107 filename: parseFilename(response.headers.get("Content-Disposition")),
108 };
109}

Callers 1

handleExportDocxFunction · 0.90

Calls 3

buildApiUrlFunction · 0.90
parseFilenameFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected