feat(archive): rich metadata in semantic search — username/channel/guild context + guild filter
Archive payload now stores username, channel_id, guild_id, thread_id and the real message created_at (not embed time). Backend searchArray accepts an optional guildId and applies a Qdrant payload filter so results can be scoped to the guild being viewed. API/frontend expose the new fields and the semantic results card shows who said it, in which channel, and when — turning bare text blobs into contextual results. Old points fall back to analyzed_at and omit the new fields gracefully.
This commit is contained in:
1 parent
c704fbf7a5
commit
26a690943d
8 files changed
+84
-8
No files matched your search
@@ -37,6 +37,14 @@ export interface QdrantVerdictPayload {
|
||||
/** Bare content hash (16 hex chars) — enables content-based invalidation
|
||||
* regardless of the (context-scoped) point id. */
|
||||
content_hash?: string;
|
||||
// Archive metadata (archiveEmbedder writes these; moderation cache doesn't).
|
||||
// Optional so the same payload shape serves both the moderation cache
|
||||
// collection and the public message archive collection.
|
||||
username?: string;
|
||||
channel_id?: string;
|
||||
guild_id?: string;
|
||||
thread_id?: string | null;
|
||||
created_at?: number;
|
||||
}
|
||||
|
||||
function baseUrl(): string {
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface ArchiveMessage {
|
||||
username: string;
|
||||
channel_id: string;
|
||||
guild_id: string;
|
||||
thread_id: string | null;
|
||||
created_at: number;
|
||||
/** True when the message came from an age-restricted (NSFW) channel. NSFW
|
||||
* content is deliberately NOT embedded into the public archive so it can't
|
||||
@@ -58,6 +59,13 @@ export function archiveMessageEmbedded(message: ArchiveMessage): void {
|
||||
{
|
||||
text: normalized.slice(0, 4000),
|
||||
flags: "",
|
||||
// Rich metadata so public semantic search results can be shown in
|
||||
// context (who said it, where, when) instead of a bare text blob.
|
||||
username: message.username ?? "",
|
||||
channel_id: message.channel_id ?? "",
|
||||
guild_id: message.guild_id ?? "",
|
||||
thread_id: message.thread_id ?? null,
|
||||
created_at: message.created_at ?? Date.now(),
|
||||
analyzed_at: Date.now(),
|
||||
// 5-year persistent window (archive is NOT a TTL cache).
|
||||
expires_at: Date.now() + 1000 * 60 * 60 * 24 * 365 * 5,
|
||||
|
||||
Reference in new issue
Block a user