refactor: make chain modes extensible via behaviour pattern #426
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extracts hardcoded modes from single file into separate modules that each implement a common Mode Behaviour, allowing users to define custom modes without modifying the library.
Comments
I'm not expecting this PR to get merged necessarily, but I wanted to propose a possible way of making run Modes more approachable with a Behaviour pattern.
I found myself wanting to write my own "mode" to have control over the restart strategy, but some functions like
do_runare private and unaccessible. So I'd end up using the :step mode and then copying some of the private functions internals. Perhaps that's the intention of the author, in which case feel free to close this PR. By having a module that defines the Mode behaviour, you can pass it in as an option and the higher level api of calling LLMChain.run(...) stays the same in your code.