-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
Adds Reflexion (solves #2316) #4737
Conversation
Reflexion works now Still to do: - clean up inheritance structure - integrate callback manager, run manager, ... - remove debug log statements - create a short default prompt for reflexion? - test, document, lint, ...
…into 2316-reflexion
cc @mbchang |
Nice! |
This is really cool! And thank you for the PR and patience! The reason I'm taking some time to review this is that it changes a couple pretty core pieces - the agent executor and callback managers. While you do an excellent job of making sure it's all compatible, we may want to look into if a lighter-touch implementation would be appropriate here. I think @hwchase17 will have some stronger opinions than I right now in terms of how the agent framework should evolve |
Sure! 100% no hurt feelings. I think we have 2 options:
I went with 2 because @noahshinn024 explicitly stated "Reflexion is not a replacement for [...] any [....] decision-guiding approach! It is a simple retry technique that can be used (to) enhance other approaches." How would you design a light-version? Am happy to implement :) Edit: formatting |
Hey @hwchase17 any comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. I noticed some small typos and made a comment about an implementation detail. I don't understand Langchain enough to make more useful feedbacks, so...
total_time_elapsed = 0.0 | ||
total_start_time = time.time() | ||
trials = 1 | ||
trial_iterations = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trials and trial_iterations is confusing to me. From my understanding trial_iterations indicates the number of iterations done during the current trial, and "trials" indicates the current trial number. Maybe it would be beneficial to add some brief comment to describe each arguments or find a better naming (I don't have ideas thought).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good comment - will think of this when I get further comments from the LC team
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Hi @hinthornw! I saw you're now the maintainer for Agents / Tools / Toolkits, so am pinging you. Would love to get a rough direction on this, so I can adjust this to the LC team's preferences and get it merged. |
@UmerHA Hi , could you, please, resolve the merging issues? After that ping me and I push this PR for the review. Thanks! |
Hi @leo-gan, nice to see you're an LC collaborator - congrats! :) I would rather not fix this PR, because @vowelparrot said the key change in this PR needs to be discussed first. This PR introduces the concept of 'trials'. When an agent execution fails, a new run (new 'trial') is started. From @vowelparrot's comment, LC's preference is to implement this differently - maybe as a chain? Would love to get clarity on this issue before investing the effort of bringing this PR up-to-date. |
@hwchase17 Please, give a feedback to this important PR. Thanks! |
Hopping into this one - @UmerHA would you be game to implement this using Runnables (LCEL) in a template? https://github.com/langchain-ai/langchain/blob/master/templates/docs/CONTRIBUTING.md Would require starting over for the most part, but I don't think this PR is mergable in its current state anyways (library has evolved a lot since this was last worked on!). Let me know how you'd like to proceed! Happy to close this and you can open a new PR, or you're welcome to work from this PR's current state. |
Hey @efriis, I can't promise to work on this due to time constraints, so feel free to close this. If I find time to adapt this, I'll open a new PR! |
Sounds great - thanks @UmerHA ! |
Adds Reflexion (solves #2316)
Introduces the concept of trials to AgentExecutor and implements Reflexion as re-try method.
I.e., when the Agent fails, it thinks about what it could have done better & attempts the task again.
Based on https://arxiv.org/abs/2303.11366.
Fixes #2316
Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested:
@vowelparrot
Twitter: @UmerHAdil | Discord: RicChilligerDude#7589