feat: refactor whole bunch of stuff
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { transcribe } from "@lib/openai.ts";
|
||||
import { createDocument } from "@lib/documents.ts";
|
||||
import { createResource } from "@lib/marka/index.ts";
|
||||
import { createLogger } from "./log/index.ts";
|
||||
import { convertOggToMp3 } from "./helpers.ts";
|
||||
|
||||
@@ -48,9 +48,8 @@ export async function endTask(chatId: string): Promise<string | null> {
|
||||
finalNote += "**[Voice message could not be transcribed]**\n\n";
|
||||
}
|
||||
} else if (entry.type === "photo") {
|
||||
const photoUrl = `${
|
||||
task.noteName.replace(/\.md$/, "")
|
||||
}/photo-${photoIndex++}.jpg`;
|
||||
const photoUrl = `${task.noteName.replace(/\.md$/, "")
|
||||
}/photo-${photoIndex++}.jpg`;
|
||||
|
||||
finalNote += `**Photo**:\n ${photoUrl}\n\n`;
|
||||
photoTasks.push({
|
||||
@@ -62,13 +61,13 @@ export async function endTask(chatId: string): Promise<string | null> {
|
||||
|
||||
try {
|
||||
for (const entry of photoTasks) {
|
||||
await createDocument(entry.path, entry.content, "image/jpeg");
|
||||
await createResource(entry.path, entry.content);
|
||||
}
|
||||
} catch (err) {
|
||||
log.error("Error creating photo document:", err);
|
||||
}
|
||||
try {
|
||||
await createDocument(task.noteName, finalNote, "text/markdown");
|
||||
await createResource(task.noteName, finalNote);
|
||||
} catch (error) {
|
||||
log.error("Error creating document:", error);
|
||||
return error instanceof Error
|
||||
|
||||
Reference in New Issue
Block a user