implement components
This commit is contained in:
@@ -1,21 +1,14 @@
|
||||
import { END, START, StateGraph } from "@langchain/langgraph";
|
||||
import { OpenCodeAnnotation, OpenCodeState } from "./types";
|
||||
import { OpenCodeAnnotation } from "./types";
|
||||
import { planner } from "./nodes/planner";
|
||||
import { interrupt } from "./nodes/interrupt";
|
||||
import { executor } from "./nodes/executor";
|
||||
|
||||
function handleRoutingFromExecutor(state: OpenCodeState): "executor" | "interrupt" {
|
||||
const lastAIMessage = state.messages.findLast((m) => m.getType() === "ai");
|
||||
if (lastAIMessage)
|
||||
}
|
||||
|
||||
function handleRoutingFromInterrupt(state: OpenCodeState): "executor" | typeof END {}
|
||||
|
||||
const workflow = new StateGraph(OpenCodeAnnotation)
|
||||
.addNode("planner", planner)
|
||||
.addNode("executor", executor)
|
||||
.addNode("interrupt", interrupt)
|
||||
.addEdge(START, "planner")
|
||||
.addEdge("planner", "executor")
|
||||
.addConditionalEdges("executor", handleRoutingFromExecutor, ["executor", "interrupt"])
|
||||
.addConditionalEdges("interrupt", handleRoutingFromInterrupt, ["executor", END])
|
||||
.addEdge("executor", END);
|
||||
|
||||
export const graph = workflow.compile();
|
||||
graph.name = "Open Code Graph";
|
||||
|
||||
Reference in New Issue
Block a user