DOC: Example llm-compiler #21

Closed
opened 2026-02-20 17:22:39 -05:00 by yindo · 1 comment
Owner

Originally created by @Siafu on GitHub (Feb 15, 2024).

Issue with current documentation:

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.

Example Code

from typing import List
from langgraph.graph import MessageGraph, END
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage

from codegen.agent_runtime.llm_compiler.joiner import joiner
from codegen.agent_runtime.llm_compiler.task import plan_and_schedule

graph_builder = MessageGraph()

# 1.  Define vertices
# We defined plan_and_schedule above already
# Assign each node to a state variable to update
graph_builder.add_node("plan_and_schedule", plan_and_schedule)
graph_builder.add_node("join", joiner)


# Define edges
graph_builder.add_edge("plan_and_schedule", "join")

# This condition determines looping logic


def should_continue(state: List[BaseMessage]):
    if isinstance(state[-1], AIMessage):
        return END
    return "plan_and_schedule"


graph_builder.add_conditional_edges(
    start_key="join",
    # Next, we pass in the function that will determine which node is called next.
    condition=should_continue,
)
graph_builder.set_entry_point("plan_and_schedule")
chain = graph_builder.compile()
steps = chain.stream(
    [
        HumanMessage(
            content="What's the oldest parrot alive, and how much longer is that than the average?"
        )
    ],
    {
        "recursion_limit": 100,
    },
)
for step in steps:
    print(step)
    print("---")

Error Message and Stack Trace

<module>
    graph_builder.add_conditional_edges(
TypeError: Graph.add_conditional_edges() missing 1 required positional argument: 'conditional_edge_mapping'

System Info

python = ">=3.10,<4.0.0"
tenacity = "^8.2.3"
langgraph = "^0.0.20"
langchain = "^0.1.4"
beautifulsoup4 = "^4.12.2"
docker = "^6.1.3"
langchain-community = "^0.0.17"
llama-cpp-python = "^0.2.38"
gpt4all = "^2.1.0"
gguf = "^0.6.0"
boto3 = "^1.34.34"
langchain-openai = "^0.0.5"
gitpython = "^3.1.41"
qdrant-client = "^1.7.3"
langchain-experimental = "^0.0.50"
langchainhub = "^0.1.14"

Idea or request for content:

No response

Originally created by @Siafu on GitHub (Feb 15, 2024). ### Issue with current documentation: Checked other resources - [x] I added a very descriptive title to this issue. - [x] I searched the LangChain documentation with the integrated search. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in LangChain rather than my code. Example Code ``` from typing import List from langgraph.graph import MessageGraph, END from langchain_core.messages import AIMessage, BaseMessage, HumanMessage from codegen.agent_runtime.llm_compiler.joiner import joiner from codegen.agent_runtime.llm_compiler.task import plan_and_schedule graph_builder = MessageGraph() # 1. Define vertices # We defined plan_and_schedule above already # Assign each node to a state variable to update graph_builder.add_node("plan_and_schedule", plan_and_schedule) graph_builder.add_node("join", joiner) # Define edges graph_builder.add_edge("plan_and_schedule", "join") # This condition determines looping logic def should_continue(state: List[BaseMessage]): if isinstance(state[-1], AIMessage): return END return "plan_and_schedule" graph_builder.add_conditional_edges( start_key="join", # Next, we pass in the function that will determine which node is called next. condition=should_continue, ) graph_builder.set_entry_point("plan_and_schedule") chain = graph_builder.compile() steps = chain.stream( [ HumanMessage( content="What's the oldest parrot alive, and how much longer is that than the average?" ) ], { "recursion_limit": 100, }, ) for step in steps: print(step) print("---") ``` Error Message and Stack Trace ``` <module> graph_builder.add_conditional_edges( TypeError: Graph.add_conditional_edges() missing 1 required positional argument: 'conditional_edge_mapping' ``` System Info ``` python = ">=3.10,<4.0.0" tenacity = "^8.2.3" langgraph = "^0.0.20" langchain = "^0.1.4" beautifulsoup4 = "^4.12.2" docker = "^6.1.3" langchain-community = "^0.0.17" llama-cpp-python = "^0.2.38" gpt4all = "^2.1.0" gguf = "^0.6.0" boto3 = "^1.34.34" langchain-openai = "^0.0.5" gitpython = "^3.1.41" qdrant-client = "^1.7.3" langchain-experimental = "^0.0.50" langchainhub = "^0.1.14" ``` ### Idea or request for content: _No response_
yindo closed this issue 2026-02-20 17:22:39 -05:00
Author
Owner

@Siafu commented on GitHub (Feb 15, 2024):

This was resolved by updating all of the Langchain, Langgraph packages.
langchain-community = "^0.0.20"
langgraph = "^0.0.24"
langchainhub = "^0.1.14"

@Siafu commented on GitHub (Feb 15, 2024): This was resolved by updating all of the Langchain, Langgraph packages. `langchain-community = "^0.0.20"` `langgraph = "^0.0.24"` `langchainhub = "^0.1.14"`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#21