Best practices for adding branching logic? #11172
codeananda
started this conversation in
General
Replies: 1 comment
-
I imagine you'll first want to add some kind of output parser in order to make sure the output is being interpreted correctly. After that, you could use a RunnableBranch (https://python.langchain.com/docs/expression_language/how_to/routing) to select what should happen next. Perhaps something like this:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm giving an LLM 37 categories and asking it to label pieces of text with the categories that apply to it (likely multiple for each text). I ask it to output its response as a markdown table.
Problem: the LLM doesn't always return answers for all the categories.
I want to check if all the categories have been returned, if they have, finish. If they haven't, ask it to classify the categories it forgot about (or, if that's too complicated, ask it to do it again).
I've thought about a
RouterChain
but am not sure how to handle the default chain (is there aDoNothingChain
?).SequentialChain
also confuses me since you cannot account for different actions based on Yes/No answer from 'does this contain all the classes?' SubclassChain
and write it?In general though, I'm not sure how to add this branching logic?
Beta Was this translation helpful? Give feedback.
All reactions