mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
Add AssistantAgent, deprecate CodingAssistantAgent and ToolUseAssistantAgent (#3960)
* Add AssistantAgent, deprecate CodingAssistantAgent and ToolUseAssistantAgent * Rename * Add note * Update uv * uf lock * Merge branch 'main' into assistant-agent * Update uv
This commit is contained in:
@@ -3,10 +3,10 @@ import json
|
||||
from typing import Any, AsyncGenerator, List
|
||||
|
||||
import pytest
|
||||
from autogen_agentchat.agents import ToolUseAssistantAgent
|
||||
from autogen_agentchat.agents import AssistantAgent
|
||||
from autogen_agentchat.messages import StopMessage, TextMessage
|
||||
from autogen_core.components.models import OpenAIChatCompletionClient
|
||||
from autogen_core.components.tools import FunctionTool
|
||||
from autogen_ext.models import OpenAIChatCompletionClient
|
||||
from openai.resources.chat.completions import AsyncCompletions
|
||||
from openai.types.chat.chat_completion import ChatCompletion, Choice
|
||||
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk
|
||||
@@ -42,7 +42,7 @@ async def _echo_function(input: str) -> str:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_round_robin_group_chat_with_tools(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
async def test_run_with_tools(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
model = "gpt-4o-2024-05-13"
|
||||
chat_completions = [
|
||||
ChatCompletion(
|
||||
@@ -97,10 +97,10 @@ async def test_round_robin_group_chat_with_tools(monkeypatch: pytest.MonkeyPatch
|
||||
]
|
||||
mock = _MockChatCompletion(chat_completions)
|
||||
monkeypatch.setattr(AsyncCompletions, "create", mock.mock_create)
|
||||
tool_use_agent = ToolUseAssistantAgent(
|
||||
tool_use_agent = AssistantAgent(
|
||||
"tool_use_agent",
|
||||
model_client=OpenAIChatCompletionClient(model=model, api_key=""),
|
||||
registered_tools=[_pass_function, _fail_function, FunctionTool(_echo_function, description="Echo")],
|
||||
tools=[_pass_function, _fail_function, FunctionTool(_echo_function, description="Echo")],
|
||||
)
|
||||
result = await tool_use_agent.run("task")
|
||||
assert len(result.messages) == 3
|
||||
@@ -7,10 +7,9 @@ from typing import Any, AsyncGenerator, List, Sequence
|
||||
import pytest
|
||||
from autogen_agentchat import EVENT_LOGGER_NAME
|
||||
from autogen_agentchat.agents import (
|
||||
AssistantAgent,
|
||||
BaseChatAgent,
|
||||
CodeExecutorAgent,
|
||||
CodingAssistantAgent,
|
||||
ToolUseAssistantAgent,
|
||||
)
|
||||
from autogen_agentchat.logging import FileLogHandler
|
||||
from autogen_agentchat.messages import (
|
||||
@@ -131,7 +130,7 @@ async def test_round_robin_group_chat(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
code_executor_agent = CodeExecutorAgent(
|
||||
"code_executor", code_executor=LocalCommandLineCodeExecutor(work_dir=temp_dir)
|
||||
)
|
||||
coding_assistant_agent = CodingAssistantAgent(
|
||||
coding_assistant_agent = AssistantAgent(
|
||||
"coding_assistant", model_client=OpenAIChatCompletionClient(model=model, api_key="")
|
||||
)
|
||||
team = RoundRobinGroupChat(participants=[coding_assistant_agent, code_executor_agent])
|
||||
@@ -211,10 +210,10 @@ async def test_round_robin_group_chat_with_tools(monkeypatch: pytest.MonkeyPatch
|
||||
mock = _MockChatCompletion(chat_completions)
|
||||
monkeypatch.setattr(AsyncCompletions, "create", mock.mock_create)
|
||||
tool = FunctionTool(_pass_function, name="pass", description="pass function")
|
||||
tool_use_agent = ToolUseAssistantAgent(
|
||||
tool_use_agent = AssistantAgent(
|
||||
"tool_use_agent",
|
||||
model_client=OpenAIChatCompletionClient(model=model, api_key=""),
|
||||
registered_tools=[tool],
|
||||
tools=[tool],
|
||||
)
|
||||
echo_agent = _EchoAgent("echo_agent", description="echo agent")
|
||||
team = RoundRobinGroupChat(participants=[tool_use_agent, echo_agent])
|
||||
|
||||
Reference in New Issue
Block a user