autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[Feature Request]: Enable easy replacement of registered functions

Open krlng opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

If a user wants to change the behavior of any of the functions that got registered for a reply, it is not enough to overwrite this function in a child-class, as the register_reply function registers class-methods.

Instead a user has to replace the function with something similar as:

  ind = [i for i, x in enumerate(self._reply_func_list) if hasattr(x["reply_func"],"__name__") and x["reply_func"].__name__ == "generate_oai_reply"]
  assert len(ind) == 1
  for i in ind:
      self._reply_func_list.pop(i)
      self.register_reply([Agent, None], self.generate_oai_reply, position=i)

after calling the constructor of the parent class.

Describe the solution you'd like

Make it somehow more easy for users to use custom reply functions. On idea is not using class-functions, as sketched here: https://github.com/microsoft/autogen/issues/1209

Another would be an easy replacement of existing functions.

Additional context

No response

krlng avatar Jan 13 '24 21:01 krlng

I like this issue. This is touching the heart of what we are currently working on in #1215 and #1240. In short, we want to make it really easy for developers to compose agent. So you can customize your own agent by declaratively specify a list of components, without modifying the defaults like today.

What you are doing is a fine shortcut for the issue right now as you can go directly modify the _reply_func_list of the agent by adding or remove reply functions.

ekzhu avatar Jan 14 '24 04:01 ekzhu