start adding dummy nodes
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import { GraphNode } from "@langchain/langgraph";
|
||||
import { MessagesState } from "../state";
|
||||
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
||||
|
||||
export const dummyNormalisationModel: GraphNode<typeof MessagesState> = async (state) => {
|
||||
//TODO: call AI model with collected data
|
||||
|
||||
return {
|
||||
messages: [ new AIMessage(state.messages.at(-1)?.content + " Processed")]
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { GraphNode } from "@langchain/langgraph";
|
||||
import { MessagesState } from "../state";
|
||||
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
||||
|
||||
export const dummyRagasMetrics: GraphNode<typeof MessagesState> = async (state) => {
|
||||
//TODO: get ragas metrics
|
||||
|
||||
return {
|
||||
messages: [ new AIMessage("RAGASSED : " + state.messages.at(-1)?.content)]
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { GraphNode } from "@langchain/langgraph";
|
||||
import { MessagesState } from "../state";
|
||||
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
||||
|
||||
export const dummyTriggerEventModel: GraphNode<typeof MessagesState> = async (state) => {
|
||||
//TODO: call AI model with collected data
|
||||
|
||||
return {
|
||||
messages: [ new AIMessage("Trigger events of: " + state.messages.at(-1)?.content)]
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { GraphNode } from "@langchain/langgraph";
|
||||
import { MessagesState } from "../state";
|
||||
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
||||
|
||||
export const dummyVerificationModel: GraphNode<typeof MessagesState> = async (state) => {
|
||||
//TODO: call AI model with collected data
|
||||
|
||||
return {
|
||||
messages: [ new AIMessage("Verified : " + state.messages.at(-1)?.content)]
|
||||
};
|
||||
};
|
||||
+21
-18
@@ -1,21 +1,24 @@
|
||||
import { task, entrypoint } from "@langchain/langgraph";
|
||||
import { BaseMessage, SystemMessage } from "@langchain/core/messages";
|
||||
import { ChatOpenAI } from "@langchain/openai"
|
||||
import { arithmeticTools } from "../tools/arithmetic";
|
||||
// import { SystemMessage } from "@langchain/core/messages";
|
||||
// import { GraphNode } from "@langchain/langgraph";
|
||||
// import { MessagesState } from "../state";
|
||||
// import { arithmeticTools } from "../tools/arithmetic";
|
||||
// import { ChatOpenAI } from "@langchain/openai"
|
||||
|
||||
const model = new ChatOpenAI({
|
||||
model: "gpt-5-mini"
|
||||
});
|
||||
// const model = new ChatOpenAI({
|
||||
// model: "gpt-5-mini"
|
||||
// });
|
||||
|
||||
const modelWithTools = model.bindTools(arithmeticTools);
|
||||
// const modelWithTools = model.bindTools(arithmeticTools);
|
||||
|
||||
export const modelNode = task({ name: "callLlm" }, async (messages: BaseMessage[]) => {
|
||||
|
||||
|
||||
return modelWithTools.invoke([
|
||||
new SystemMessage(
|
||||
"You are a helpful assistant tasked with performing arithmetic on a set of inputs."
|
||||
),
|
||||
...messages,
|
||||
]);
|
||||
});
|
||||
// export const llmCall: GraphNode<typeof MessagesState> = async (state) => {
|
||||
// const response = await modelWithTools.invoke([
|
||||
// new SystemMessage(
|
||||
// "You are a helpful assistant tasked with performing arithmetic on a set of inputs. Any calculation, no matter how trivial, should be done with tools. Output the final answer with %%% on each side"
|
||||
// ),
|
||||
// ...state.messages,
|
||||
// ]);
|
||||
// return {
|
||||
// messages: [response],
|
||||
// llmCalls: 1,
|
||||
// };
|
||||
// };
|
||||
@@ -0,0 +1,9 @@
|
||||
import { GraphNode } from "@langchain/langgraph";
|
||||
import { MessagesState } from "../state";
|
||||
import { HumanMessage } from "@langchain/core/messages";
|
||||
|
||||
export const normalizationSetup: GraphNode<typeof MessagesState> = async (state) => {
|
||||
//TODO: Implement claim normalisation, using few shot prompting and CLAN Dataset
|
||||
|
||||
return { messages: [ new HumanMessage(state.disinformationTitle)] };
|
||||
};
|
||||
+23
-6
@@ -1,8 +1,25 @@
|
||||
import type { ToolCall } from "@langchain/core/messages/tool";
|
||||
import { task } from "@langchain/langgraph";
|
||||
import { AIMessage, ToolMessage } from "@langchain/core/messages";
|
||||
import { GraphNode } from "@langchain/langgraph";
|
||||
import { MessagesState } from "../state";
|
||||
import { arithmeticToolsByName } from "../tools/arithmetic";
|
||||
|
||||
export const toolNode = task({ name: "callTool" }, async (toolCall: ToolCall) => {
|
||||
const tool = arithmeticToolsByName[toolCall.name];
|
||||
return tool.invoke(toolCall);
|
||||
});
|
||||
export const toolNode: GraphNode<typeof MessagesState> = async (state) => {
|
||||
const lastMessage = state.messages.at(-1);
|
||||
|
||||
//STARTTEMP
|
||||
return {messages: [new AIMessage("yeman")]}
|
||||
//ENDTEMP
|
||||
|
||||
if (lastMessage == null || !AIMessage.isInstance(lastMessage)) {
|
||||
return { messages: [] };
|
||||
}
|
||||
|
||||
const result: ToolMessage[] = [];
|
||||
for (const toolCall of lastMessage.tool_calls ?? []) {
|
||||
const tool = arithmeticToolsByName[toolCall.name];
|
||||
const observation = await tool.invoke(toolCall);
|
||||
result.push(observation);
|
||||
}
|
||||
|
||||
return { messages: result };
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { GraphNode } from "@langchain/langgraph";
|
||||
import { MessagesState } from "../state";
|
||||
import { HumanMessage } from "@langchain/core/messages";
|
||||
|
||||
export const verificationSetup: GraphNode<typeof MessagesState> = async (state) => {
|
||||
//TODO: this might not be needed, looks nice on the graph tho
|
||||
|
||||
return { messages: [ new HumanMessage(state.messages.at(-1)?.content ?? "undefined")] };
|
||||
};
|
||||
Reference in New Issue
Block a user