-
According to https://langchain-ai.github.io/langgraph/how-tos/subgraphs-manage-state/#acting-as-the-entire-subgraph we can only route to only one path, my question is how can we implement a graph such that it supports a question that requires multiple routes e.g. both weather and other route. For example with routes like this
Questions like what is the weather in SF and show me 3 countries with highest sales? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You would need to adjust the schema for the structured output to return multiple values and also set up conditional edges (i.e.
class Router(TypedDict):
route: list[Literal["weather", "sql", "other"]]
model = ChatOpenAI(model_name="gpt-4o-mini")
model.with_structured_output(Router).invoke("what is the weather in SF and show me 3 countries with highest sales?")
# {'route': ['weather', 'sql']}
|
Beta Was this translation helpful? Give feedback.
You would need to adjust the schema for the structured output to return multiple values and also set up conditional edges (i.e.
route_after_prediction
) to return multiple values (I am assuming in your case you would want to run the nodes you route to via multiple routes in parallel)