Improve response extraction

This commit is contained in:
William Jeynes
2026-04-02 21:02:26 +01:00
parent 10f2644408
commit b37799b3d2
4 changed files with 33 additions and 8 deletions
+10 -2
View File
@@ -3,9 +3,17 @@ import { MessagesState } from "../state";
import { AIMessage, BaseMessage } from "@langchain/core/messages";
import { rankExampleTriggerEvents } from "../tools/retreiveExamples";
function extractTE(text: string) {
const match = text.match(/<norm>([\s\S]*?)<\/norm>/);
if (!match) throw new Error("Nothing found between <norm> tags");
return match[1].trim();
}
export const triggerEventSetup: GraphNode<typeof MessagesState> = async (state) => {
let nc = state?.messages?.at(-1)?.content ?? "" //keep a copy of normalized trigger event. Again two things, womp womp
let raw = state?.messages?.at(-1)?.content ?? "" //keep a copy of normalized trigger event. Again two things, womp womp
let nc = extractTE(raw.toString())
//Now give in-context examples. hopwfully we can self-teach?
let similarityResults = await rankExampleTriggerEvents(state.disinformationTitle)