Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't the run_name when running graph #2664

Open
4 tasks done
Daniel-963 opened this issue Dec 6, 2024 · 1 comment
Open
4 tasks done

Can't the run_name when running graph #2664

Daniel-963 opened this issue Dec 6, 2024 · 1 comment

Comments

@Daniel-963
Copy link

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

# when i def the chatbot using follow code,i cant get the name when run the workflow
async def chatbot1(state: State, config: RunnableConfig):
        config["run_name"] = "chatbot1"
        return {"messages": [await llm1.ainvoke(state["messages"], config)]}

# here i cant get name
async def message_generator(user_input: str):
    """Generate streaming messages from the graph."""
    inputs = [HumanMessage(content=user_input)]

    async for msg, metadata in graph.astream(
        {"messages": inputs}, stream_mode="messages"
    ):
        # here is none.
        # but i can get it when i using second way
        print(msg.name)
        yield json.dumps({"content": msg.content})

# but when using follow code,i can
    async def chatbot1(state: State, config: RunnableConfig):
        RunnableConfig(run_name="chatbot1")
        return {"messages": [await llm1.ainvoke(state["messages"], RunnableConfig(run_name="chatbot1"))]}

# that's why? is it a bug?

Error Message and Stack Trace (if applicable)

it's not a Error ,it's a phenomenon

Description

when i use first way to def the run_name,i cant get name in workflow processing ,but i can get it using seconds code!

System Info

pass

@vbarda
Copy link
Collaborator

vbarda commented Dec 18, 2024

@Daniel-963 is your intention to use this to dynamically set the message names? if so, neither of the approaches is suited for that. what you can do is you can get the node name from the streamed metadata (it will live under the key 'langgraph_node', e.g. : {'langgraph_node': 'chatbot1', ...}). you can then dynamically assign the name as needed. does this help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants