-
Notifications
You must be signed in to change notification settings - Fork 679
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
Removed inheritance of TaskSpecifier, TaskPlanner and CriticAgent from ChatAgent #197
Conversation
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.
TBH, I do not know if introducing nested agents is a good idea or not. It makes the design very complicated. Renaming the step functions also makes it hard to scale if we introduce more agents in the future. The current inheritance is not ideal but we can find other ways to fix it. I would prefer not to introduce nested agents and keep unified interfaces.
This is an important change. It would be great to hear everyone's opinions @hammoudhasan @HaniItani @oserikov @zechengz @camel-ai/camel-intern-team.
The current inheritance is non-existant. If you "inherit" just a name of a method but not its signature it is not inheritance. What do you mean by "nested" agents? |
I believe, you want to organize something like PyTorch dynamic graph. But it does not make much sense since the only purpose of pytorch modules is to keep track of the compute graph for backprop. We do not have backprop then we dont need Modules. Further, notice that PyTorch does dynamic check of matching arguments and can crash at any moment. This is fine for Pytorch since neural networks are fast (less than a second). With chat agents it may take minutes. You dont want to have a chat of 50 messages to have it crash when the last agent of summarization gets the wrong number of parameters. We want this statically checked by mypy. |
BTW if you wanted something like PyTorch modules, you could name the main function 'forward' to refer PyTorch's concept. |
IMO it depends on the functionality of |
I realize that playing with inheritance may make you look cool in the eyes of peers. But it is not cool if you (1) have mypy errors on your code, (2) do not use polymorphism which is the purpose of having inheritance, (3) do not follow the Gang of Four's "prefer composition over inheritance" principle. A good software engineering practice is to use inheritance purely for interface specification, having max one level of inheritance. |
@lightaime I got you point about the nested agents. My opinion is that this is the pattern that is the most natural: makes the job done with composition only. Why is it complicated? You don't have to flatten-out all agents. What is the use of a unified interface? You could do some dynamic routing of messages between agents but if the output signature is is incompatible with the input signature, the code will crash and that's it. |
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, I'm good with this PR! @lightaime @Obs01ete could we meet and discuss the nested/non-nested agent thing? I believe this relates to the general positioning of the codebase
|
||
def step( | ||
def specify_prompt( |
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.
def specify_prompt( | |
def expand_prompt( |
I'd propose expand as a basic self-descriptive word for what happens here, same could work for the class name probably
@lightaime Speaking of nested agents, in the camel/camel/agents/embodied_agent.py Line 61 in abff2ea
This looks like nesting to me. |
Fixed in #206 |
Closed since it is not an active PR. |
Description
Removed inheritance of TaskSpecifier, TaskPlanner and CriticAgent from ChatAgent. Now we have 0 mypy errors in
camel
andtest
.Motivation and Context
TaskSpecifier, TaskPlanner and CriticAgent do not follow the signature of step() of ChatAgent. They must be dis-inherited from ChatAgent and a ChatAgent instance used as a member.
Issue #163
This is a list of rules of overriding for python:
https://rules.sonarsource.com/python/RSPEC-2638/
Types of changes
Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!