Implement RAGAS metrics

This commit is contained in:
William Jeynes
2026-02-12 22:52:22 +00:00
parent 6dd6bf7eaf
commit c89f73e138
6 changed files with 24 additions and 21 deletions
+18
View File
@@ -0,0 +1,18 @@
import { GraphNode } from "@langchain/langgraph";
import { MessagesState } from "../state";
import { AIMessage, HumanMessage } from "@langchain/core/messages";
import { evaluateWithRagas } from "../tools/ragasCall";
export const ragasMetrics: GraphNode<typeof MessagesState> = async (state) => {
const question = "A possible trigger event for: " + state.disinformationTitle //Should it be raw, or normalized?
const answer = state.proposedTriggerEvent[state.proposedTriggerEventIndex].Event
const contexts = state.proposedTriggerEvent[state.proposedTriggerEventIndex].context?.split("^^^") ?? []
console.log(contexts)
const results = await evaluateWithRagas({question, answer, contexts})
return {
messages: [ new AIMessage("RAGAS:" + results.faithfulness)]
};
};