Skip to content

Commit

Permalink
langgraph[patch]: Fix typing for conditional edge array route maps (#408
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jacoblee93 authored Aug 28, 2024
1 parent 4298a20 commit eae2321
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libs/langgraph/src/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const END = "__end__";
export interface BranchOptions<IO, N extends string> {
source: N;
path: Branch<IO, N>["condition"];
pathMap?: Record<string, N | typeof END> | N[];
pathMap?: Record<string, N | typeof END> | (N | typeof END)[];
}

export class Branch<IO, N extends string> {
Expand Down
14 changes: 4 additions & 10 deletions libs/langgraph/src/tests/pregel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2036,9 +2036,9 @@ describe("StateGraph", () => {
data: typeof AgentAnnotation.State
): Promise<string> => {
if (data.agentOutcome && "returnValues" in data.agentOutcome) {
return "exit";
return "__end__";
}
return "continue";
return "tools";
};

it("can invoke", async () => {
Expand Down Expand Up @@ -2088,10 +2088,7 @@ describe("StateGraph", () => {
.addNode("tools", executeTools)
.addEdge(START, "agent")
.addEdge("agent", "passthrough")
.addConditionalEdges("passthrough", shouldContinue, {
continue: "tools",
exit: END,
})
.addConditionalEdges("passthrough", shouldContinue, ["tools", "__end__"])
.addEdge("tools", "agent")
.compile();

Expand Down Expand Up @@ -2182,10 +2179,7 @@ describe("StateGraph", () => {
.addNode("agent", agent)
.addNode("tools", executeTools)
.addEdge(START, "agent")
.addConditionalEdges("agent", shouldContinue, {
continue: "tools",
exit: END,
})
.addConditionalEdges("agent", shouldContinue, ["tools", "__end__"])
.addEdge("tools", "agent")
.compile();

Expand Down

0 comments on commit eae2321

Please sign in to comment.