mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-17 01:11:14 +03:00
Add parseAttachedEvent and prependAttachment helpers
This commit is contained in:
parent
c580cfff70
commit
13d66c5155
@ -192,6 +192,23 @@ export function getEventIdsFromSearchObjectsToolCalls(
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ATTACHED_EVENT_MARKER = /^\[attached_event:([A-Za-z0-9._-]+)\]\s*\n?/;
|
||||||
|
|
||||||
|
export function parseAttachedEvent(content: string): {
|
||||||
|
eventId: string | null;
|
||||||
|
body: string;
|
||||||
|
} {
|
||||||
|
if (!content) return { eventId: null, body: content };
|
||||||
|
const match = content.match(ATTACHED_EVENT_MARKER);
|
||||||
|
if (!match) return { eventId: null, body: content };
|
||||||
|
const body = content.slice(match[0].length).replace(/^\n+/, "");
|
||||||
|
return { eventId: match[1], body };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function prependAttachment(body: string, eventId: string): string {
|
||||||
|
return `[attached_event:${eventId}]\n\n${body}`;
|
||||||
|
}
|
||||||
|
|
||||||
export type FindSimilarObjectsResult = {
|
export type FindSimilarObjectsResult = {
|
||||||
anchor: { id: string } | null;
|
anchor: { id: string } | null;
|
||||||
results: { id: string; score?: number }[];
|
results: { id: string; score?: number }[];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user