feat(open-webui): voice messages, fix camera capture and full notes
- Voice messages: record from the microphone and transcribe to the input via Open WebUI's /api/v1/audio/transcriptions (mic button in composer). - Camera capture: attach the stream via a ref callback so the preview is no longer a black frame (the ref could be read before the video mounted). - Notes: fetch the full note body on attach. The list endpoint truncates content to 1000 chars, so attached notes were cut off; getNote returns the complete markdown.
This commit is contained in:
1 parent
d74728c28d
commit
46454cc0f0
7 files changed
+189
-19
No files matched your search
@@ -28,7 +28,9 @@ import {
|
||||
openWebUiKnowledgeListSchema,
|
||||
openWebUiModelsResponseSchema,
|
||||
openWebUiNoteListSchema,
|
||||
openWebUiNoteSchema,
|
||||
openWebUiProcessWebResponseSchema,
|
||||
openWebUiTranscriptionSchema,
|
||||
openWebUiUploadedFileSchema,
|
||||
} from "./open-webui-types";
|
||||
|
||||
@@ -132,6 +134,43 @@ export class OpenWebUiIntegration extends Integration {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single note including its full markdown content. The list endpoint
|
||||
* truncates the body, so we fetch the note directly when attaching it.
|
||||
*/
|
||||
public async getNoteAsync(noteId: string): Promise<OpenWebUiNote> {
|
||||
const response = await fetchWithTrustedCertificatesAsync(this.url(`/api/v1/notes/${noteId}`), {
|
||||
headers: this.getAuthHeaders(),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new ResponseError(response);
|
||||
}
|
||||
|
||||
const parsed = openWebUiNoteSchema.parse(await response.json());
|
||||
return { id: parsed.id, title: parsed.title ?? "Untitled note", content: parsed.data?.content?.md ?? "" };
|
||||
}
|
||||
|
||||
/**
|
||||
* Transcribe recorded audio to text (speech-to-text) for voice messages.
|
||||
*/
|
||||
public async transcribeAudioAsync(filename: string, base64Content: string, contentType: string): Promise<string> {
|
||||
const form = new FormData();
|
||||
form.append("file", new Blob([Buffer.from(base64Content, "base64")], { type: contentType }), filename);
|
||||
|
||||
const response = await fetchWithTrustedCertificatesAsync(this.url("/api/v1/audio/transcriptions"), {
|
||||
method: "POST",
|
||||
headers: this.getAuthHeaders(),
|
||||
body: form,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new ResponseError(response);
|
||||
}
|
||||
|
||||
return openWebUiTranscriptionSchema.parse(await response.json()).text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file to Open WebUI so it can be retrieved from later. Returns the
|
||||
* new file id (its vector collection is `file-{id}`).
|
||||
|
||||
@@ -135,6 +135,9 @@ export interface OpenWebUiNote {
|
||||
content: string;
|
||||
}
|
||||
|
||||
// POST /api/v1/audio/transcriptions — speech-to-text result.
|
||||
export const openWebUiTranscriptionSchema = z.object({ text: z.string() });
|
||||
|
||||
// A file flattened for the widget: id and a display name.
|
||||
export interface OpenWebUiFileSummary {
|
||||
id: string;
|
||||
|
||||
Reference in new issue
Block a user