diff --git a/examples/rag/langgraph_agentic_rag.ipynb b/examples/rag/langgraph_agentic_rag.ipynb index 070a02cc..cf1a04e2 100644 --- a/examples/rag/langgraph_agentic_rag.ipynb +++ b/examples/rag/langgraph_agentic_rag.ipynb @@ -414,10 +414,21 @@ "metadata": {}, "outputs": [], "source": [ - "import { MessageGraph } from \"@langchain/langgraph\";\n", + "import { StateGraph } from \"@langchain/langgraph\";\n", + "// Define the top-level State interface\n", + "interface State {\n", + " messages: BaseMessage[];\n", + "}\n", "\n", - "// Define a new graph\n", - "const workflow = new MessageGraph()\n", + "// Define the graph\n", + "const workflow = new StateGraph({\n", + " channels: {\n", + " messages: {\n", + " value: (x: BaseMessage[], y: BaseMessage[]) => x.concat(y),\n", + " default: () => [],\n", + " },\n", + " },\n", + "})\n", " // Define the nodes which we'll cycle between.\n", " .addNode(\"agent\", agent)\n", " .addNode(\"retrieve\", retrieve)\n", diff --git a/examples/reflection/reflection.ipynb b/examples/reflection/reflection.ipynb index 733a7b2c..c11650e9 100644 --- a/examples/reflection/reflection.ipynb +++ b/examples/reflection/reflection.ipynb @@ -758,7 +758,7 @@ "metadata": {}, "outputs": [], "source": [ - "import { END, MemorySaver, MessageGraph, START } from \"@langchain/langgraph\";\n", + "import { END, MemorySaver, StateGraph, START } from \"@langchain/langgraph\";\n", "\n", "const generationNode = async (messages: BaseMessage[]) => {\n", " return [await essayGenerationChain.invoke({ messages })];\n", @@ -782,8 +782,20 @@ " return [new HumanMessage({ content: res.content })];\n", "};\n", "\n", + "// Define the top-level State interface\n", + "interface State {\n", + " messages: BaseMessage[];\n", + "}\n", + "\n", "// Define the graph\n", - "const workflow = new MessageGraph()\n", + "const workflow = new StateGraph({\n", + " channels: {\n", + " messages: {\n", + " value: (x: BaseMessage[], y: BaseMessage[]) => x.concat(y),\n", + " default: () => [],\n", + " },\n", + " },\n", + "})\n", " .addNode(\"generate\", generationNode)\n", " .addNode(\"reflect\", reflectionNode)\n", " .addEdge(START, \"generate\");\n",