Skip to content

Commit eca6c04

Browse files
WaelKarkoubekzhu
andauthored
Document Migration to TransformMessages (#2247)
* wip * tweaks * undo fix * undo removal * adds to FAQ * modify docs * undo formatter * updates docs * update deprec notice in compressible agent * restore notebooks * giorgossideris comments * cleanup * resolve comments * improve english * improve english * cleanup --------- Co-authored-by: Eric Zhu <[email protected]>
1 parent bb374c8 commit eca6c04

File tree

3 files changed

+380
-4
lines changed

3 files changed

+380
-4
lines changed

autogen/agentchat/contrib/compressible_agent.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44
import logging
55
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
6+
from warnings import warn
67

78
from autogen import Agent, ConversableAgent, OpenAIWrapper
89
from autogen.token_count_utils import count_token, get_max_token_limit, num_tokens_from_functions
@@ -11,10 +12,17 @@
1112

1213
logger = logging.getLogger(__name__)
1314

15+
warn(
16+
"Context handling with CompressibleAgent is deprecated. "
17+
"Please use `TransformMessages`, documentation can be found at https://microsoft.github.io/autogen/docs/reference/agentchat/contrib/capabilities/transform_messages",
18+
DeprecationWarning,
19+
stacklevel=2,
20+
)
21+
1422

1523
class CompressibleAgent(ConversableAgent):
16-
"""(CompressibleAgent will be deprecated. Refer to https://github.com/microsoft/autogen/blob/main/notebook/agentchat_capability_long_context_handling.ipynb for long context handling capability.) CompressibleAgent agent. While this agent retains all the default functionalities of the `AssistantAgent`,
17-
it also provides the added feature of compression when activated through the `compress_config` setting.
24+
"""CompressibleAgent agent. While this agent retains all the default functionalities of the `AssistantAgent`,
25+
it also provides the added feature of compression when activated through the `compress_config` setting.
1826
1927
`compress_config` is set to False by default, making this agent equivalent to the `AssistantAgent`.
2028
This agent does not work well in a GroupChat: The compressed messages will not be sent to all the agents in the group.

website/docs/FAQ.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import TOCInline from '@theme/TOCInline';
1+
import TOCInline from "@theme/TOCInline";
22

33
# Frequently Asked Questions
44

@@ -7,6 +7,7 @@ import TOCInline from '@theme/TOCInline';
77
## Install the correct package - `pyautogen`
88

99
The name of Autogen package at PyPI is `pyautogen`:
10+
1011
```
1112
pip install pyautogen
1213
```
@@ -50,6 +51,7 @@ Please refer to the [documentation](/docs/Use-Cases/enhanced_inference#runtime-e
5051
When you call `initiate_chat` the conversation restarts by default. You can use `send` or `initiate_chat(clear_history=False)` to continue the conversation.
5152

5253
## `max_consecutive_auto_reply` vs `max_turn` vs `max_round`
54+
5355
- [`max_consecutive_auto_reply`](https://microsoft.github.io/autogen/docs/reference/agentchat/conversable_agent#max_consecutive_auto_reply) the maximum number of consecutive auto replie (a reply from an agent without human input is considered an auto reply). It plays a role when `human_input_mode` is not "ALWAYS".
5456
- [`max_turns` in `ConversableAgent.initiate_chat`](https://microsoft.github.io/autogen/docs/reference/agentchat/conversable_agent#initiate_chat) limits the number of conversation turns between two conversable agents (without differentiating auto-reply and reply/input from human)
5557
- [`max_round` in GroupChat](https://microsoft.github.io/autogen/docs/reference/agentchat/groupchat#groupchat-objects) specifies the maximum number of rounds in a group chat session.
@@ -135,6 +137,7 @@ prompt += termination_notice
135137
(from [issue #251](https://github.com/microsoft/autogen/issues/251))
136138

137139
Code examples that use chromadb (like retrieval) fail in codespaces due to a sqlite3 requirement.
140+
138141
```
139142
>>> import chromadb
140143
Traceback (most recent call last):
@@ -146,6 +149,7 @@ Please visit https://docs.trychroma.com/troubleshooting#sqlite to learn how to u
146149
```
147150

148151
Workaround:
152+
149153
1. `pip install pysqlite3-binary`
150154
2. `mkdir /home/vscode/.local/lib/python3.10/site-packages/google/colab`
151155

@@ -157,7 +161,8 @@ Explanation: Per [this gist](https://gist.github.com/defulmere/8b9695e415a442710
157161

158162
See here https://microsoft.github.io/autogen/docs/reference/agentchat/conversable_agent/#register_reply
159163

160-
For example, you can register a reply function that gets called when `generate_reply` is called for an agent.
164+
For example, you can register a reply function that gets called when `generate_reply` is called for an agent.
165+
161166
```python
162167
def print_messages(recipient, messages, sender, config):
163168
if "callback" in config and config["callback"] is not None:
@@ -178,6 +183,7 @@ assistant.register_reply(
178183
config={"callback": None},
179184
)
180185
```
186+
181187
In the above, we register a `print_messages` function that is called each time the agent's `generate_reply` is triggered after receiving a message.
182188

183189
## How to get last message ?
@@ -252,3 +258,13 @@ user_proxy = autogen.UserProxyAgent(
252258
name="agent", llm_config=llm_config,
253259
code_execution_config={"work_dir":"coding", "use_docker":False})
254260
```
261+
262+
## Migrating from `CompressibleAgent` and `TransformChatHistory` to `TransformMessages`
263+
264+
### Why migrate to `TransformMessages`?
265+
266+
Migrating enhances flexibility, modularity, and customization in handling chat message transformations. `TransformMessages` introduces an improved, extensible approach for pre-processing messages for conversational agents.
267+
268+
### How to migrate?
269+
270+
To ensure a smooth migration process, simply follow the detailed guide provided in [Handling Long Context Conversations with Transform Messages](/docs/topics/long_contexts.md).

0 commit comments

Comments
 (0)