autogen/website/docs/topics/handling_long_contexts/compressing_text_w_llmligua.md
Example 2: Integrating LLMLingua with `ConversableAgent`  Now, let's integrate `LLMLingua` into a conversational agent within AutoGen. This allows dynamic compression of prompts before they are sent to the LLM.  ```python import os  import autogen from autogen.agentchat.contrib.capabilities import transform_messages  system_message = "You are a world class researcher." config_list = [{"model": "gpt-4-turbo", "api_key": os.getenv("OPENAI_API_KEY")}]  # Define your agent; the user proxy and an assistant researcher = autogen.ConversableAgent(     "assistant",     llm_config={"config_list": config_list},     max_consecutive_auto_reply=1,     system_message=system_message,     human_input_mode="NEVER", ) user_proxy = autogen.UserProxyAgent(     "user_proxy",     human_input_mode="NEVER",     is_termination_msg=lambda x: "TERMINATE" in x.get("content", ""),     max_consecutive_auto_reply=1, ) ```  :::tip Learn more about configuring LLMs for agents [here](/docs/topics/llm_configuration). :::  ```python context_handling = transform_messages.TransformMessages(transforms=[text_compressor]) context_handling.add_to_agent(researcher)  message = "Summarize this research paper for me, include the important information" + pdf_text result = user_proxy.initiate_chat(recipient=researcher, clear_history=True, message=message, silent=True)  print(result.chat_history[1]["content"]) ```  ```console 19953 tokens saved with text compression. The paper describes AutoGen, a framework designed to facilitate the development of diverse large language model (LLM) applications through conversational multi-agent systems. The framework emphasizes customization and flexibility, enabling developers to define agent interaction behaviors in natural language or computer code.  Key components of AutoGen include: 1. **Conversable Agents**: These are customizable agents designed to operate autonomously or through human interaction. They are capable of initiating, maintaining, and responding within conversations, contributing effectively to multi-agent dialogues.  2. **Conversation Programming**: AutoGen introduces a programming paradigm centered around conversational interactions among agents. This approach simplifies the development of complex applications by streamlining how agents communicate and interact, focusing on conversational logic rather than traditional coding for mats.  3. **Agent Customization and Flexibility**: Developers have the freedom to define the capabilities and behaviors of agents within the system, allowing for a wide range of applications across different domains.  4. **Application Versatility**: The paper outlines various use cases from mathematics and coding to decision-making and entertainment, demonstrating AutoGen's ability to cope with a broad spectrum of complexities and requirements.  5. **Hierarchical and Joint Chat Capabilities**: The system supports complex conversation patterns including hierarchical and multi-agent interactions, facilitating robust dialogues that can dynamically adjust based on the conversation context and the agents' roles.  6. **Open-source and Community Engagement**: AutoGen is presented as an open-source framework, inviting contributions and adaptations from the global development community to expand its capabilities and applications.  The framework's architecture is designed so that it can be seamlessly integrated into existing systems, providing a robust foundation for developing sophisticated multi-agent applications that leverage the capabilities of modern LLMs. The paper also discusses potential ethical considerations and future improvements, highlighting the importance of continual development in response to evolving tech landscapes and user needs. ``` 