Skip to content
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

how to register a rely function Issue-478 #579

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions website/docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,34 @@ Workaround:
2. `mkdir /home/vscode/.local/lib/python3.10/site-packages/google/colab`

Explanation: Per [this gist](https://gist.github.com/defulmere/8b9695e415a44271061cc8e272f3c300?permalink_comment_id=4711478#gistcomment-4711478), linked from the official [chromadb docs](https://docs.trychroma.com/troubleshooting#sqlite), adding this folder triggers chromadb to use pysqlite3 instead of the default.

## How to register a reply function

(from [issue #478](https://github.com/microsoft/autogen/issues/478))
olaoluwasalami marked this conversation as resolved.
Show resolved Hide resolved

You can hook in a function that is called whenever an agent receives a message
olaoluwasalami marked this conversation as resolved.
Show resolved Hide resolved

Assuming you have two agents user_proxy and assistant, you can register a function with these agents that gets called with some parameters.
olaoluwasalami marked this conversation as resolved.
Show resolved Hide resolved

```
def print_messages(recipient, messages, sender, config):
if "callback" in config and config["callback"] is not None:
callback = config["callback"]
callback(sender, recipient, messages[-1])
print(f"Messages sent to: {recipient.name} | num messages: {len(messages)}")
return False, None # required to ensure the agent communication flow continues

user_proxy.register_reply(
[autogen.Agent, None],
reply_func=print_messages,
config={"callback": None},
)

assistant.register_reply(
[autogen.Agent, None],
reply_func=print_messages,
config={"callback": None},
)

```
In the above, we register a print_messages message that is called each time the agent receive a message.
olaoluwasalami marked this conversation as resolved.
Show resolved Hide resolved
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved
Loading