-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[Feature Request]: Use self instaed of class functions in register_reply #1209
Comments
Instead of overriding |
Maybe another solution would be to have the agent object itself as part of the argument in the custom reply function. Because often time we need to have access to the agent's state in the custom reply function, making this explicit could be a good idea. It would be easy to do, we can allow both stateless and stateful functions to be registered as reply function. @davorrunje what do you think? |
@rickyloynd-microsoft Thanks for the example. It looks pretty similar to mine, it just does not remove the entry for the old generate_oai_reply first. I guess it does not matter, as long as I return final=True. However it feels kind of wrong to have the old function I want to replace still in the list. Is there a reason I should not remove the old function from the list? |
Yes, I think that was the intended purpose of the autogen/autogen/agentchat/conversable_agent.py Lines 185 to 190 in 2e519b0
|
Yes, we could support removing functions from the list. I am working on this part of the code right now and could include that change (#1208 ). Can you please create a new issue for it and I'll take it from there? |
I am working on a #1215 trying to unify API for registering functions, here is an example from a test case how to use it: autogen/test/agentchat/test_conversable_agent.py Lines 93 to 107 in 11ebd3c
|
The example you posted looks nice 👍 The wished additional issue: #1233 |
* admin takeover in group chat * comments * add comments
Is your feature request related to a problem? Please describe.
I adapt the ConversableAgent using inheritance to adapt some functionalities.
Right now, I want to fix the out_of_context issue (see # TODO: #1143 handle token limit exceeded error in ConversableAgent.py).
How ever, overwriting the generate_oai_reply in my class does not have any effect if I don't overwrite the init as well, because it gets registered using the class function:
self.register_reply([Agent, None], ConversableAgent.generate_oai_reply)
My current workaround is overwriting it after calling super:
Describe the solution you'd like
I think it would be possible to register function calls like this:
self.register_reply([Agent, None], self.generate_oai_reply)
This would require some more changes when functions are called, i.e. removing the self in:
final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"])
happy to provide a pull request if wished.
Additional context
No response
The text was updated successfully, but these errors were encountered: