What's New
Anthropic Model Client
Native support for Anthropic models. Get your update:
pip install -U "autogen-ext[anthropic]"
The new client follows the same interface as OpenAIChatCompletionClient
so you can use it directly in your agents and teams.
import asyncio
from autogen_ext.models.anthropic import AnthropicChatCompletionClient
from autogen_core.models import UserMessage
async def main():
anthropic_client = AnthropicChatCompletionClient(
model="claude-3-sonnet-20240229",
api_key="your-api-key", # Optional if ANTHROPIC_API_KEY is set in environment
)
result = await anthropic_client.create([UserMessage(content="What is the capital of France?", source="user")]) # type: ignore
print(result)
if __name__ == "__main__":
asyncio.run(main())
You can also load the model client directly from a configuration dictionary:
from autogen_core.models import ChatCompletionClient
config = {
"provider": "AnthropicChatCompletionClient",
"config": {"model": "claude-3-sonnet-20240229"},
}
client = ChatCompletionClient.load_component(config)
To use with AssistantAgent
and run the agent in a loop to match the behavior of Claude agents, you can use Single-Agent Team.
- Add anthropic docs by @victordibia in #5882
LlamaCpp Model Client
LlamaCpp is a great project for working with local models. Now we have native support via its official SDK.
pip install -U "autogen-ext[llama-cpp]"
To use a local model file:
import asyncio
from autogen_core.models import UserMessage
from autogen_ext.models.llama_cpp import LlamaCppChatCompletionClient
async def main():
llama_client = LlamaCppChatCompletionClient(model_path="/path/to/your/model.gguf")
result = await llama_client.create([UserMessage(content="What is the capital of France?", source="user")])
print(result)
asyncio.run(main())
To use it with a Hugging Face model:
import asyncio
from autogen_core.models import UserMessage
from autogen_ext.models.llama_cpp import LlamaCppChatCompletionClient
async def main():
llama_client = LlamaCppChatCompletionClient(
repo_id="unsloth/phi-4-GGUF", filename="phi-4-Q2_K_L.gguf", n_gpu_layers=-1, seed=1337, n_ctx=5000
)
result = await llama_client.create([UserMessage(content="What is the capital of France?", source="user")])
print(result)
asyncio.run(main())
- Feature add Add LlamaCppChatCompletionClient and llama-cpp by @aribornstein in #5326
Task-Centric Memory (Experimental)
Task-Centric memory is an experimental module that can give agents the ability to:
- Accomplish general tasks more effectively by learning quickly and continually beyond context-window limitations.
- Remember guidance, corrections, plans, and demonstrations provided by users (teachability)
- Learn through the agent's own experience and adapt quickly to changing circumstances (self-improvement)
- Avoid repeating mistakes on tasks that are similar to those previously encountered.
For example, you can use Teachability
as a memory
for AssistantAgent
so your agent can learn from user teaching.
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.experimental.task_centric_memory import MemoryController
from autogen_ext.experimental.task_centric_memory.utils import Teachability
async def main():
# Create a client
client = OpenAIChatCompletionClient(model="gpt-4o-2024-08-06", )
# Create an instance of Task-Centric Memory, passing minimal parameters for this simple example
memory_controller = MemoryController(reset=False, client=client)
# Wrap the memory controller in a Teachability instance
teachability = Teachability(memory_controller=memory_controller)
# Create an AssistantAgent, and attach teachability as its memory
assistant_agent = AssistantAgent(
name="teachable_agent",
system_message = "You are a helpful AI assistant, with the special ability to remember user teachings from prior conversations.",
model_client=client,
memory=[teachability],
)
# Enter a loop to chat with the teachable agent
print("Now chatting with a teachable agent. Please enter your first message. Type 'exit' or 'quit' to quit.")
while True:
user_input = input("\nYou: ")
if user_input.lower() in ["exit", "quit"]:
break
await Console(assistant_agent.run_stream(task=user_input))
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Head over to its README for details, and the samples for runnable examples.
- Task-Centric Memory by @rickyloynd-microsoft in #5227
New Sample: Gitty (Experimental)
Gitty is an experimental application built to help easing the burden on open-source project maintainers. Currently, it can generate auto reply to issues.
To use:
gitty --repo microsoft/autogen issue 5212
Head over to Gitty to see details.
Improved Tracing and Logging
In this version, we made a number of improvements on tracing and logging.
- add LLMStreamStartEvent and LLMStreamEndEvent by @EItanya in #5890
- Allow for tracing via context provider by @EItanya in #5889
- Fix span structure for tracing by @ekzhu in #5853
- Add ToolCallEvent and log it from all builtin tools by @ekzhu in #5859
Powershell Support for LocalCommandLineCodeExecutor
- feat: update local code executor to support powershell by @lspinheiro in #5884
Website Accessibility Improvements
@peterychang has made huge improvements to the accessibility of our documentation website. Thank you @peterychang!
- word wrap prev/next links on autodocs by @peterychang in #5867
- Allow Voice Access to find clickable cards by @peterychang in #5857
- copy tooltip on focus. Upgrade PDT version by @peterychang in #5848
- highlight focused code output boxes in jupyter notebook pages by @peterychang in #5819
- Fix high contrast mode focus by @peterychang in #5796
- Keyboard copy event and search bar cancellation by @peterychang in #5820
Bug Fixes
- fix: save_state should not require the team to be stopped. by @ekzhu in #5885
- fix: remove max_tokens from az ai client create call when stream=True by @ekzhu in #5860
- fix: add plugin to kernel by @lspinheiro in #5830
- fix: warn when using reflection on tool use with Claude models by @ekzhu in #5829
Other Python Related Changes
- doc: update termination tutorial to include FunctionCallTermination condition and fix formatting by @ekzhu in #5813
- docs: Add note recommending PythonCodeExecutionTool as an alternative to CodeExecutorAgent by @ekzhu in #5809
- Update quickstart.ipynb by @taswar in #5815
- Fix warning in selector gorup chat guide by @ekzhu in #5849
- Support for external agent runtime in AgentChat by @ekzhu in #5843
- update ollama usage docs by @ekzhu in #5854
- Update markitdown requirements to >= 0.0.1, while still in the 0.0.x range by @afourney in #5864
- Add client close by @afourney in #5871
- Update README to clarify Web Browsing Agent Team usage, and use animated Chromium browser by @ekzhu in #5861
- Add author name before their message in Chainlit team sample by @DavidYu00 in #5878
- Bump axios from 1.7.9 to 1.8.2 in /python/packages/autogen-studio/frontend by @dependabot in #5874
- Add an optional base path to FileSurfer by @husseinmozannar in #5886
- feat: Pause and Resume for AgentChat Teams and Agents by @ekzhu in #5887
- update version to v0.4.9 by @ekzhu in #5903
New Contributors
- @taswar made their first contribution in #5815
- @DavidYu00 made their first contribution in #5878
- @aribornstein made their first contribution in #5326
Full Changelog: python-v0.4.8...python-v0.4.9