langgraph4j icon indicating copy to clipboard operation
langgraph4j copied to clipboard

How to implement routing function:

Open smileyboy2019 opened this issue 10 months ago • 3 comments

How to implement routing function: How to achieve intent recognition similar: The selector for LlamaIndex Pydant Router in LlamaIndex ZeroShot TextRouter in Haystack

Image

smileyboy2019 avatar Jan 21 '25 05:01 smileyboy2019

HI @smileyboy2019

The routing is based on conditional edge that use a routing function to decide what is the next step.

In the routing function you got the Agent State and based on it you can choose the route

graph.addConditionalEdges("nl-router", routingFunction, Map.of( "first": "llm-router", "second": "semantic-router" ) );

It is very important define and contribute to the Agent State in order to have in each node or edge the right information to do the right actions

bsorrentino avatar Jan 21 '25 09:01 bsorrentino

1.How to pass parameters during the routing process 2. Can the entire arrangement be implemented through JSON

smileyboy2019 avatar Jan 22 '25 05:01 smileyboy2019

1.How to pass parameters during the routing process 2. Can the entire arrangement be implemented through JSON

  1. Only Agent State is passed to node and edge actions so, you have to store parameters into state itself
  2. Could be, but it is not so and should be implemented

bsorrentino avatar Jan 22 '25 15:01 bsorrentino