Implement RAGAS metrics
This commit is contained in:
@@ -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)]
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user