Files
Tat Dat Duong 2b729b47c2 Add CLI
2025-01-21 02:53:12 +01:00

18 lines
487 B
TypeScript

import { StateGraph, START } from "@langchain/langgraph";
import { MessagesAnnotation } from "@langchain/langgraph";
class CustomError extends Error {
constructor(message: string) {
super(message);
this.name = "CustomError";
}
}
export const graph = new StateGraph(MessagesAnnotation)
.addNode("error_node", async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
throw new CustomError("Boo!");
})
.addEdge(START, "error_node")
.compile();