feat: add multimodal analysis support to LLM moderation client by processing image attachments

This commit is contained in:
MythEclipse
2026-05-17 23:56:04 +07:00
parent 059d569566
commit 51dc1f8869
21 changed files with 443 additions and 83 deletions
+35 -1
View File
@@ -1,4 +1,14 @@
import { and, asc, desc, eq, isNull, or, type SQL, sql } from "drizzle-orm";
import {
and,
asc,
desc,
eq,
inArray,
isNull,
or,
type SQL,
sql,
} from "drizzle-orm";
import { getDatabase } from "../database/drizzle.ts";
import { attachmentsTable, messagesTable } from "../database/schema.ts";
import { createChildLogger } from "../logger.ts";
@@ -605,3 +615,27 @@ export async function getPendingConversationKeys(
throw error;
}
}
export async function getAttachmentsForMessages(
messageIds: string[],
): Promise<AttachmentRecord[]> {
try {
if (messageIds.length === 0) return [];
const database = db();
const rows = await database
.select()
.from(attachmentsTable)
.where(inArray(attachmentsTable.message_id, messageIds));
return rows as AttachmentRecord[];
} catch (error) {
logger.error(
{
messageIds,
error: error instanceof Error ? error.message : String(error),
},
"Failed to get attachments for messages",
);
throw error;
}
}