diff --git a/README.md b/README.md
index a876fa19ea2..f51aef2f5fe 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,8 @@
-[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40pyautogen)](https://twitter.com/pyautogen) [![GitHub Discussions](https://img.shields.io/badge/Discussions-Q%26A-green?logo=github)](https://github.com/microsoft/autogen/discussions) [![0.2 Docs](https://img.shields.io/badge/Docs-0.2-blue)](https://microsoft.github.io/autogen/0.2/) [![0.4 Docs](https://img.shields.io/badge/Docs-0.4-blue)](https://microsoft.github.io/autogen/dev/)
+[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40pyautogen)](https://twitter.com/pyautogen) [![LinkedIn](https://img.shields.io/badge/LinkedIn-Company?style=flat&logo=linkedin&logoColor=white)](https://www.linkedin.com/company/105812540)
+[![GitHub Discussions](https://img.shields.io/badge/Discussions-Q%26A-green?logo=github)](https://github.com/microsoft/autogen/discussions) [![0.2 Docs](https://img.shields.io/badge/Docs-0.2-blue)](https://microsoft.github.io/autogen/0.2/) [![0.4 Docs](https://img.shields.io/badge/Docs-0.4-blue)](https://microsoft.github.io/autogen/dev/)
[![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/0.4.0.dev8/) [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/0.4.0.dev8/) [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/0.4.0.dev8/)
@@ -115,7 +116,8 @@ To use Azure OpenAI models, follow the instruction
```python
import asyncio
from autogen_agentchat.agents import AssistantAgent
-from autogen_agentchat.task import Console, TextMentionTermination
+from autogen_agentchat.ui import Console
+from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models import OpenAIChatCompletionClient
diff --git a/python/packages/agbench/benchmarks/AssistantBench/Templates/MagenticOne/scenario.py b/python/packages/agbench/benchmarks/AssistantBench/Templates/MagenticOne/scenario.py
index 17d9125195d..09925ebe14d 100644
--- a/python/packages/agbench/benchmarks/AssistantBench/Templates/MagenticOne/scenario.py
+++ b/python/packages/agbench/benchmarks/AssistantBench/Templates/MagenticOne/scenario.py
@@ -8,7 +8,7 @@
from typing import List
-from autogen_core.base import AgentId, AgentProxy, TopicId
+from autogen_core import AgentId, AgentProxy, TopicId
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
from autogen_core.components.models import (
@@ -16,7 +16,7 @@
UserMessage,
LLMMessage,
)
-from autogen_core.components import DefaultSubscription, DefaultTopicId
+from autogen_core import DefaultSubscription, DefaultTopicId
from autogen_core.components.code_executor import LocalCommandLineCodeExecutor
from autogen_core.components.models import AssistantMessage
diff --git a/python/packages/agbench/benchmarks/GAIA/Templates/MagenticOne/scenario.py b/python/packages/agbench/benchmarks/GAIA/Templates/MagenticOne/scenario.py
index 6c7f8ab763a..15b312c517c 100644
--- a/python/packages/agbench/benchmarks/GAIA/Templates/MagenticOne/scenario.py
+++ b/python/packages/agbench/benchmarks/GAIA/Templates/MagenticOne/scenario.py
@@ -8,7 +8,7 @@
from typing import List
-from autogen_core.base import AgentId, AgentProxy, TopicId
+from autogen_core import AgentId, AgentProxy, TopicId
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
from autogen_core.components.models import (
@@ -17,7 +17,7 @@
UserMessage,
LLMMessage,
)
-from autogen_core.components import DefaultSubscription, DefaultTopicId
+from autogen_core import DefaultSubscription, DefaultTopicId
from autogen_core.components.code_executor import LocalCommandLineCodeExecutor
from autogen_core.components.models import AssistantMessage
diff --git a/python/packages/agbench/benchmarks/HumanEval/Templates/MagenticOne/scenario.py b/python/packages/agbench/benchmarks/HumanEval/Templates/MagenticOne/scenario.py
index a9b62a1e38e..a0a2707aa71 100644
--- a/python/packages/agbench/benchmarks/HumanEval/Templates/MagenticOne/scenario.py
+++ b/python/packages/agbench/benchmarks/HumanEval/Templates/MagenticOne/scenario.py
@@ -1,10 +1,10 @@
import asyncio
import logging
-from autogen_core.base import AgentId, AgentProxy, TopicId
+from autogen_core import AgentId, AgentProxy, TopicId
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.components import DefaultSubscription, DefaultTopicId
+from autogen_core import DefaultSubscription, DefaultTopicId
from autogen_core.components.code_executor import LocalCommandLineCodeExecutor
from autogen_core.components.models import (
UserMessage,
@@ -41,7 +41,7 @@ async def main() -> None:
executor = AgentProxy(AgentId("Executor", "default"), runtime)
await runtime.register(
- "Orchestrator",
+ "Orchestrator",
lambda: RoundRobinOrchestrator([coder, executor]),
subscriptions=lambda: [DefaultSubscription()],
)
diff --git a/python/packages/agbench/benchmarks/WebArena/Templates/MagenticOne/scenario.py b/python/packages/agbench/benchmarks/WebArena/Templates/MagenticOne/scenario.py
index 5cbf5c4c213..306c87826bc 100644
--- a/python/packages/agbench/benchmarks/WebArena/Templates/MagenticOne/scenario.py
+++ b/python/packages/agbench/benchmarks/WebArena/Templates/MagenticOne/scenario.py
@@ -7,10 +7,10 @@
from typing import Any, Dict, List, Tuple, Union
-from autogen_core.base import AgentId, AgentProxy, TopicId
+from autogen_core import AgentId, AgentProxy, TopicId
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.components import DefaultSubscription, DefaultTopicId
+from autogen_core import DefaultSubscription, DefaultTopicId
from autogen_core.components.code_executor import LocalCommandLineCodeExecutor
from autogen_core.components.models import (
ChatCompletionClient,
@@ -105,7 +105,7 @@ async def main() -> None:
task_prompt = task_prompt.replace(k, REPLACEMENTS[k])
fh.write(task_prompt)
TASK = json.loads(task_prompt)
- if TASK["start_url"] == REDDIT:
+ if TASK["start_url"] == REDDIT:
TASK["start_url"] = TASK["start_url"] + "/forums/all"
full_task = ""
@@ -150,7 +150,7 @@ async def main() -> None:
# Round-robin orchestrator
await runtime.register(
- "round_robin_orc",
+ "round_robin_orc",
lambda: RoundRobinOrchestrator(agents=[web_surfer, login_assistant],),
subscriptions=lambda: [DefaultSubscription()],
)
@@ -163,7 +163,7 @@ async def main() -> None:
runtime.start()
await runtime.publish_message(
- ResetMessage(),
+ ResetMessage(),
topic_id=DefaultTopicId(),
)
await runtime.publish_message(
@@ -192,16 +192,16 @@ async def main() -> None:
subscriptions=lambda: [DefaultSubscription()],
)
executor = AgentProxy(AgentId("ComputerTerminal", "default"), runtime)
-
+
await runtime.register(
"FileSurfer",
lambda: FileSurfer(model_client=client),
subscriptions=lambda: [DefaultSubscription()],
)
file_surfer = AgentProxy(AgentId("FileSurfer", "default"), runtime)
-
+
await runtime.register(
- "orchestrator",
+ "orchestrator",
lambda: LedgerOrchestrator(
agents=[coder, executor, file_surfer, web_surfer],
model_client=client,
@@ -251,7 +251,7 @@ async def main() -> None:
page = actual_surfer._page
cdp_session = await context.new_cdp_session(page)
config_file = "full_task.json"
-
+
evaluator = evaluation_harness.evaluator_router(config_file)
score = await evaluator(
trajectory=evaluation_harness.make_answer_trajecotry(final_answer),
@@ -260,7 +260,7 @@ async def main() -> None:
client=cdp_session,
# azure_config=llm_config,
)
-
+
print("FINAL SCORE: " + str(score))
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py
index 4cff9f45822..219cb1af534 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py
@@ -1,4 +1,4 @@
-from ._assistant_agent import AssistantAgent, Handoff
+from ._assistant_agent import AssistantAgent, Handoff # type: ignore
from ._base_chat_agent import BaseChatAgent
from ._code_executor_agent import CodeExecutorAgent
from ._coding_assistant_agent import CodingAssistantAgent
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py
index 1edf86f0061..de208738225 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py
@@ -1,10 +1,10 @@
import asyncio
import json
import logging
+import warnings
from typing import Any, AsyncGenerator, Awaitable, Callable, Dict, List, Sequence
-from autogen_core.base import CancellationToken
-from autogen_core.components import FunctionCall
+from autogen_core import CancellationToken, FunctionCall
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
@@ -15,9 +15,10 @@
UserMessage,
)
from autogen_core.components.tools import FunctionTool, Tool
-from pydantic import BaseModel, Field, model_validator
+from typing_extensions import deprecated
from .. import EVENT_LOGGER_NAME
+from ..base import Handoff as HandoffBase
from ..base import Response
from ..messages import (
AgentMessage,
@@ -33,51 +34,16 @@
event_logger = logging.getLogger(EVENT_LOGGER_NAME)
-class Handoff(BaseModel):
- """Handoff configuration for :class:`AssistantAgent`."""
+@deprecated("Moved to autogen_agentchat.base.Handoff. Will remove in 0.4.0.", stacklevel=2)
+class Handoff(HandoffBase):
+ """[DEPRECATED] Handoff configuration. Moved to :class:`autogen_agentchat.base.Handoff`. Will remove in 0.4.0."""
- target: str
- """The name of the target agent to handoff to."""
-
- description: str = Field(default=None)
- """The description of the handoff such as the condition under which it should happen and the target agent's ability.
- If not provided, it is generated from the target agent's name."""
-
- name: str = Field(default=None)
- """The name of this handoff configuration. If not provided, it is generated from the target agent's name."""
-
- message: str = Field(default=None)
- """The message to the target agent.
- If not provided, it is generated from the target agent's name."""
-
- @model_validator(mode="before")
- @classmethod
- def set_defaults(cls, values: Dict[str, Any]) -> Dict[str, Any]:
- if values.get("description") is None:
- values["description"] = f"Handoff to {values['target']}."
- if values.get("name") is None:
- values["name"] = f"transfer_to_{values['target']}".lower()
- else:
- name = values["name"]
- if not isinstance(name, str):
- raise ValueError(f"Handoff name must be a string: {values['name']}")
- # Check if name is a valid identifier.
- if not name.isidentifier():
- raise ValueError(f"Handoff name must be a valid identifier: {values['name']}")
- if values.get("message") is None:
- values["message"] = (
- f"Transferred to {values['target']}, adopting the role of {values['target']} immediately."
- )
- return values
-
- @property
- def handoff_tool(self) -> Tool:
- """Create a handoff tool from this handoff configuration."""
-
- def _handoff_tool() -> str:
- return self.message
-
- return FunctionTool(_handoff_tool, name=self.name, description=self.description)
+ def model_post_init(self, __context: Any) -> None:
+ warnings.warn(
+ "Handoff was moved to autogen_agentchat.base.Handoff. Importing from this will be removed in 0.4.0.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
class AssistantAgent(BaseChatAgent):
@@ -87,7 +53,7 @@ class AssistantAgent(BaseChatAgent):
name (str): The name of the agent.
model_client (ChatCompletionClient): The model client to use for inference.
tools (List[Tool | Callable[..., Any] | Callable[..., Awaitable[Any]]] | None, optional): The tools to register with the agent.
- handoffs (List[Handoff | str] | None, optional): The handoff configurations for the agent,
+ handoffs (List[HandoffBase | str] | None, optional): The handoff configurations for the agent,
allowing it to transfer to other agents by responding with a :class:`HandoffMessage`.
The transfer is only executed when the team is in :class:`~autogen_agentchat.teams.Swarm`.
If a handoff is a string, it should represent the target agent's name.
@@ -107,7 +73,7 @@ class AssistantAgent(BaseChatAgent):
.. code-block:: python
import asyncio
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.messages import TextMessage
@@ -139,8 +105,8 @@ async def main() -> None:
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.messages import TextMessage
- from autogen_agentchat.task import Console
- from autogen_core.base import CancellationToken
+ from autogen_agentchat.ui import Console
+ from autogen_core import CancellationToken
async def get_current_time() -> str:
@@ -169,7 +135,7 @@ async def main() -> None:
.. code-block:: python
import asyncio
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.messages import TextMessage
@@ -204,7 +170,7 @@ def __init__(
model_client: ChatCompletionClient,
*,
tools: List[Tool | Callable[..., Any] | Callable[..., Awaitable[Any]]] | None = None,
- handoffs: List[Handoff | str] | None = None,
+ handoffs: List[HandoffBase | str] | None = None,
description: str = "An agent that provides assistance with ability to use tools.",
system_message: str
| None = "You are a helpful AI assistant. Solve tasks using your tools. Reply with TERMINATE when the task has been completed.",
@@ -236,14 +202,14 @@ def __init__(
raise ValueError(f"Tool names must be unique: {tool_names}")
# Handoff tools.
self._handoff_tools: List[Tool] = []
- self._handoffs: Dict[str, Handoff] = {}
+ self._handoffs: Dict[str, HandoffBase] = {}
if handoffs is not None:
if model_client.capabilities["function_calling"] is False:
raise ValueError("The model does not support function calling, which is needed for handoffs.")
for handoff in handoffs:
if isinstance(handoff, str):
- handoff = Handoff(target=handoff)
- if isinstance(handoff, Handoff):
+ handoff = HandoffBase(target=handoff)
+ if isinstance(handoff, HandoffBase):
self._handoff_tools.append(handoff.handoff_tool)
self._handoffs[handoff.name] = handoff
else:
@@ -312,7 +278,7 @@ async def on_messages_stream(
yield tool_call_result_msg
# Detect handoff requests.
- handoffs: List[Handoff] = []
+ handoffs: List[HandoffBase] = []
for call in result.content:
if call.name in self._handoffs:
handoffs.append(self._handoffs[call.name])
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py
index 622a4d491c9..01eafa86a41 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
from typing import AsyncGenerator, List, Sequence
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from ..base import ChatAgent, Response, TaskResult
from ..messages import AgentMessage, ChatMessage, HandoffMessage, MultiModalMessage, StopMessage, TextMessage
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
index 5dd4c9008ef..4667c4a5865 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py
@@ -1,6 +1,6 @@
from typing import List, Sequence
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import CodeBlock, CodeExecutor, extract_markdown_code_blocks
from ..base import Response
@@ -28,7 +28,7 @@ class CodeExecutorAgent(BaseChatAgent):
from autogen_agentchat.agents import CodeExecutorAgent
from autogen_agentchat.messages import TextMessage
from autogen_ext.code_executors import DockerCommandLineCodeExecutor
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
async def run_code_executor_agent() -> None:
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py
index 9a8cdffaaeb..4bef5664fce 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py
@@ -1,7 +1,6 @@
from typing import AsyncGenerator, List, Sequence
-from autogen_core.base import CancellationToken
-from autogen_core.components import Image
+from autogen_core import CancellationToken, Image
from autogen_core.components.models import ChatCompletionClient
from autogen_core.components.models._types import SystemMessage
@@ -43,7 +42,7 @@ class SocietyOfMindAgent(BaseChatAgent):
from autogen_agentchat.agents import AssistantAgent, SocietyOfMindAgent
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.teams import RoundRobinGroupChat
- from autogen_agentchat.task import MaxMessageTermination
+ from autogen_agentchat.conditions import MaxMessageTermination
async def main() -> None:
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py
index 5de17f70643..d4ba81a3a6f 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py
@@ -2,7 +2,7 @@
from inspect import iscoroutinefunction
from typing import Awaitable, Callable, List, Optional, Sequence, Union, cast
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from ..base import Response
from ..messages import ChatMessage, HandoffMessage, TextMessage
@@ -33,7 +33,7 @@ class UserProxyAgent(BaseChatAgent):
For typical use cases that involve
slow human responses, it is recommended to use termination conditions
- such as :class:`~autogen_agentchat.task.HandoffTermination` or :class:`~autogen_agentchat.task.SourceMatchTermination`
+ such as :class:`~autogen_agentchat.conditions.HandoffTermination` or :class:`~autogen_agentchat.conditions.SourceMatchTermination`
to stop the running team and return the control to the application.
You can run the team again with the user input. This way, the state of the team
can be saved and restored when the user responds.
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/base/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/base/__init__.py
index 1b95d6e180f..5815adc35fa 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/base/__init__.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/base/__init__.py
@@ -1,4 +1,5 @@
from ._chat_agent import ChatAgent, Response
+from ._handoff import Handoff
from ._task import TaskResult, TaskRunner
from ._team import Team
from ._termination import TerminatedException, TerminationCondition
@@ -11,4 +12,5 @@
"TerminationCondition",
"TaskResult",
"TaskRunner",
+ "Handoff",
]
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py
index dd3a2be2c88..861389cb78c 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import AsyncGenerator, List, Protocol, Sequence, runtime_checkable
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from ..messages import AgentMessage, ChatMessage
from ._task import TaskRunner
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_handoff.py b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_handoff.py
new file mode 100644
index 00000000000..3ab859a08e8
--- /dev/null
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_handoff.py
@@ -0,0 +1,56 @@
+import logging
+from typing import Any, Dict
+
+from autogen_core.components.tools import FunctionTool, Tool
+from pydantic import BaseModel, Field, model_validator
+
+from .. import EVENT_LOGGER_NAME
+
+event_logger = logging.getLogger(EVENT_LOGGER_NAME)
+
+
+class Handoff(BaseModel):
+ """Handoff configuration."""
+
+ target: str
+ """The name of the target agent to handoff to."""
+
+ description: str = Field(default=None)
+ """The description of the handoff such as the condition under which it should happen and the target agent's ability.
+ If not provided, it is generated from the target agent's name."""
+
+ name: str = Field(default=None)
+ """The name of this handoff configuration. If not provided, it is generated from the target agent's name."""
+
+ message: str = Field(default=None)
+ """The message to the target agent.
+ If not provided, it is generated from the target agent's name."""
+
+ @model_validator(mode="before")
+ @classmethod
+ def set_defaults(cls, values: Dict[str, Any]) -> Dict[str, Any]:
+ if values.get("description") is None:
+ values["description"] = f"Handoff to {values['target']}."
+ if values.get("name") is None:
+ values["name"] = f"transfer_to_{values['target']}".lower()
+ else:
+ name = values["name"]
+ if not isinstance(name, str):
+ raise ValueError(f"Handoff name must be a string: {values['name']}")
+ # Check if name is a valid identifier.
+ if not name.isidentifier():
+ raise ValueError(f"Handoff name must be a valid identifier: {values['name']}")
+ if values.get("message") is None:
+ values["message"] = (
+ f"Transferred to {values['target']}, adopting the role of {values['target']} immediately."
+ )
+ return values
+
+ @property
+ def handoff_tool(self) -> Tool:
+ """Create a handoff tool from this handoff configuration."""
+
+ def _handoff_tool() -> str:
+ return self.message
+
+ return FunctionTool(_handoff_tool, name=self.name, description=self.description)
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_task.py b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_task.py
index d2cb39eb6fd..f617b382345 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_task.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_task.py
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import AsyncGenerator, Protocol, Sequence
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from ..messages import AgentMessage, ChatMessage
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py
index c923e8ced51..211b912c1f2 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py
@@ -23,7 +23,7 @@ class TerminationCondition(ABC):
.. code-block:: python
import asyncio
- from autogen_agentchat.task import MaxMessageTermination, TextMentionTermination
+ from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination
async def main() -> None:
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/conditions/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/conditions/__init__.py
new file mode 100644
index 00000000000..cc8e5e8312f
--- /dev/null
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/conditions/__init__.py
@@ -0,0 +1,21 @@
+from ._terminations import (
+ ExternalTermination,
+ HandoffTermination,
+ MaxMessageTermination,
+ SourceMatchTermination,
+ StopMessageTermination,
+ TextMentionTermination,
+ TimeoutTermination,
+ TokenUsageTermination,
+)
+
+__all__ = [
+ "MaxMessageTermination",
+ "TextMentionTermination",
+ "StopMessageTermination",
+ "TokenUsageTermination",
+ "HandoffTermination",
+ "TimeoutTermination",
+ "ExternalTermination",
+ "SourceMatchTermination",
+]
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/task/_terminations.py b/python/packages/autogen-agentchat/src/autogen_agentchat/conditions/_terminations.py
similarity index 99%
rename from python/packages/autogen-agentchat/src/autogen_agentchat/task/_terminations.py
rename to python/packages/autogen-agentchat/src/autogen_agentchat/conditions/_terminations.py
index 9db5b584a31..bab3e03ff35 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/task/_terminations.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/conditions/_terminations.py
@@ -218,7 +218,7 @@ class ExternalTermination(TerminationCondition):
.. code-block:: python
- from autogen_agentchat.task import ExternalTermination
+ from autogen_agentchat.conditions import ExternalTermination
termination = ExternalTermination()
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/logging/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/logging/__init__.py
deleted file mode 100644
index 8da6243cce3..00000000000
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/logging/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from ._console_log_handler import ConsoleLogHandler
-from ._file_log_handler import FileLogHandler
-
-__all__ = ["ConsoleLogHandler", "FileLogHandler"]
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/logging/_console_log_handler.py b/python/packages/autogen-agentchat/src/autogen_agentchat/logging/_console_log_handler.py
deleted file mode 100644
index cc292e76c7c..00000000000
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/logging/_console_log_handler.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import json
-import logging
-import sys
-from datetime import datetime
-
-from pydantic import BaseModel
-
-
-class ConsoleLogHandler(logging.Handler):
- def emit(self, record: logging.LogRecord) -> None:
- ts = datetime.fromtimestamp(record.created).isoformat()
- if isinstance(record.msg, BaseModel):
- record.msg = json.dumps(
- {
- "timestamp": ts,
- "message": record.msg.model_dump_json(indent=2),
- "type": record.msg.__class__.__name__,
- },
- )
- sys.stdout.write(f"{record.msg}\n")
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py b/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py
index c5a9ac21ef2..b7650d581a7 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py
@@ -1,6 +1,6 @@
from typing import List
-from autogen_core.components import FunctionCall, Image
+from autogen_core import FunctionCall, Image
from autogen_core.components.models import FunctionExecutionResult, RequestUsage
from pydantic import BaseModel, ConfigDict
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py
index d863c87cd13..6ff2077882b 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py
@@ -1,14 +1,79 @@
-from ._console import Console
-from ._terminations import (
- ExternalTermination,
- HandoffTermination,
- MaxMessageTermination,
- SourceMatchTermination,
- StopMessageTermination,
- TextMentionTermination,
- TimeoutTermination,
- TokenUsageTermination,
+from typing import AsyncGenerator, TypeVar
+
+from typing_extensions import deprecated
+
+from ..base import Response, TaskResult
+from ..conditions import (
+ ExternalTermination as ExternalTerminationAlias,
+)
+from ..conditions import (
+ HandoffTermination as HandoffTerminationAlias,
+)
+from ..conditions import (
+ MaxMessageTermination as MaxMessageTerminationAlias,
+)
+from ..conditions import (
+ SourceMatchTermination as SourceMatchTerminationAlias,
+)
+from ..conditions import (
+ StopMessageTermination as StopMessageTerminationAlias,
+)
+from ..conditions import (
+ TextMentionTermination as TextMentionTerminationAlias,
+)
+from ..conditions import (
+ TimeoutTermination as TimeoutTerminationAlias,
)
+from ..conditions import (
+ TokenUsageTermination as TokenUsageTerminationAlias,
+)
+from ..messages import AgentMessage
+from ..ui import Console as ConsoleAlias
+
+
+@deprecated("Moved to autogen_agentchat.terminations.ExternalTermination. Will remove this in 0.4.0.", stacklevel=2)
+class ExternalTermination(ExternalTerminationAlias): ...
+
+
+@deprecated("Moved to autogen_agentchat.terminations.HandoffTermination. Will remove this in 0.4.0.", stacklevel=2)
+class HandoffTermination(HandoffTerminationAlias): ...
+
+
+@deprecated("Moved to autogen_agentchat.terminations.MaxMessageTermination. Will remove this in 0.4.0.", stacklevel=2)
+class MaxMessageTermination(MaxMessageTerminationAlias): ...
+
+
+@deprecated("Moved to autogen_agentchat.terminations.SourceMatchTermination. Will remove this in 0.4.0.", stacklevel=2)
+class SourceMatchTermination(SourceMatchTerminationAlias): ...
+
+
+@deprecated("Moved to autogen_agentchat.terminations.StopMessageTermination. Will remove this in 0.4.0.", stacklevel=2)
+class StopMessageTermination(StopMessageTerminationAlias): ...
+
+
+@deprecated("Moved to autogen_agentchat.terminations.TextMentionTermination. Will remove this in 0.4.0.", stacklevel=2)
+class TextMentionTermination(TextMentionTerminationAlias): ...
+
+
+@deprecated("Moved to autogen_agentchat.terminations.TimeoutTermination. Will remove this in 0.4.0.", stacklevel=2)
+class TimeoutTermination(TimeoutTerminationAlias): ...
+
+
+@deprecated("Moved to autogen_agentchat.terminations.TokenUsageTermination. Will remove this in 0.4.0.", stacklevel=2)
+class TokenUsageTermination(TokenUsageTerminationAlias): ...
+
+
+T = TypeVar("T", bound=TaskResult | Response)
+
+
+@deprecated("Moved to autogen_agentchat.ui.Console. Will remove this in 0.4.0.", stacklevel=2)
+async def Console(
+ stream: AsyncGenerator[AgentMessage | T, None],
+ *,
+ no_inline_images: bool = False,
+) -> T:
+ return await ConsoleAlias(stream, no_inline_images=no_inline_images)
+
__all__ = [
"MaxMessageTermination",
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py
index ce333a11f03..58f87e5a5f8 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py
@@ -4,17 +4,18 @@
from abc import ABC, abstractmethod
from typing import AsyncGenerator, Callable, List
-from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import (
+from autogen_core import (
AgentId,
AgentInstantiationContext,
AgentRuntime,
AgentType,
CancellationToken,
+ ClosureAgent,
MessageContext,
+ TypeSubscription,
)
-from autogen_core.components import ClosureAgent, TypeSubscription
-from autogen_core.components._closure_agent import ClosureContext
+from autogen_core._closure_agent import ClosureContext
+from autogen_core.application import SingleThreadedAgentRuntime
from ... import EVENT_LOGGER_NAME
from ...base import ChatAgent, TaskResult, Team, TerminationCondition
@@ -175,7 +176,7 @@ async def run(
cancellation_token (CancellationToken | None): The cancellation token to kill the task immediately.
Setting the cancellation token potentially put the team in an inconsistent state,
and it may not reset the termination condition.
- To gracefully stop the team, use :class:`~autogen_agentchat.task.ExternalTermination` instead.
+ To gracefully stop the team, use :class:`~autogen_agentchat.conditions.ExternalTermination` instead.
Example using the :class:`~autogen_agentchat.teams.RoundRobinGroupChat` team:
@@ -184,7 +185,7 @@ async def run(
import asyncio
from autogen_agentchat.agents import AssistantAgent
- from autogen_agentchat.task import MaxMessageTermination
+ from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models import OpenAIChatCompletionClient
@@ -214,9 +215,9 @@ async def main() -> None:
import asyncio
from autogen_agentchat.agents import AssistantAgent
- from autogen_agentchat.task import MaxMessageTermination
+ from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
from autogen_ext.models import OpenAIChatCompletionClient
@@ -274,7 +275,7 @@ async def run_stream(
cancellation_token (CancellationToken | None): The cancellation token to kill the task immediately.
Setting the cancellation token potentially put the team in an inconsistent state,
and it may not reset the termination condition.
- To gracefully stop the team, use :class:`~autogen_agentchat.task.ExternalTermination` instead.
+ To gracefully stop the team, use :class:`~autogen_agentchat.conditions.ExternalTermination` instead.
Example using the :class:`~autogen_agentchat.teams.RoundRobinGroupChat` team:
@@ -282,7 +283,7 @@ async def run_stream(
import asyncio
from autogen_agentchat.agents import AssistantAgent
- from autogen_agentchat.task import MaxMessageTermination
+ from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models import OpenAIChatCompletionClient
@@ -314,9 +315,10 @@ async def main() -> None:
import asyncio
from autogen_agentchat.agents import AssistantAgent
- from autogen_agentchat.task import MaxMessageTermination, Console
+ from autogen_agentchat.conditions import MaxMessageTermination
+ from autogen_agentchat.ui import Console
from autogen_agentchat.teams import RoundRobinGroupChat
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
from autogen_ext.models import OpenAIChatCompletionClient
@@ -441,7 +443,7 @@ async def reset(self) -> None:
import asyncio
from autogen_agentchat.agents import AssistantAgent
- from autogen_agentchat.task import MaxMessageTermination
+ from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models import OpenAIChatCompletionClient
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat_manager.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat_manager.py
index 201db26bfba..aefe4f8d49d 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat_manager.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat_manager.py
@@ -2,8 +2,7 @@
from abc import ABC, abstractmethod
from typing import Any, List
-from autogen_core.base import MessageContext
-from autogen_core.components import DefaultTopicId, event, rpc
+from autogen_core import DefaultTopicId, MessageContext, event, rpc
from ...base import TerminationCondition
from ...messages import AgentMessage, ChatMessage, StopMessage
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_chat_agent_container.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_chat_agent_container.py
index 17c9830086b..01638def8f0 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_chat_agent_container.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_chat_agent_container.py
@@ -1,7 +1,6 @@
from typing import Any, List
-from autogen_core.base import MessageContext
-from autogen_core.components import DefaultTopicId, event, rpc
+from autogen_core import DefaultTopicId, MessageContext, event, rpc
from ...base import ChatAgent, Response
from ...messages import ChatMessage
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py
index e8d83176ff2..2a4ea7a28c3 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py
@@ -41,7 +41,7 @@ class MagenticOneGroupChat(BaseGroupChat):
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import MagenticOneGroupChat
- from autogen_agentchat.task import Console
+ from autogen_agentchat.ui import Console
async def main() -> None:
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py
index d4509a61b4f..4758ddd8d8f 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py
@@ -2,8 +2,7 @@
import logging
from typing import Any, Dict, List
-from autogen_core.base import AgentId, CancellationToken, MessageContext
-from autogen_core.components import DefaultTopicId, Image, event, rpc
+from autogen_core import AgentId, CancellationToken, DefaultTopicId, Image, MessageContext, event, rpc
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py
index f5c128a6cc2..4566bf8fe4d 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py
@@ -71,7 +71,8 @@ class RoundRobinGroupChat(BaseGroupChat):
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
- from autogen_agentchat.task import TextMentionTermination, Console
+ from autogen_agentchat.conditions import TextMentionTermination
+ from autogen_agentchat.ui import Console
async def main() -> None:
@@ -100,7 +101,8 @@ async def get_weather(location: str) -> str:
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
- from autogen_agentchat.task import TextMentionTermination, Console
+ from autogen_agentchat.conditions import TextMentionTermination
+ from autogen_agentchat.ui import Console
async def main() -> None:
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py
index cfcebd3783c..76d9108c051 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py
@@ -208,7 +208,8 @@ class SelectorGroupChat(BaseGroupChat):
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import SelectorGroupChat
- from autogen_agentchat.task import TextMentionTermination, Console
+ from autogen_agentchat.conditions import TextMentionTermination
+ from autogen_agentchat.ui import Console
async def main() -> None:
@@ -261,7 +262,8 @@ async def book_trip() -> str:
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import SelectorGroupChat
- from autogen_agentchat.task import TextMentionTermination, Console
+ from autogen_agentchat.conditions import TextMentionTermination
+ from autogen_agentchat.ui import Console
from autogen_agentchat.messages import AgentMessage
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_sequential_routed_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_sequential_routed_agent.py
index ff76586a042..ceb63d23ced 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_sequential_routed_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_sequential_routed_agent.py
@@ -1,8 +1,7 @@
import asyncio
from typing import Any
-from autogen_core.base import MessageContext
-from autogen_core.components import RoutedAgent
+from autogen_core import MessageContext, RoutedAgent
class FIFOLock:
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py
index 0e658ab7523..7feaf3736c7 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py
@@ -100,7 +100,7 @@ class Swarm(BaseGroupChat):
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import Swarm
- from autogen_agentchat.task import MaxMessageTermination
+ from autogen_agentchat.conditions import MaxMessageTermination
async def main() -> None:
@@ -127,7 +127,7 @@ async def main() -> None:
asyncio.run(main())
- Using the :class:`~autogen_agentchat.task.HandoffTermination` for human-in-the-loop handoff:
+ Using the :class:`~autogen_agentchat.conditions.HandoffTermination` for human-in-the-loop handoff:
.. code-block:: python
@@ -135,7 +135,8 @@ async def main() -> None:
from autogen_ext.models import OpenAIChatCompletionClient
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import Swarm
- from autogen_agentchat.task import HandoffTermination, Console, MaxMessageTermination
+ from autogen_agentchat.conditions import HandoffTermination, MaxMessageTermination
+ from autogen_agentchat.ui import Console
from autogen_agentchat.messages import HandoffMessage
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/ui/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/ui/__init__.py
new file mode 100644
index 00000000000..d668e02c5c2
--- /dev/null
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/ui/__init__.py
@@ -0,0 +1,3 @@
+from ._console import Console
+
+__all__ = ["Console"]
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/task/_console.py b/python/packages/autogen-agentchat/src/autogen_agentchat/ui/_console.py
similarity index 99%
rename from python/packages/autogen-agentchat/src/autogen_agentchat/task/_console.py
rename to python/packages/autogen-agentchat/src/autogen_agentchat/ui/_console.py
index 596f9de481c..4059bc477b1 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/task/_console.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/ui/_console.py
@@ -3,7 +3,7 @@
import time
from typing import AsyncGenerator, List, Optional, TypeVar, cast
-from autogen_core.components import Image
+from autogen_core import Image
from autogen_core.components.models import RequestUsage
from autogen_agentchat.base import Response, TaskResult
diff --git a/python/packages/autogen-agentchat/tests/test_assistant_agent.py b/python/packages/autogen-agentchat/tests/test_assistant_agent.py
index 086ea62ae42..b68ef70cce8 100644
--- a/python/packages/autogen-agentchat/tests/test_assistant_agent.py
+++ b/python/packages/autogen-agentchat/tests/test_assistant_agent.py
@@ -5,9 +5,8 @@
import pytest
from autogen_agentchat import EVENT_LOGGER_NAME
-from autogen_agentchat.agents import AssistantAgent, Handoff
-from autogen_agentchat.base import TaskResult
-from autogen_agentchat.logging import FileLogHandler
+from autogen_agentchat.agents import AssistantAgent
+from autogen_agentchat.base import Handoff, TaskResult
from autogen_agentchat.messages import (
HandoffMessage,
MultiModalMessage,
@@ -15,7 +14,7 @@
ToolCallMessage,
ToolCallResultMessage,
)
-from autogen_core.components import Image
+from autogen_core import Image
from autogen_core.components.tools import FunctionTool
from autogen_ext.models import OpenAIChatCompletionClient
from openai.resources.chat.completions import AsyncCompletions
@@ -24,6 +23,7 @@
from openai.types.chat.chat_completion_message import ChatCompletionMessage
from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall, Function
from openai.types.completion_usage import CompletionUsage
+from utils import FileLogHandler
logger = logging.getLogger(EVENT_LOGGER_NAME)
logger.setLevel(logging.DEBUG)
diff --git a/python/packages/autogen-agentchat/tests/test_group_chat.py b/python/packages/autogen-agentchat/tests/test_group_chat.py
index c9f2d1fd60d..b5eb7ff3f69 100644
--- a/python/packages/autogen-agentchat/tests/test_group_chat.py
+++ b/python/packages/autogen-agentchat/tests/test_group_chat.py
@@ -10,10 +10,9 @@
AssistantAgent,
BaseChatAgent,
CodeExecutorAgent,
- Handoff,
)
-from autogen_agentchat.base import Response, TaskResult
-from autogen_agentchat.logging import FileLogHandler
+from autogen_agentchat.base import Handoff, Response, TaskResult
+from autogen_agentchat.conditions import HandoffTermination, MaxMessageTermination, TextMentionTermination
from autogen_agentchat.messages import (
AgentMessage,
ChatMessage,
@@ -24,14 +23,13 @@
ToolCallMessage,
ToolCallResultMessage,
)
-from autogen_agentchat.task import Console, HandoffTermination, MaxMessageTermination, TextMentionTermination
from autogen_agentchat.teams import (
RoundRobinGroupChat,
SelectorGroupChat,
Swarm,
)
-from autogen_core.base import CancellationToken
-from autogen_core.components import FunctionCall
+from autogen_agentchat.ui import Console
+from autogen_core import CancellationToken, FunctionCall
from autogen_core.components.code_executor import LocalCommandLineCodeExecutor
from autogen_core.components.models import FunctionExecutionResult
from autogen_core.components.tools import FunctionTool
@@ -42,6 +40,7 @@
from openai.types.chat.chat_completion_message import ChatCompletionMessage
from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall, Function
from openai.types.completion_usage import CompletionUsage
+from utils import FileLogHandler
logger = logging.getLogger(EVENT_LOGGER_NAME)
logger.setLevel(logging.DEBUG)
diff --git a/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py b/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py
index a5c8d5761ee..00564928467 100644
--- a/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py
+++ b/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py
@@ -9,7 +9,6 @@
BaseChatAgent,
)
from autogen_agentchat.base import Response
-from autogen_agentchat.logging import FileLogHandler
from autogen_agentchat.messages import (
ChatMessage,
TextMessage,
@@ -17,8 +16,9 @@
from autogen_agentchat.teams import (
MagenticOneGroupChat,
)
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_ext.models import ReplayChatCompletionClient
+from utils import FileLogHandler
logger = logging.getLogger(EVENT_LOGGER_NAME)
logger.setLevel(logging.DEBUG)
diff --git a/python/packages/autogen-agentchat/tests/test_sequential_routed_agent.py b/python/packages/autogen-agentchat/tests/test_sequential_routed_agent.py
index 0d5f7c3700b..9291882cc43 100644
--- a/python/packages/autogen-agentchat/tests/test_sequential_routed_agent.py
+++ b/python/packages/autogen-agentchat/tests/test_sequential_routed_agent.py
@@ -5,9 +5,8 @@
import pytest
from autogen_agentchat.teams._group_chat._sequential_routed_agent import SequentialRoutedAgent
+from autogen_core import AgentId, DefaultTopicId, MessageContext, default_subscription, message_handler
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, MessageContext
-from autogen_core.components import DefaultTopicId, default_subscription, message_handler
@dataclass
diff --git a/python/packages/autogen-agentchat/tests/test_society_of_mind_agent.py b/python/packages/autogen-agentchat/tests/test_society_of_mind_agent.py
index 0b9f635ac7f..a62d6c1dbf9 100644
--- a/python/packages/autogen-agentchat/tests/test_society_of_mind_agent.py
+++ b/python/packages/autogen-agentchat/tests/test_society_of_mind_agent.py
@@ -3,7 +3,7 @@
import pytest
from autogen_agentchat.agents import AssistantAgent, SocietyOfMindAgent
-from autogen_agentchat.task import MaxMessageTermination
+from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models import OpenAIChatCompletionClient
from openai.resources.chat.completions import AsyncCompletions
diff --git a/python/packages/autogen-agentchat/tests/test_termination_condition.py b/python/packages/autogen-agentchat/tests/test_termination_condition.py
index ec6ff43e00c..c8df96f42bc 100644
--- a/python/packages/autogen-agentchat/tests/test_termination_condition.py
+++ b/python/packages/autogen-agentchat/tests/test_termination_condition.py
@@ -2,8 +2,7 @@
import pytest
from autogen_agentchat.base import TerminatedException
-from autogen_agentchat.messages import HandoffMessage, StopMessage, TextMessage
-from autogen_agentchat.task import (
+from autogen_agentchat.conditions import (
ExternalTermination,
HandoffTermination,
MaxMessageTermination,
@@ -13,6 +12,7 @@
TimeoutTermination,
TokenUsageTermination,
)
+from autogen_agentchat.messages import HandoffMessage, StopMessage, TextMessage
from autogen_core.components.models import RequestUsage
diff --git a/python/packages/autogen-agentchat/tests/test_userproxy_agent.py b/python/packages/autogen-agentchat/tests/test_userproxy_agent.py
index d06e209cfbb..8ff6422a696 100644
--- a/python/packages/autogen-agentchat/tests/test_userproxy_agent.py
+++ b/python/packages/autogen-agentchat/tests/test_userproxy_agent.py
@@ -5,7 +5,7 @@
from autogen_agentchat.agents import UserProxyAgent
from autogen_agentchat.base import Response
from autogen_agentchat.messages import ChatMessage, HandoffMessage, TextMessage
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
@pytest.mark.asyncio
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/logging/_file_log_handler.py b/python/packages/autogen-agentchat/tests/utils.py
similarity index 58%
rename from python/packages/autogen-agentchat/src/autogen_agentchat/logging/_file_log_handler.py
rename to python/packages/autogen-agentchat/tests/utils.py
index 1e4b402da35..90d66f0ba98 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/logging/_file_log_handler.py
+++ b/python/packages/autogen-agentchat/tests/utils.py
@@ -1,5 +1,6 @@
import json
import logging
+import sys
from datetime import datetime
from pydantic import BaseModel
@@ -22,3 +23,17 @@ def emit(self, record: logging.LogRecord) -> None:
},
)
self.file_handler.emit(record)
+
+
+class ConsoleLogHandler(logging.Handler):
+ def emit(self, record: logging.LogRecord) -> None:
+ ts = datetime.fromtimestamp(record.created).isoformat()
+ if isinstance(record.msg, BaseModel):
+ record.msg = json.dumps(
+ {
+ "timestamp": ts,
+ "message": record.msg.model_dump_json(indent=2),
+ "type": record.msg.__class__.__name__,
+ },
+ )
+ sys.stdout.write(f"{record.msg}\n")
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/company-research.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/company-research.ipynb
index 21d10aadc5d..3cc8bcbee0c 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/company-research.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/company-research.ipynb
@@ -23,7 +23,7 @@
"outputs": [],
"source": [
"from autogen_agentchat.agents import CodingAssistantAgent, ToolUseAssistantAgent\n",
- "from autogen_agentchat.task import TextMentionTermination\n",
+ "from autogen_agentchat.conditions import TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
"from autogen_core.components.tools import FunctionTool\n",
"from autogen_ext.models import OpenAIChatCompletionClient"
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/literature-review.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/literature-review.ipynb
index 94f08abdb43..e769a84b1bd 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/literature-review.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/literature-review.ipynb
@@ -23,7 +23,7 @@
"outputs": [],
"source": [
"from autogen_agentchat.agents import CodingAssistantAgent, ToolUseAssistantAgent\n",
- "from autogen_agentchat.task import TextMentionTermination\n",
+ "from autogen_agentchat.conditions import TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
"from autogen_core.components.tools import FunctionTool\n",
"from autogen_ext.models import OpenAIChatCompletionClient"
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/travel-planning.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/travel-planning.ipynb
index fbcce8f53ad..b3d16b2fe2c 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/travel-planning.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/examples/travel-planning.ipynb
@@ -18,7 +18,7 @@
"outputs": [],
"source": [
"from autogen_agentchat.agents import CodingAssistantAgent\n",
- "from autogen_agentchat.task import TextMentionTermination\n",
+ "from autogen_agentchat.conditions import TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
"from autogen_ext.models import OpenAIChatCompletionClient"
]
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.md b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.md
index 82ecb204b75..02a0b95178a 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.md
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.md
@@ -13,18 +13,9 @@ For beginner users, AgentChat is the recommended starting point.
For advanced users, [`autogen-core`](../core-user-guide/index.md)'s event-driven
programming model provides more flexibility and control over the underlying components.
-AgentChat aims to provide intuitive defaults, such as **Agents** with preset
+AgentChat provides intuitive defaults, such as **Agents** with preset
behaviors and **Teams** with predefined [multi-agent design patterns](../core-user-guide/design-patterns/index.md).
-to simplify building multi-agent applications.
-```{include} warning.md
-
-```
-
-```{tip}
-If you are interested in implementing complex agent interaction behaviours, defining custom messaging protocols, or orchestration mechanisms, consider using the [ `autogen-core`](../core-user-guide/index.md) package.
-
-```
::::{grid} 2 2 2 2
:gutter: 3
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/installation.md b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/installation.md
index c3d256e20ae..3f1b1d1496b 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/installation.md
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/installation.md
@@ -7,7 +7,7 @@ myst:
# Installation
-## Create a virtual environment (optional)
+## Create a Virtual Environment (optional)
When installing AgentChat locally, we recommend using a virtual environment for the installation. This will ensure that the dependencies for AgentChat are isolated from the rest of your system.
@@ -55,7 +55,7 @@ conda deactivate
``````
-## Intall the AgentChat package using pip
+## Install Using pip
Install the `autogen-agentchat` package using pip:
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb
index 2c45f19a270..e4f5817f1dd 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb
@@ -1,160 +1,153 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Quickstart"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "```{include} warning.md\n",
- "\n",
- "```\n",
- "\n",
- ":::{note}\n",
- "For installation instructions, please refer to the [installation guide](./installation).\n",
- ":::\n",
- "\n",
- "In AutoGen AgentChat, you can build applications quickly using preset agents.\n",
- "To illustrate this, we will begin with creating a team of a single agent\n",
- "that can use tools and respond to messages.\n",
- "\n",
- "The following code uses the OpenAI model. If you haven't already, you need to\n",
- "install the following package and extension:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "vscode": {
- "languageId": "shellscript"
- }
- },
- "outputs": [],
- "source": [
- "pip install 'autogen-agentchat==0.4.0.dev8' 'autogen-ext[openai]==0.4.0.dev8'"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "To use Azure OpenAI models and AAD authentication,\n",
- "you can follow the instructions [here](./tutorial/models.ipynb#azure-openai)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "---------- user ----------\n",
- "What is the weather in New York?\n",
- "---------- weather_agent ----------\n",
- "[FunctionCall(id='call_AhTZ2q3TNL8x0qs00e3wIZ7y', arguments='{\"city\":\"New York\"}', name='get_weather')]\n",
- "[Prompt tokens: 79, Completion tokens: 15]\n",
- "---------- weather_agent ----------\n",
- "[FunctionExecutionResult(content='The weather in New York is 73 degrees and Sunny.', call_id='call_AhTZ2q3TNL8x0qs00e3wIZ7y')]\n",
- "---------- weather_agent ----------\n",
- "The weather in New York is currently 73 degrees and sunny.\n",
- "[Prompt tokens: 90, Completion tokens: 14]\n",
- "---------- weather_agent ----------\n",
- "TERMINATE\n",
- "[Prompt tokens: 137, Completion tokens: 4]\n",
- "---------- Summary ----------\n",
- "Number of messages: 5\n",
- "Finish reason: Text 'TERMINATE' mentioned\n",
- "Total prompt tokens: 306\n",
- "Total completion tokens: 33\n",
- "Duration: 1.43 seconds\n"
- ]
- }
- ],
- "source": [
- "from autogen_agentchat.agents import AssistantAgent\n",
- "from autogen_agentchat.task import Console, TextMentionTermination\n",
- "from autogen_agentchat.teams import RoundRobinGroupChat\n",
- "from autogen_ext.models import OpenAIChatCompletionClient\n",
- "\n",
- "\n",
- "# Define a tool\n",
- "async def get_weather(city: str) -> str:\n",
- " return f\"The weather in {city} is 73 degrees and Sunny.\"\n",
- "\n",
- "\n",
- "async def main() -> None:\n",
- " # Define an agent\n",
- " weather_agent = AssistantAgent(\n",
- " name=\"weather_agent\",\n",
- " model_client=OpenAIChatCompletionClient(\n",
- " model=\"gpt-4o-2024-08-06\",\n",
- " # api_key=\"YOUR_API_KEY\",\n",
- " ),\n",
- " tools=[get_weather],\n",
- " )\n",
- "\n",
- " # Define termination condition\n",
- " termination = TextMentionTermination(\"TERMINATE\")\n",
- "\n",
- " # Define a team\n",
- " agent_team = RoundRobinGroupChat([weather_agent], termination_condition=termination)\n",
- "\n",
- " # Run the team and stream messages to the console\n",
- " stream = agent_team.run_stream(task=\"What is the weather in New York?\")\n",
- " await Console(stream)\n",
- "\n",
- "\n",
- "# NOTE: if running this inside a Python script you'll need to use asyncio.run(main()).\n",
- "await main()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "The code snippet above introduces two high level concepts in AgentChat: *Agent* and *Team*. An Agent helps us define what actions are taken when a message is received. Specifically, we use the {py:class}`~autogen_agentchat.agents.AssistantAgent` preset - an agent that can be given access to a model (e.g., LLM) and tools (functions) that it can then use to address tasks. A Team helps us define the rules for how agents interact with each other. In the {py:class}`~autogen_agentchat.teams.RoundRobinGroupChat` team, agents respond in a sequential round-robin fashion.\n",
- "In this case, we have a single agent, so the same agent is used for each round."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## What's Next?\n",
- "\n",
- "Now that you have a basic understanding of how to define an agent and a team, consider following the [tutorial](./tutorial/index) for a walkthrough on other features of AgentChat.\n",
- "\n"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": ".venv",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.5"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Quickstart"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Via AgentChat, you can build applications quickly using preset agents.\n",
+ "To illustrate this, we will begin with creating a team of a single agent\n",
+ "that can use tools and respond to messages.\n",
+ "\n",
+ "The following code uses the OpenAI model. If you haven't already, you need to\n",
+ "install the following package and extension:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "vscode": {
+ "languageId": "shellscript"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "pip install 'autogen-agentchat==0.4.0.dev8' 'autogen-ext[openai]==0.4.0.dev8'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To use Azure OpenAI models and AAD authentication,\n",
+ "you can follow the instructions [here](./tutorial/models.ipynb#azure-openai)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "---------- user ----------\n",
+ "What is the weather in New York?\n",
+ "---------- weather_agent ----------\n",
+ "[FunctionCall(id='call_AhTZ2q3TNL8x0qs00e3wIZ7y', arguments='{\"city\":\"New York\"}', name='get_weather')]\n",
+ "[Prompt tokens: 79, Completion tokens: 15]\n",
+ "---------- weather_agent ----------\n",
+ "[FunctionExecutionResult(content='The weather in New York is 73 degrees and Sunny.', call_id='call_AhTZ2q3TNL8x0qs00e3wIZ7y')]\n",
+ "---------- weather_agent ----------\n",
+ "The weather in New York is currently 73 degrees and sunny.\n",
+ "[Prompt tokens: 90, Completion tokens: 14]\n",
+ "---------- weather_agent ----------\n",
+ "TERMINATE\n",
+ "[Prompt tokens: 137, Completion tokens: 4]\n",
+ "---------- Summary ----------\n",
+ "Number of messages: 5\n",
+ "Finish reason: Text 'TERMINATE' mentioned\n",
+ "Total prompt tokens: 306\n",
+ "Total completion tokens: 33\n",
+ "Duration: 1.43 seconds\n"
+ ]
+ }
+ ],
+ "source": [
+ "from autogen_agentchat.agents import AssistantAgent\n",
+ "from autogen_agentchat.conditions import TextMentionTermination\n",
+ "from autogen_agentchat.teams import RoundRobinGroupChat\n",
+ "from autogen_agentchat.ui import Console\n",
+ "from autogen_ext.models import OpenAIChatCompletionClient\n",
+ "\n",
+ "\n",
+ "# Define a tool\n",
+ "async def get_weather(city: str) -> str:\n",
+ " return f\"The weather in {city} is 73 degrees and Sunny.\"\n",
+ "\n",
+ "\n",
+ "async def main() -> None:\n",
+ " # Define an agent\n",
+ " weather_agent = AssistantAgent(\n",
+ " name=\"weather_agent\",\n",
+ " model_client=OpenAIChatCompletionClient(\n",
+ " model=\"gpt-4o-2024-08-06\",\n",
+ " # api_key=\"YOUR_API_KEY\",\n",
+ " ),\n",
+ " tools=[get_weather],\n",
+ " )\n",
+ "\n",
+ " # Define termination condition\n",
+ " termination = TextMentionTermination(\"TERMINATE\")\n",
+ "\n",
+ " # Define a team\n",
+ " agent_team = RoundRobinGroupChat([weather_agent], termination_condition=termination)\n",
+ "\n",
+ " # Run the team and stream messages to the console\n",
+ " stream = agent_team.run_stream(task=\"What is the weather in New York?\")\n",
+ " await Console(stream)\n",
+ "\n",
+ "\n",
+ "# NOTE: if running this inside a Python script you'll need to use asyncio.run(main()).\n",
+ "await main()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The code snippet above introduces two high level concepts in AgentChat: *Agent* and *Team*. An Agent helps us define what actions are taken when a message is received. Specifically, we use the {py:class}`~autogen_agentchat.agents.AssistantAgent` preset - an agent that can be given access to a model (e.g., LLM) and tools (functions) that it can then use to address tasks. A Team helps us define the rules for how agents interact with each other. In the {py:class}`~autogen_agentchat.teams.RoundRobinGroupChat` team, agents respond in a sequential round-robin fashion.\n",
+ "In this case, we have a single agent, so the same agent is used for each round."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## What's Next?\n",
+ "\n",
+ "Now that you have a basic understanding of how to define an agent and a team, consider following the [tutorial](./tutorial/index) for a walkthrough on other features of AgentChat.\n",
+ "\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": ".venv",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.12.6"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
}
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/agents.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/agents.ipynb
index 9fa0b845fc2..7f9d789ac8d 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/agents.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/agents.ipynb
@@ -35,7 +35,7 @@
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
"from autogen_agentchat.messages import TextMessage\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"\n",
@@ -108,13 +108,13 @@
"\n",
"We can also stream each message as it is generated by the agent by using the\n",
"{py:meth}`~autogen_agentchat.agents.AssistantAgent.on_messages_stream` method,\n",
- "and use {py:class}`~autogen_agentchat.task.Console` to print the messages\n",
+ "and use {py:class}`~autogen_agentchat.ui.Console` to print the messages\n",
"as they appear to the console."
]
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
@@ -138,7 +138,7 @@
}
],
"source": [
- "from autogen_agentchat.task import Console\n",
+ "from autogen_agentchat.ui import Console\n",
"\n",
"\n",
"async def assistant_run_stream() -> None:\n",
@@ -251,7 +251,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.5"
+ "version": "3.12.6"
}
},
"nbformat": 4,
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb
index 7c90a04440b..35e145c14f6 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb
@@ -43,7 +43,7 @@
"from autogen_agentchat.agents import BaseChatAgent\n",
"from autogen_agentchat.base import Response\n",
"from autogen_agentchat.messages import AgentMessage, ChatMessage, TextMessage\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"\n",
"\n",
"class CountDownAgent(BaseChatAgent):\n",
@@ -120,7 +120,7 @@
"from autogen_agentchat.agents import BaseChatAgent\n",
"from autogen_agentchat.base import Response\n",
"from autogen_agentchat.messages import ChatMessage\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"\n",
"\n",
"class UserProxyAgent(BaseChatAgent):\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/index.md b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/index.md
index fa0ed5f6caa..597063a0c01 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/index.md
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/index.md
@@ -7,11 +7,7 @@ myst:
# Tutorial
-Tutorial to get started with AgentChat.
-
-```{include} ../warning.md
-
-```
+Get started with AgentChat through this comprehensive tutorial.
::::{grid} 2 2 2 3
:gutter: 3
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb
index bd2bcaf230f..dc521efa550 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb
@@ -1,187 +1,185 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Models\n",
- "\n",
- "In many cases, agents need access to model services such as OpenAI, Azure OpenAI, and local models.\n",
- "AgentChat utilizes model clients provided by the\n",
- "[`autogen-ext`](../../core-user-guide/framework/model-clients.ipynb) package."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## OpenAI\n",
- "\n",
- "To access OpenAI models, you need to install the `openai` extension to use the {py:class}`~autogen_ext.models.OpenAIChatCompletionClient`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "vscode": {
- "languageId": "shellscript"
- }
- },
- "outputs": [],
- "source": [
- "pip install 'autogen-ext[openai]==0.4.0.dev8'"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "You will also need to obtain an [API key](https://platform.openai.com/account/api-keys) from OpenAI."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {},
- "outputs": [],
- "source": [
- "from autogen_ext.models import OpenAIChatCompletionClient\n",
- "\n",
- "opneai_model_client = OpenAIChatCompletionClient(\n",
- " model=\"gpt-4o-2024-08-06\",\n",
- " # api_key=\"sk-...\", # Optional if you have an OPENAI_API_KEY environment variable set.\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "To test the model client, you can use the following code:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "CreateResult(finish_reason='stop', content='The capital of France is Paris.', usage=RequestUsage(prompt_tokens=15, completion_tokens=7), cached=False, logprobs=None)\n"
- ]
- }
- ],
- "source": [
- "from autogen_core.components.models import UserMessage\n",
- "\n",
- "result = await opneai_model_client.create([UserMessage(content=\"What is the capital of France?\", source=\"user\")])\n",
- "print(result)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "```{note}\n",
- "You can use this client with models hosted on OpenAI-compatible endpoints, however, we have not tested this functionality.\n",
- "See {py:class}`~autogen_ext.models.OpenAIChatCompletionClient` for more information.\n",
- "```"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Azure OpenAI\n",
- "\n",
- "Install the `azure` and `openai` extensions to use the {py:class}`~autogen_ext.models.AzureOpenAIChatCompletionClient`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "vscode": {
- "languageId": "shellscript"
- }
- },
- "outputs": [],
- "source": [
- "pip install 'autogen-ext[openai,azure]==0.4.0.dev8'"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "To use the client, you need to provide your deployment id, Azure Cognitive Services endpoint, api version, and model capabilities.\n",
- "For authentication, you can either provide an API key or an Azure Active Directory (AAD) token credential.\n",
- "\n",
- "The following code snippet shows how to use AAD authentication.\n",
- "The identity used must be assigned the [Cognitive Services OpenAI User](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/role-based-access-control#cognitive-services-openai-user) role."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from autogen_ext.models import AzureOpenAIChatCompletionClient\n",
- "from azure.identity import DefaultAzureCredential, get_bearer_token_provider\n",
- "\n",
- "# Create the token provider\n",
- "token_provider = get_bearer_token_provider(DefaultAzureCredential(), \"https://cognitiveservices.azure.com/.default\")\n",
- "\n",
- "az_model_client = AzureOpenAIChatCompletionClient(\n",
- " azure_deployment=\"{your-azure-deployment}\",\n",
- " model=\"{model-name, such as gpt-4o}\",\n",
- " api_version=\"2024-06-01\",\n",
- " azure_endpoint=\"https://{your-custom-endpoint}.openai.azure.com/\",\n",
- " azure_ad_token_provider=token_provider, # Optional if you choose key-based authentication.\n",
- " # api_key=\"sk-...\", # For key-based authentication.\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "See [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/managed-identity#chat-completions) for how to use the Azure client directly or for more info."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Local Models\n",
- "\n",
- "We are working on it. Stay tuned!"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": ".venv",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.5"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Models\n",
+ "\n",
+ "In many cases, agents need access to LLM model services such as OpenAI, Azure OpenAI, or local models. Since there are many different providers with different APIs, `autogen-core` implements a protocol for [model clients](../../core-user-guide/framework/model-clients.ipynb) and `autogen-ext` implements a set of model clients for popular model services. AgentChat can use these model clients to interact with model services. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## OpenAI\n",
+ "\n",
+ "To access OpenAI models, install the `openai` extension, which allows you to use the {py:class}`~autogen_ext.models.OpenAIChatCompletionClient`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "vscode": {
+ "languageId": "shellscript"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "pip install 'autogen-ext[openai]==0.4.0.dev8'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "You will also need to obtain an [API key](https://platform.openai.com/account/api-keys) from OpenAI."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from autogen_ext.models import OpenAIChatCompletionClient\n",
+ "\n",
+ "opneai_model_client = OpenAIChatCompletionClient(\n",
+ " model=\"gpt-4o-2024-08-06\",\n",
+ " # api_key=\"sk-...\", # Optional if you have an OPENAI_API_KEY environment variable set.\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To test the model client, you can use the following code:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "CreateResult(finish_reason='stop', content='The capital of France is Paris.', usage=RequestUsage(prompt_tokens=15, completion_tokens=7), cached=False, logprobs=None)\n"
+ ]
+ }
+ ],
+ "source": [
+ "from autogen_core.components.models import UserMessage\n",
+ "\n",
+ "result = await opneai_model_client.create([UserMessage(content=\"What is the capital of France?\", source=\"user\")])\n",
+ "print(result)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "```{note}\n",
+ "You can use this client with models hosted on OpenAI-compatible endpoints, however, we have not tested this functionality.\n",
+ "See {py:class}`~autogen_ext.models.OpenAIChatCompletionClient` for more information.\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Azure OpenAI\n",
+ "\n",
+ "Similarly, install the `azure` and `openai` extensions to use the {py:class}`~autogen_ext.models.AzureOpenAIChatCompletionClient`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "vscode": {
+ "languageId": "shellscript"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "pip install 'autogen-ext[openai,azure]==0.4.0.dev8'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To use the client, you need to provide your deployment id, Azure Cognitive Services endpoint, api version, and model capabilities.\n",
+ "For authentication, you can either provide an API key or an Azure Active Directory (AAD) token credential.\n",
+ "\n",
+ "The following code snippet shows how to use AAD authentication.\n",
+ "The identity used must be assigned the [Cognitive Services OpenAI User](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/role-based-access-control#cognitive-services-openai-user) role."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from autogen_ext.models import AzureOpenAIChatCompletionClient\n",
+ "from azure.identity import DefaultAzureCredential, get_bearer_token_provider\n",
+ "\n",
+ "# Create the token provider\n",
+ "token_provider = get_bearer_token_provider(DefaultAzureCredential(), \"https://cognitiveservices.azure.com/.default\")\n",
+ "\n",
+ "az_model_client = AzureOpenAIChatCompletionClient(\n",
+ " azure_deployment=\"{your-azure-deployment}\",\n",
+ " model=\"{model-name, such as gpt-4o}\",\n",
+ " api_version=\"2024-06-01\",\n",
+ " azure_endpoint=\"https://{your-custom-endpoint}.openai.azure.com/\",\n",
+ " azure_ad_token_provider=token_provider, # Optional if you choose key-based authentication.\n",
+ " # api_key=\"sk-...\", # For key-based authentication.\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "See [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/managed-identity#chat-completions) for how to use the Azure client directly or for more information."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Local Models\n",
+ "\n",
+ "We are working on it. Stay tuned!"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": ".venv",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.5"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
}
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/selector-group-chat.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/selector-group-chat.ipynb
index 3377d3d47c3..98b52b1ee69 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/selector-group-chat.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/selector-group-chat.ipynb
@@ -56,16 +56,17 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from typing import Sequence\n",
"\n",
"from autogen_agentchat.agents import AssistantAgent\n",
+ "from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination\n",
"from autogen_agentchat.messages import AgentMessage\n",
- "from autogen_agentchat.task import Console, MaxMessageTermination, TextMentionTermination\n",
"from autogen_agentchat.teams import SelectorGroupChat\n",
+ "from autogen_agentchat.ui import Console\n",
"from autogen_ext.models import OpenAIChatCompletionClient"
]
},
@@ -208,8 +209,8 @@
"metadata": {},
"source": [
"Let's create the team with two termination conditions:\n",
- "{py:class}`~autogen_agentchat.task.TextMentionTermination` to end the conversation when the Planning Agent sends \"TERMINATE\",\n",
- "and {py:class}`~autogen_agentchat.task.MaxMessageTermination` to limit the conversation to 25 messages to avoid infinite loop."
+ "{py:class}`~autogen_agentchat.conditions.TextMentionTermination` to end the conversation when the Planning Agent sends \"TERMINATE\",\n",
+ "and {py:class}`~autogen_agentchat.conditions.MaxMessageTermination` to limit the conversation to 25 messages to avoid infinite loop."
]
},
{
@@ -458,7 +459,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.7"
+ "version": "3.12.6"
}
},
"nbformat": 4,
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/swarm.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/swarm.ipynb
index 68e77690d45..c1583848a50 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/swarm.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/swarm.ipynb
@@ -39,7 +39,7 @@
"\n",
"For {py:class}`~autogen_agentchat.agents.AssistantAgent`, you can set the\n",
"`handoffs` argument to specify which agents it can hand off to. You can\n",
- "use {py:class}`~autogen_agentchat.agents.Handoff` to customize the message\n",
+ "use {py:class}`~autogen_agentchat.base.Handoff` to customize the message\n",
"content and handoff behavior.\n",
"\n",
"The overall process can be summarized as follows:\n",
@@ -89,16 +89,17 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from typing import Any, Dict, List\n",
"\n",
"from autogen_agentchat.agents import AssistantAgent\n",
+ "from autogen_agentchat.conditions import HandoffTermination, TextMentionTermination\n",
"from autogen_agentchat.messages import HandoffMessage\n",
- "from autogen_agentchat.task import Console, HandoffTermination, TextMentionTermination\n",
"from autogen_agentchat.teams import Swarm\n",
+ "from autogen_agentchat.ui import Console\n",
"from autogen_ext.models import OpenAIChatCompletionClient"
]
},
@@ -533,7 +534,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "autogen",
+ "display_name": ".venv",
"language": "python",
"name": "python3"
},
@@ -547,7 +548,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.7"
+ "version": "3.12.6"
}
},
"nbformat": 4,
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/teams.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/teams.ipynb
index 51976a5370d..a5599965f56 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/teams.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/teams.ipynb
@@ -46,18 +46,18 @@
"On its turn, each agent broadcasts its response to all other agents in the team, so all agents have the same context.\n",
"\n",
"We will start by creating a team with a single {py:class}`~autogen_agentchat.agents.AssistantAgent` agent\n",
- "and {py:class}`~autogen_agentchat.task.TextMentionTermination`\n",
+ "and {py:class}`~autogen_agentchat.conditions.TextMentionTermination`\n",
"termination condition that stops the team when a word is detected."
]
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
- "from autogen_agentchat.task import TextMentionTermination\n",
+ "from autogen_agentchat.conditions import TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
@@ -212,7 +212,7 @@
"source": [
"As the above example shows, you can obtain the reason why the team stopped by checking the {py:attr}`~autogen_agentchat.base.TaskResult.stop_reason` attribute.\n",
"\n",
- "There is a covenient method {py:meth}`~autogen_agentchat.task.Console` that prints the messages to the console\n",
+ "There is a covenient method {py:meth}`~autogen_agentchat.ui.Console` that prints the messages to the console\n",
"with proper formatting."
]
},
@@ -248,7 +248,7 @@
}
],
"source": [
- "from autogen_agentchat.task import Console\n",
+ "from autogen_agentchat.ui import Console\n",
"\n",
"# Use `asyncio.run(single_agent_team.reset())` when running in a script.\n",
"await single_agent_team.reset() # Reset the team for the next run.\n",
@@ -272,20 +272,21 @@
"\n",
"In this example, we will use the {py:class}`~autogen_agentchat.agents.AssistantAgent` agent class\n",
"for both the primary and critic agents.\n",
- "We will use both the {py:class}`~autogen_agentchat.task.TextMentionTermination`\n",
- "and {py:class}`~autogen_agentchat.task.MaxMessageTermination` termination conditions\n",
+ "We will use both the {py:class}`~autogen_agentchat.conditions.TextMentionTermination`\n",
+ "and {py:class}`~autogen_agentchat.conditions.MaxMessageTermination` termination conditions\n",
"together to stop the team."
]
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
- "from autogen_agentchat.task import Console, MaxMessageTermination, TextMentionTermination\n",
+ "from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
+ "from autogen_agentchat.ui import Console\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"# Create an OpenAI model client.\n",
@@ -605,7 +606,7 @@
"to continue processing the task. We will show two possible ways to do it:\n",
"\n",
"- Set the maximum number of turns such that the team stops after the specified number of turns.\n",
- "- Use the {py:class}`~autogen_agentchat.task.HandoffTermination` termination condition.\n",
+ "- Use the {py:class}`~autogen_agentchat.conditions.HandoffTermination` termination condition.\n",
"\n",
"You can also use custom termination conditions, see [Termination Conditions](./termination.ipynb)."
]
@@ -641,7 +642,7 @@
"source": [
"#### Using Handoff to Pause Team\n",
"\n",
- "You can use the {py:class}`~autogen_agentchat.task.HandoffTermination` termination condition\n",
+ "You can use the {py:class}`~autogen_agentchat.conditions.HandoffTermination` termination condition\n",
"to stop the team when an agent sends a {py:class}`~autogen_agentchat.messages.HandoffMessage` message.\n",
"\n",
"Let's create a team with a single {py:class}`~autogen_agentchat.agents.AssistantAgent` agent\n",
@@ -655,12 +656,13 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
- "from autogen_agentchat.agents import AssistantAgent, Handoff\n",
- "from autogen_agentchat.task import HandoffTermination, TextMentionTermination\n",
+ "from autogen_agentchat.agents import AssistantAgent\n",
+ "from autogen_agentchat.base import Handoff\n",
+ "from autogen_agentchat.conditions import HandoffTermination, TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
@@ -697,7 +699,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
@@ -723,7 +725,7 @@
}
],
"source": [
- "from autogen_agentchat.task import Console\n",
+ "from autogen_agentchat.ui import Console\n",
"\n",
"# Use `asyncio.run(Console(lazy_agent_team.run_stream(task=\"What is the weather in New York?\")))` when running in a script.\n",
"await Console(lazy_agent_team.run_stream(task=\"What is the weather in New York?\"))"
@@ -790,4 +792,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
-}
+}
\ No newline at end of file
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/termination.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/termination.ipynb
index 67c7582a311..683a9a8ac09 100644
--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/termination.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/termination.ipynb
@@ -31,14 +31,14 @@
"metadata": {},
"source": [
"# AutoGen provides several built-in termination conditions: \n",
- "1. {py:class}`~autogen_agentchat.task.MaxMessageTermination`: Stops after a specified number of messages have been produced, including both agent and task messages.\n",
- "2. {py:class}`~autogen_agentchat.task.TextMentionTermination`: Stops when specific text or string is mentioned in a message (e.g., \"TERMINATE\").\n",
- "3. {py:class}`~autogen_agentchat.task.TokenUsageTermination`: Stops when a certain number of prompt or completion tokens are used. This requires the agents to report token usage in their messages.\n",
- "4. {py:class}`~autogen_agentchat.task.TimeoutTermination`: Stops after a specified duration in seconds.\n",
- "5. {py:class}`~autogen_agentchat.task.HandoffTermination`: Stops when a handoff to a specific target is requested. Handoff messages can be used to build patterns such as {py:class}`~autogen_agentchat.teams.Swarm`. This is useful when you want to pause the run and allow application or user to provide input when an agent hands off to them.\n",
- "6. {py:class}`~autogen_agentchat.task.SourceMatchTermination`: Stops after a specific agent responds.\n",
- "7. {py:class}`~autogen_agentchat.task.ExternalTermination`: Enables programmatic control of termination from outside the run. This is useful for UI integration (e.g., \"Stop\" buttons in chat interfaces).\n",
- "8. {py:class}`~autogen_agentchat.task.StopMessageTermination`: Stops when a {py:class}`~autogen_agentchat.messages.StopMessage` is produced by an agent."
+ "1. {py:class}`~autogen_agentchat.conditions.MaxMessageTermination`: Stops after a specified number of messages have been produced, including both agent and task messages.\n",
+ "2. {py:class}`~autogen_agentchat.conditions.TextMentionTermination`: Stops when specific text or string is mentioned in a message (e.g., \"TERMINATE\").\n",
+ "3. {py:class}`~autogen_agentchat.conditions.TokenUsageTermination`: Stops when a certain number of prompt or completion tokens are used. This requires the agents to report token usage in their messages.\n",
+ "4. {py:class}`~autogen_agentchat.conditions.TimeoutTermination`: Stops after a specified duration in seconds.\n",
+ "5. {py:class}`~autogen_agentchat.conditions.HandoffTermination`: Stops when a handoff to a specific target is requested. Handoff messages can be used to build patterns such as {py:class}`~autogen_agentchat.teams.Swarm`. This is useful when you want to pause the run and allow application or user to provide input when an agent hands off to them.\n",
+ "6. {py:class}`~autogen_agentchat.conditions.SourceMatchTermination`: Stops after a specific agent responds.\n",
+ "7. {py:class}`~autogen_agentchat.conditions.ExternalTermination`: Enables programmatic control of termination from outside the run. This is useful for UI integration (e.g., \"Stop\" buttons in chat interfaces).\n",
+ "8. {py:class}`~autogen_agentchat.conditions.StopMessageTermination`: Stops when a {py:class}`~autogen_agentchat.messages.StopMessage` is produced by an agent."
]
},
{
@@ -50,13 +50,14 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
- "from autogen_agentchat.task import Console, MaxMessageTermination, TextMentionTermination\n",
+ "from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat\n",
+ "from autogen_agentchat.ui import Console\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"model_client = OpenAIChatCompletionClient(\n",
@@ -295,7 +296,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.5"
+ "version": "3.12.6"
}
},
"nbformat": 4,
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/extracting-results-with-an-agent.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/extracting-results-with-an-agent.ipynb
index e86b807d783..81cdaecac1c 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/extracting-results-with-an-agent.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/extracting-results-with-an-agent.ipynb
@@ -25,9 +25,8 @@
"import asyncio\n",
"from dataclasses import dataclass\n",
"\n",
- "from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import MessageContext\n",
- "from autogen_core.components import ClosureAgent, ClosureContext, DefaultSubscription, DefaultTopicId"
+ "from autogen_core import ClosureAgent, ClosureContext, DefaultSubscription, DefaultTopicId, MessageContext\n",
+ "from autogen_core.application import SingleThreadedAgentRuntime"
]
},
{
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/langgraph-agent.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/langgraph-agent.ipynb
index 5516bdc4230..513ec557665 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/langgraph-agent.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/langgraph-agent.ipynb
@@ -42,9 +42,8 @@
"from dataclasses import dataclass\n",
"from typing import Any, Callable, List, Literal\n",
"\n",
+ "from autogen_core import AgentId, MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
"from azure.identity import DefaultAzureCredential, get_bearer_token_provider\n",
"from langchain_core.messages import HumanMessage, SystemMessage\n",
"from langchain_core.tools import tool # pyright: ignore\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/llamaindex-agent.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/llamaindex-agent.ipynb
index 1bd489f6f04..71e1dc19638 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/llamaindex-agent.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/llamaindex-agent.ipynb
@@ -41,9 +41,8 @@
"from dataclasses import dataclass\n",
"from typing import List, Optional\n",
"\n",
+ "from autogen_core import AgentId, MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
"from azure.identity import DefaultAzureCredential, get_bearer_token_provider\n",
"from llama_index.core import Settings\n",
"from llama_index.core.agent import ReActAgent\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/local-llms-ollama-litellm.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/local-llms-ollama-litellm.ipynb
index 80fde2b7101..69edc8478d4 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/local-llms-ollama-litellm.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/local-llms-ollama-litellm.ipynb
@@ -39,9 +39,8 @@
"source": [
"from dataclasses import dataclass\n",
"\n",
+ "from autogen_core import AgentId, DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, MessageContext\n",
- "from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler\n",
"from autogen_core.components.model_context import BufferedChatCompletionContext\n",
"from autogen_core.components.models import (\n",
" AssistantMessage,\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/openai-assistant-agent.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/openai-assistant-agent.ipynb
index 09d18a78f2a..337e754fa88 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/openai-assistant-agent.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/openai-assistant-agent.ipynb
@@ -104,8 +104,7 @@
"from typing import Any, Callable, List\n",
"\n",
"import aiofiles\n",
- "from autogen_core.base import AgentId, MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
+ "from autogen_core import AgentId, MessageContext, RoutedAgent, message_handler\n",
"from openai import AsyncAssistantEventHandler, AsyncClient\n",
"from openai.types.beta.thread import ToolResources, ToolResourcesFileSearch\n",
"\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/termination-with-intervention.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/termination-with-intervention.ipynb
index bd37a754557..1d5387e7c92 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/termination-with-intervention.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/termination-with-intervention.ipynb
@@ -22,10 +22,9 @@
"from dataclasses import dataclass\n",
"from typing import Any\n",
"\n",
+ "from autogen_core import AgentId, DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, MessageContext\n",
- "from autogen_core.base.intervention import DefaultInterventionHandler\n",
- "from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler"
+ "from autogen_core.base.intervention import DefaultInterventionHandler"
]
},
{
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/tool-use-with-intervention.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/tool-use-with-intervention.ipynb
index e7c41c41feb..f5ac5bb2a9f 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/tool-use-with-intervention.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/tool-use-with-intervention.ipynb
@@ -19,18 +19,17 @@
"from dataclasses import dataclass\n",
"from typing import Any, List\n",
"\n",
+ "from autogen_core import AgentId, AgentType, FunctionCall, MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, AgentType, MessageContext\n",
"from autogen_core.base.intervention import DefaultInterventionHandler, DropMessage\n",
- "from autogen_core.components import FunctionCall, RoutedAgent, message_handler\n",
"from autogen_core.components.models import (\n",
" ChatCompletionClient,\n",
" LLMMessage,\n",
" SystemMessage,\n",
" UserMessage,\n",
")\n",
- "from autogen_core.components.tool_agent import ToolAgent, ToolException, tool_agent_caller_loop\n",
"from autogen_core.components.tools import PythonCodeExecutionTool, ToolSchema\n",
+ "from autogen_core.tool_agent import ToolAgent, ToolException, tool_agent_caller_loop\n",
"from autogen_ext.code_executors import DockerCommandLineCodeExecutor\n",
"from autogen_ext.models import OpenAIChatCompletionClient"
]
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/topic-subscription-scenarios.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/topic-subscription-scenarios.ipynb
index e424dddf6e6..70e2b98474e 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/topic-subscription-scenarios.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/cookbook/topic-subscription-scenarios.ipynb
@@ -44,11 +44,10 @@
"from enum import Enum\n",
"from typing import List\n",
"\n",
+ "from autogen_core import MessageContext, RoutedAgent, TopicId, TypeSubscription, message_handler\n",
+ "from autogen_core._default_subscription import DefaultSubscription\n",
+ "from autogen_core._default_topic import DefaultTopicId\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import MessageContext, TopicId\n",
- "from autogen_core.components import RoutedAgent, TypeSubscription, message_handler\n",
- "from autogen_core.components._default_subscription import DefaultSubscription\n",
- "from autogen_core.components._default_topic import DefaultTopicId\n",
"from autogen_core.components.models import (\n",
" SystemMessage,\n",
")"
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/group-chat.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/group-chat.ipynb
index 3238656c426..e5b61381213 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/group-chat.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/group-chat.ipynb
@@ -72,16 +72,17 @@
"from typing import List\n",
"\n",
"import openai\n",
- "from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import MessageContext, TopicId\n",
- "from autogen_core.components import (\n",
+ "from autogen_core import (\n",
" DefaultTopicId,\n",
" FunctionCall,\n",
" Image,\n",
+ " MessageContext,\n",
" RoutedAgent,\n",
+ " TopicId,\n",
" TypeSubscription,\n",
" message_handler,\n",
")\n",
+ "from autogen_core.application import SingleThreadedAgentRuntime\n",
"from autogen_core.components.models import (\n",
" AssistantMessage,\n",
" ChatCompletionClient,\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/handoffs.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/handoffs.ipynb
index 6fb9f71782b..c8379e97f63 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/handoffs.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/handoffs.ipynb
@@ -56,9 +56,8 @@
"import uuid\n",
"from typing import List, Tuple\n",
"\n",
+ "from autogen_core import FunctionCall, MessageContext, RoutedAgent, TopicId, TypeSubscription, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import MessageContext, TopicId\n",
- "from autogen_core.components import FunctionCall, RoutedAgent, TypeSubscription, message_handler\n",
"from autogen_core.components.models import (\n",
" AssistantMessage,\n",
" ChatCompletionClient,\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/mixture-of-agents.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/mixture-of-agents.ipynb
index 61b8b62bc22..c008eff7183 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/mixture-of-agents.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/mixture-of-agents.ipynb
@@ -38,9 +38,8 @@
"from dataclasses import dataclass\n",
"from typing import List\n",
"\n",
+ "from autogen_core import AgentId, MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
"from autogen_core.components.models import ChatCompletionClient, SystemMessage, UserMessage\n",
"from autogen_ext.models import OpenAIChatCompletionClient"
]
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/multi-agent-debate.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/multi-agent-debate.ipynb
index 72b65368791..a737c09634b 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/multi-agent-debate.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/multi-agent-debate.ipynb
@@ -43,9 +43,15 @@
"from dataclasses import dataclass\n",
"from typing import Dict, List\n",
"\n",
+ "from autogen_core import (\n",
+ " DefaultTopicId,\n",
+ " MessageContext,\n",
+ " RoutedAgent,\n",
+ " TypeSubscription,\n",
+ " default_subscription,\n",
+ " message_handler,\n",
+ ")\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import MessageContext\n",
- "from autogen_core.components import DefaultTopicId, RoutedAgent, TypeSubscription, default_subscription, message_handler\n",
"from autogen_core.components.models import (\n",
" AssistantMessage,\n",
" ChatCompletionClient,\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/reflection.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/reflection.ipynb
index f00e313b144..40a6dd68047 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/reflection.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/design-patterns/reflection.ipynb
@@ -100,8 +100,7 @@
"import uuid\n",
"from typing import Dict, List, Union\n",
"\n",
- "from autogen_core.base import MessageContext, TopicId\n",
- "from autogen_core.components import RoutedAgent, default_subscription, message_handler\n",
+ "from autogen_core import MessageContext, RoutedAgent, TopicId, default_subscription, message_handler\n",
"from autogen_core.components.models import (\n",
" AssistantMessage,\n",
" ChatCompletionClient,\n",
@@ -442,8 +441,8 @@
}
],
"source": [
+ "from autogen_core import DefaultTopicId\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.components import DefaultTopicId\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"runtime = SingleThreadedAgentRuntime()\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/agent-and-agent-runtime.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/agent-and-agent-runtime.ipynb
index c8ea98d42cb..ac61eadd36d 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/agent-and-agent-runtime.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/agent-and-agent-runtime.ipynb
@@ -55,7 +55,7 @@
"source": [
"from dataclasses import dataclass\n",
"\n",
- "from autogen_core.base import AgentId, BaseAgent, MessageContext\n",
+ "from autogen_core import AgentId, BaseAgent, MessageContext\n",
"\n",
"\n",
"@dataclass\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/command-line-code-executors.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/command-line-code-executors.ipynb
index 244d258aaec..19d0ad489c0 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/command-line-code-executors.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/command-line-code-executors.ipynb
@@ -54,7 +54,7 @@
"source": [
"from pathlib import Path\n",
"\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"from autogen_core.components.code_executor import CodeBlock\n",
"from autogen_ext.code_executors import DockerCommandLineCodeExecutor\n",
"\n",
@@ -125,7 +125,7 @@
"source": [
"from pathlib import Path\n",
"\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"from autogen_core.components.code_executor import CodeBlock, LocalCommandLineCodeExecutor\n",
"\n",
"work_dir = Path(\"coding\")\n",
@@ -171,7 +171,7 @@
"import venv\n",
"from pathlib import Path\n",
"\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"from autogen_core.components.code_executor import CodeBlock, LocalCommandLineCodeExecutor\n",
"\n",
"work_dir = Path(\"coding\")\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/distributed-agent-runtime.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/distributed-agent-runtime.ipynb
index 355b5a1f74b..50f703610b6 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/distributed-agent-runtime.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/distributed-agent-runtime.ipynb
@@ -1,223 +1,222 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Distributed Agent Runtime\n",
- "\n",
- "```{attention}\n",
- "The distributed agent runtime is an experimental feature. Expect breaking changes\n",
- "to the API.\n",
- "```\n",
- "\n",
- "A distributed agent runtime facilitates communication and agent lifecycle management\n",
- "across process boundaries.\n",
- "It consists of a host service and at least one worker runtime.\n",
- "\n",
- "The host service maintains connections to all active worker runtimes,\n",
- "facilitates message delivery, and keeps sessions for all direct messages (i.e., RPCs).\n",
- "A worker runtime processes application code (agents) and connects to the host service.\n",
- "It also advertises the agents which they support to the host service,\n",
- "so the host service can deliver messages to the correct worker.\n",
- "\n",
- "````{note}\n",
- "The distributed agent runtime requires extra dependencies, install them using:\n",
- "```bash\n",
- "pip install autogen-core[grpc]==0.4.0.dev8\n",
- "```\n",
- "````\n",
- "\n",
- "We can start a host service using {py:class}`~autogen_core.application.WorkerAgentRuntimeHost`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "from autogen_core.application import WorkerAgentRuntimeHost\n",
- "\n",
- "host = WorkerAgentRuntimeHost(address=\"localhost:50051\")\n",
- "host.start() # Start a host service in the background."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "The above code starts the host service in the background and accepts\n",
- "worker connections on port 50051.\n",
- "\n",
- "Before running worker runtimes, let's define our agent.\n",
- "The agent will publish a new message on every message it receives.\n",
- "It also keeps track of how many messages it has published, and \n",
- "stops publishing new messages once it has published 5 messages."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [],
- "source": [
- "from dataclasses import dataclass\n",
- "\n",
- "from autogen_core.base import MessageContext\n",
- "from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler\n",
- "\n",
- "\n",
- "@dataclass\n",
- "class MyMessage:\n",
- " content: str\n",
- "\n",
- "\n",
- "@default_subscription\n",
- "class MyAgent(RoutedAgent):\n",
- " def __init__(self, name: str) -> None:\n",
- " super().__init__(\"My agent\")\n",
- " self._name = name\n",
- " self._counter = 0\n",
- "\n",
- " @message_handler\n",
- " async def my_message_handler(self, message: MyMessage, ctx: MessageContext) -> None:\n",
- " self._counter += 1\n",
- " if self._counter > 5:\n",
- " return\n",
- " content = f\"{self._name}: Hello x {self._counter}\"\n",
- " print(content)\n",
- " await self.publish_message(MyMessage(content=content), DefaultTopicId())"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now we can set up the worker agent runtimes.\n",
- "We use {py:class}`~autogen_core.application.WorkerAgentRuntime`.\n",
- "We set up two worker runtimes. Each runtime hosts one agent.\n",
- "All agents publish and subscribe to the default topic, so they can see all\n",
- "messages being published.\n",
- "\n",
- "To run the agents, we publishes a message from a worker."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "worker1: Hello x 1\n",
- "worker2: Hello x 1\n",
- "worker2: Hello x 2\n",
- "worker1: Hello x 2\n",
- "worker1: Hello x 3\n",
- "worker2: Hello x 3\n",
- "worker2: Hello x 4\n",
- "worker1: Hello x 4\n",
- "worker1: Hello x 5\n",
- "worker2: Hello x 5\n"
- ]
- }
- ],
- "source": [
- "import asyncio\n",
- "\n",
- "from autogen_core.application import WorkerAgentRuntime\n",
- "\n",
- "worker1 = WorkerAgentRuntime(host_address=\"localhost:50051\")\n",
- "worker1.start()\n",
- "await MyAgent.register(worker1, \"worker1\", lambda: MyAgent(\"worker1\"))\n",
- "\n",
- "worker2 = WorkerAgentRuntime(host_address=\"localhost:50051\")\n",
- "worker2.start()\n",
- "await MyAgent.register(worker2, \"worker2\", lambda: MyAgent(\"worker2\"))\n",
- "\n",
- "await worker2.publish_message(MyMessage(content=\"Hello!\"), DefaultTopicId())\n",
- "\n",
- "# Let the agents run for a while.\n",
- "await asyncio.sleep(5)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "We can see each agent published exactly 5 messages.\n",
- "\n",
- "To stop the worker runtimes, we can call {py:meth}`~autogen_core.application.WorkerAgentRuntime.stop`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "await worker1.stop()\n",
- "await worker2.stop()\n",
- "\n",
- "# To keep the worker running until a termination signal is received (e.g., SIGTERM).\n",
- "# await worker1.stop_when_signal()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "We can call {py:meth}`~autogen_core.application.WorkerAgentRuntimeHost.stop`\n",
- "to stop the host service."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [],
- "source": [
- "await host.stop()\n",
- "\n",
- "# To keep the host service running until a termination signal (e.g., SIGTERM)\n",
- "# await host.stop_when_signal()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Next Steps\n",
- "To see complete examples of using distributed runtime, please take a look at the following samples:\n",
- "\n",
- "- [Distributed Workers](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core/samples/worker) \n",
- "- [Distributed Semantic Router](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core/samples/semantic_router) \n",
- "- [Distributed Group Chat](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core/samples/distributed-group-chat) \n"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "agnext",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Distributed Agent Runtime\n",
+ "\n",
+ "```{attention}\n",
+ "The distributed agent runtime is an experimental feature. Expect breaking changes\n",
+ "to the API.\n",
+ "```\n",
+ "\n",
+ "A distributed agent runtime facilitates communication and agent lifecycle management\n",
+ "across process boundaries.\n",
+ "It consists of a host service and at least one worker runtime.\n",
+ "\n",
+ "The host service maintains connections to all active worker runtimes,\n",
+ "facilitates message delivery, and keeps sessions for all direct messages (i.e., RPCs).\n",
+ "A worker runtime processes application code (agents) and connects to the host service.\n",
+ "It also advertises the agents which they support to the host service,\n",
+ "so the host service can deliver messages to the correct worker.\n",
+ "\n",
+ "````{note}\n",
+ "The distributed agent runtime requires extra dependencies, install them using:\n",
+ "```bash\n",
+ "pip install autogen-core[grpc]==0.4.0.dev8\n",
+ "```\n",
+ "````\n",
+ "\n",
+ "We can start a host service using {py:class}`~autogen_core.application.WorkerAgentRuntimeHost`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from autogen_core.application import WorkerAgentRuntimeHost\n",
+ "\n",
+ "host = WorkerAgentRuntimeHost(address=\"localhost:50051\")\n",
+ "host.start() # Start a host service in the background."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The above code starts the host service in the background and accepts\n",
+ "worker connections on port 50051.\n",
+ "\n",
+ "Before running worker runtimes, let's define our agent.\n",
+ "The agent will publish a new message on every message it receives.\n",
+ "It also keeps track of how many messages it has published, and \n",
+ "stops publishing new messages once it has published 5 messages."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from dataclasses import dataclass\n",
+ "\n",
+ "from autogen_core import DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler\n",
+ "\n",
+ "\n",
+ "@dataclass\n",
+ "class MyMessage:\n",
+ " content: str\n",
+ "\n",
+ "\n",
+ "@default_subscription\n",
+ "class MyAgent(RoutedAgent):\n",
+ " def __init__(self, name: str) -> None:\n",
+ " super().__init__(\"My agent\")\n",
+ " self._name = name\n",
+ " self._counter = 0\n",
+ "\n",
+ " @message_handler\n",
+ " async def my_message_handler(self, message: MyMessage, ctx: MessageContext) -> None:\n",
+ " self._counter += 1\n",
+ " if self._counter > 5:\n",
+ " return\n",
+ " content = f\"{self._name}: Hello x {self._counter}\"\n",
+ " print(content)\n",
+ " await self.publish_message(MyMessage(content=content), DefaultTopicId())"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now we can set up the worker agent runtimes.\n",
+ "We use {py:class}`~autogen_core.application.WorkerAgentRuntime`.\n",
+ "We set up two worker runtimes. Each runtime hosts one agent.\n",
+ "All agents publish and subscribe to the default topic, so they can see all\n",
+ "messages being published.\n",
+ "\n",
+ "To run the agents, we publishes a message from a worker."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "worker1: Hello x 1\n",
+ "worker2: Hello x 1\n",
+ "worker2: Hello x 2\n",
+ "worker1: Hello x 2\n",
+ "worker1: Hello x 3\n",
+ "worker2: Hello x 3\n",
+ "worker2: Hello x 4\n",
+ "worker1: Hello x 4\n",
+ "worker1: Hello x 5\n",
+ "worker2: Hello x 5\n"
+ ]
+ }
+ ],
+ "source": [
+ "import asyncio\n",
+ "\n",
+ "from autogen_core.application import WorkerAgentRuntime\n",
+ "\n",
+ "worker1 = WorkerAgentRuntime(host_address=\"localhost:50051\")\n",
+ "worker1.start()\n",
+ "await MyAgent.register(worker1, \"worker1\", lambda: MyAgent(\"worker1\"))\n",
+ "\n",
+ "worker2 = WorkerAgentRuntime(host_address=\"localhost:50051\")\n",
+ "worker2.start()\n",
+ "await MyAgent.register(worker2, \"worker2\", lambda: MyAgent(\"worker2\"))\n",
+ "\n",
+ "await worker2.publish_message(MyMessage(content=\"Hello!\"), DefaultTopicId())\n",
+ "\n",
+ "# Let the agents run for a while.\n",
+ "await asyncio.sleep(5)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can see each agent published exactly 5 messages.\n",
+ "\n",
+ "To stop the worker runtimes, we can call {py:meth}`~autogen_core.application.WorkerAgentRuntime.stop`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "await worker1.stop()\n",
+ "await worker2.stop()\n",
+ "\n",
+ "# To keep the worker running until a termination signal is received (e.g., SIGTERM).\n",
+ "# await worker1.stop_when_signal()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can call {py:meth}`~autogen_core.application.WorkerAgentRuntimeHost.stop`\n",
+ "to stop the host service."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "await host.stop()\n",
+ "\n",
+ "# To keep the host service running until a termination signal (e.g., SIGTERM)\n",
+ "# await host.stop_when_signal()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Next Steps\n",
+ "To see complete examples of using distributed runtime, please take a look at the following samples:\n",
+ "\n",
+ "- [Distributed Workers](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core/samples/worker) \n",
+ "- [Distributed Semantic Router](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core/samples/semantic_router) \n",
+ "- [Distributed Group Chat](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core/samples/distributed-group-chat) \n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "agnext",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
}
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/message-and-communication.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/message-and-communication.ipynb
index f51b31d9d33..d4f5b0ed02c 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/message-and-communication.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/message-and-communication.ipynb
@@ -90,9 +90,8 @@
"metadata": {},
"outputs": [],
"source": [
+ "from autogen_core import AgentId, MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
"\n",
"\n",
"class MyAgent(RoutedAgent):\n",
@@ -299,9 +298,8 @@
"source": [
"from dataclasses import dataclass\n",
"\n",
+ "from autogen_core import MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
"\n",
"\n",
"@dataclass\n",
@@ -420,7 +418,7 @@
"metadata": {},
"outputs": [],
"source": [
- "from autogen_core.components import RoutedAgent, message_handler, type_subscription\n",
+ "from autogen_core import RoutedAgent, message_handler, type_subscription\n",
"\n",
"\n",
"@type_subscription(topic_type=\"default\")\n",
@@ -452,7 +450,7 @@
"metadata": {},
"outputs": [],
"source": [
- "from autogen_core.base import TopicId\n",
+ "from autogen_core import TopicId\n",
"\n",
"\n",
"class BroadcastingAgent(RoutedAgent):\n",
@@ -498,7 +496,7 @@
}
],
"source": [
- "from autogen_core.components import TypeSubscription\n",
+ "from autogen_core import TypeSubscription\n",
"\n",
"runtime = SingleThreadedAgentRuntime()\n",
"\n",
@@ -561,7 +559,7 @@
"metadata": {},
"outputs": [],
"source": [
- "from autogen_core.components import DefaultTopicId, default_subscription\n",
+ "from autogen_core import DefaultTopicId, default_subscription\n",
"\n",
"\n",
"@default_subscription\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/model-clients.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/model-clients.ipynb
index e074eb970e0..1dbb0840bb9 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/model-clients.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/model-clients.ipynb
@@ -329,9 +329,8 @@
"source": [
"from dataclasses import dataclass\n",
"\n",
+ "from autogen_core import MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
"from autogen_core.components.models import ChatCompletionClient, SystemMessage, UserMessage\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
@@ -422,7 +421,7 @@
],
"source": [
"# Create the runtime and register the agent.\n",
- "from autogen_core.base import AgentId\n",
+ "from autogen_core import AgentId\n",
"\n",
"runtime = SingleThreadedAgentRuntime()\n",
"await SimpleAgent.register(\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/tools.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/tools.ipynb
index ff24095e8b5..b7859dfc63f 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/tools.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/tools.ipynb
@@ -43,7 +43,7 @@
}
],
"source": [
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"from autogen_core.components.tools import PythonCodeExecutionTool\n",
"from autogen_ext.code_executors import DockerCommandLineCodeExecutor\n",
"\n",
@@ -113,7 +113,7 @@
"source": [
"import random\n",
"\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"from autogen_core.components.tools import FunctionTool\n",
"from typing_extensions import Annotated\n",
"\n",
@@ -155,17 +155,16 @@
"from dataclasses import dataclass\n",
"from typing import List\n",
"\n",
+ "from autogen_core import AgentId, AgentInstantiationContext, MessageContext, RoutedAgent, message_handler\n",
"from autogen_core.application import SingleThreadedAgentRuntime\n",
- "from autogen_core.base import AgentId, AgentInstantiationContext, MessageContext\n",
- "from autogen_core.components import RoutedAgent, message_handler\n",
"from autogen_core.components.models import (\n",
" ChatCompletionClient,\n",
" LLMMessage,\n",
" SystemMessage,\n",
" UserMessage,\n",
")\n",
- "from autogen_core.components.tool_agent import ToolAgent, tool_agent_caller_loop\n",
"from autogen_core.components.tools import FunctionTool, Tool, ToolSchema\n",
+ "from autogen_core.tool_agent import ToolAgent, tool_agent_caller_loop\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/quickstart.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/quickstart.ipynb
index 9cc36b8fdc0..1ad55133fb7 100644
--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/quickstart.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/quickstart.ipynb
@@ -34,8 +34,7 @@
"from dataclasses import dataclass\n",
"from typing import List\n",
"\n",
- "from autogen_core.base import MessageContext\n",
- "from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler\n",
+ "from autogen_core import DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler\n",
"from autogen_core.components.code_executor import CodeExecutor, extract_markdown_code_blocks\n",
"from autogen_core.components.models import (\n",
" AssistantMessage,\n",
diff --git a/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb b/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb
index 98c6b848c05..5b06b13ef80 100644
--- a/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb
+++ b/python/packages/autogen-core/docs/src/user-guide/extensions-user-guide/azure-container-code-executor.ipynb
@@ -61,7 +61,7 @@
"import tempfile\n",
"\n",
"from anyio import open_file\n",
- "from autogen_core.base import CancellationToken\n",
+ "from autogen_core import CancellationToken\n",
"from autogen_core.components.code_executor import CodeBlock\n",
"from autogen_ext.code_executor.aca_dynamic_sessions import AzureContainerCodeExecutor\n",
"from azure.identity import DefaultAzureCredential"
diff --git a/python/packages/autogen-core/samples/chess_game.py b/python/packages/autogen-core/samples/chess_game.py
index e0bc95e1d57..4936c324252 100644
--- a/python/packages/autogen-core/samples/chess_game.py
+++ b/python/packages/autogen-core/samples/chess_game.py
@@ -7,9 +7,8 @@
import logging
from typing import Annotated, Literal
+from autogen_core import AgentId, AgentInstantiationContext, AgentRuntime, DefaultSubscription, DefaultTopicId
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, AgentInstantiationContext, AgentRuntime
-from autogen_core.components import DefaultSubscription, DefaultTopicId
from autogen_core.components.model_context import BufferedChatCompletionContext
from autogen_core.components.models import SystemMessage
from autogen_core.components.tools import FunctionTool
diff --git a/python/packages/autogen-core/samples/common/agents/_chat_completion_agent.py b/python/packages/autogen-core/samples/common/agents/_chat_completion_agent.py
index 51f53c9a26e..c36edea1860 100644
--- a/python/packages/autogen-core/samples/common/agents/_chat_completion_agent.py
+++ b/python/packages/autogen-core/samples/common/agents/_chat_completion_agent.py
@@ -2,10 +2,12 @@
import json
from typing import Any, Coroutine, Dict, List, Mapping, Sequence, Tuple
-from autogen_core.base import AgentId, CancellationToken, MessageContext
-from autogen_core.components import (
+from autogen_core import (
+ AgentId,
+ CancellationToken,
DefaultTopicId,
FunctionCall,
+ MessageContext,
RoutedAgent,
message_handler,
)
diff --git a/python/packages/autogen-core/samples/common/patterns/_group_chat_manager.py b/python/packages/autogen-core/samples/common/patterns/_group_chat_manager.py
index 22d42911858..485614ce679 100644
--- a/python/packages/autogen-core/samples/common/patterns/_group_chat_manager.py
+++ b/python/packages/autogen-core/samples/common/patterns/_group_chat_manager.py
@@ -1,8 +1,7 @@
import logging
from typing import Any, Callable, List, Mapping
-from autogen_core.base import AgentId, AgentProxy, MessageContext
-from autogen_core.components import RoutedAgent, message_handler
+from autogen_core import AgentId, AgentProxy, MessageContext, RoutedAgent, message_handler
from autogen_core.components.model_context import ChatCompletionContext
from autogen_core.components.models import ChatCompletionClient, UserMessage
diff --git a/python/packages/autogen-core/samples/common/patterns/_group_chat_utils.py b/python/packages/autogen-core/samples/common/patterns/_group_chat_utils.py
index 74633f81200..b87fdc8cae0 100644
--- a/python/packages/autogen-core/samples/common/patterns/_group_chat_utils.py
+++ b/python/packages/autogen-core/samples/common/patterns/_group_chat_utils.py
@@ -3,7 +3,7 @@
import re
from typing import Dict, List
-from autogen_core.base import AgentProxy
+from autogen_core import AgentProxy
from autogen_core.components.model_context import ChatCompletionContext
from autogen_core.components.models import ChatCompletionClient, SystemMessage, UserMessage
diff --git a/python/packages/autogen-core/samples/common/types.py b/python/packages/autogen-core/samples/common/types.py
index 028f0ab7b87..1aee6aa602a 100644
--- a/python/packages/autogen-core/samples/common/types.py
+++ b/python/packages/autogen-core/samples/common/types.py
@@ -4,7 +4,7 @@
from enum import Enum
from typing import List, Union
-from autogen_core.components import FunctionCall, Image
+from autogen_core import FunctionCall, Image
from autogen_core.components.models import FunctionExecutionResultMessage
diff --git a/python/packages/autogen-core/samples/distributed-group-chat/_agents.py b/python/packages/autogen-core/samples/distributed-group-chat/_agents.py
index 8ff935600ba..ce054777587 100644
--- a/python/packages/autogen-core/samples/distributed-group-chat/_agents.py
+++ b/python/packages/autogen-core/samples/distributed-group-chat/_agents.py
@@ -4,9 +4,8 @@
from uuid import uuid4
from _types import GroupChatMessage, MessageChunk, RequestToSpeak, UIAgentConfig
+from autogen_core import DefaultTopicId, MessageContext, RoutedAgent, message_handler
from autogen_core.application import WorkerAgentRuntime
-from autogen_core.base import MessageContext
-from autogen_core.components import DefaultTopicId, RoutedAgent, message_handler
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-core/samples/distributed-group-chat/_utils.py b/python/packages/autogen-core/samples/distributed-group-chat/_utils.py
index 431a94319fc..3869b88c281 100644
--- a/python/packages/autogen-core/samples/distributed-group-chat/_utils.py
+++ b/python/packages/autogen-core/samples/distributed-group-chat/_utils.py
@@ -4,7 +4,7 @@
import yaml
from _types import AppConfig
-from autogen_core.base import MessageSerializer, try_get_known_serializers_for_type
+from autogen_core import MessageSerializer, try_get_known_serializers_for_type
from autogen_ext.models import AzureOpenAIClientConfiguration
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
diff --git a/python/packages/autogen-core/samples/distributed-group-chat/run_editor_agent.py b/python/packages/autogen-core/samples/distributed-group-chat/run_editor_agent.py
index 8a08bfe6b47..fee5e91e6d5 100644
--- a/python/packages/autogen-core/samples/distributed-group-chat/run_editor_agent.py
+++ b/python/packages/autogen-core/samples/distributed-group-chat/run_editor_agent.py
@@ -5,10 +5,10 @@
from _agents import BaseGroupChatAgent
from _types import AppConfig, GroupChatMessage, MessageChunk, RequestToSpeak
from _utils import get_serializers, load_config, set_all_log_levels
-from autogen_core.application import WorkerAgentRuntime
-from autogen_core.components import (
+from autogen_core import (
TypeSubscription,
)
+from autogen_core.application import WorkerAgentRuntime
from autogen_ext.models import AzureOpenAIChatCompletionClient
from rich.console import Console
from rich.markdown import Markdown
diff --git a/python/packages/autogen-core/samples/distributed-group-chat/run_group_chat_manager.py b/python/packages/autogen-core/samples/distributed-group-chat/run_group_chat_manager.py
index e0b2880aa99..aa68f3c19b2 100644
--- a/python/packages/autogen-core/samples/distributed-group-chat/run_group_chat_manager.py
+++ b/python/packages/autogen-core/samples/distributed-group-chat/run_group_chat_manager.py
@@ -5,10 +5,10 @@
from _agents import GroupChatManager, publish_message_to_ui, publish_message_to_ui_and_backend
from _types import AppConfig, GroupChatMessage, MessageChunk, RequestToSpeak
from _utils import get_serializers, load_config, set_all_log_levels
-from autogen_core.application import WorkerAgentRuntime
-from autogen_core.components import (
+from autogen_core import (
TypeSubscription,
)
+from autogen_core.application import WorkerAgentRuntime
from autogen_ext.models import AzureOpenAIChatCompletionClient
from rich.console import Console
from rich.markdown import Markdown
diff --git a/python/packages/autogen-core/samples/distributed-group-chat/run_ui.py b/python/packages/autogen-core/samples/distributed-group-chat/run_ui.py
index aeb24e8d175..e4d127aa0a2 100644
--- a/python/packages/autogen-core/samples/distributed-group-chat/run_ui.py
+++ b/python/packages/autogen-core/samples/distributed-group-chat/run_ui.py
@@ -6,10 +6,10 @@
from _agents import MessageChunk, UIAgent
from _types import AppConfig, GroupChatMessage, RequestToSpeak
from _utils import get_serializers, load_config, set_all_log_levels
-from autogen_core.application import WorkerAgentRuntime
-from autogen_core.components import (
+from autogen_core import (
TypeSubscription,
)
+from autogen_core.application import WorkerAgentRuntime
from chainlit import Message # type: ignore [reportAttributeAccessIssue]
from rich.console import Console
from rich.markdown import Markdown
diff --git a/python/packages/autogen-core/samples/distributed-group-chat/run_writer_agent.py b/python/packages/autogen-core/samples/distributed-group-chat/run_writer_agent.py
index 674ed59ce3a..1168dcf0bd5 100644
--- a/python/packages/autogen-core/samples/distributed-group-chat/run_writer_agent.py
+++ b/python/packages/autogen-core/samples/distributed-group-chat/run_writer_agent.py
@@ -5,10 +5,10 @@
from _agents import BaseGroupChatAgent
from _types import AppConfig, GroupChatMessage, MessageChunk, RequestToSpeak
from _utils import get_serializers, load_config, set_all_log_levels
-from autogen_core.application import WorkerAgentRuntime
-from autogen_core.components import (
+from autogen_core import (
TypeSubscription,
)
+from autogen_core.application import WorkerAgentRuntime
from autogen_ext.models import AzureOpenAIChatCompletionClient
from rich.console import Console
from rich.markdown import Markdown
diff --git a/python/packages/autogen-core/samples/semantic_router/_agents.py b/python/packages/autogen-core/samples/semantic_router/_agents.py
index ddfc1ed6b2b..e3ca4f2e611 100644
--- a/python/packages/autogen-core/samples/semantic_router/_agents.py
+++ b/python/packages/autogen-core/samples/semantic_router/_agents.py
@@ -2,9 +2,8 @@
import logging
from _semantic_router_components import FinalResult, TerminationMessage, UserProxyMessage, WorkerAgentMessage
+from autogen_core import DefaultTopicId, MessageContext, RoutedAgent, message_handler
from autogen_core.application.logging import TRACE_LOGGER_NAME
-from autogen_core.base import MessageContext
-from autogen_core.components import DefaultTopicId, RoutedAgent, message_handler
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(f"{TRACE_LOGGER_NAME}.workers")
diff --git a/python/packages/autogen-core/samples/semantic_router/_semantic_router_agent.py b/python/packages/autogen-core/samples/semantic_router/_semantic_router_agent.py
index 5b90670739b..6d64c510c97 100644
--- a/python/packages/autogen-core/samples/semantic_router/_semantic_router_agent.py
+++ b/python/packages/autogen-core/samples/semantic_router/_semantic_router_agent.py
@@ -1,9 +1,8 @@
import logging
from _semantic_router_components import AgentRegistryBase, IntentClassifierBase, TerminationMessage, UserProxyMessage
+from autogen_core import DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler
from autogen_core.application.logging import TRACE_LOGGER_NAME
-from autogen_core.base import MessageContext
-from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(f"{TRACE_LOGGER_NAME}.semantic_router")
diff --git a/python/packages/autogen-core/samples/semantic_router/run_semantic_router.py b/python/packages/autogen-core/samples/semantic_router/run_semantic_router.py
index 35d057fb994..aacae578456 100644
--- a/python/packages/autogen-core/samples/semantic_router/run_semantic_router.py
+++ b/python/packages/autogen-core/samples/semantic_router/run_semantic_router.py
@@ -31,9 +31,8 @@
UserProxyMessage,
WorkerAgentMessage,
)
+from autogen_core import ClosureAgent, ClosureContext, DefaultSubscription, DefaultTopicId, MessageContext
from autogen_core.application import WorkerAgentRuntime
-from autogen_core.base import MessageContext
-from autogen_core.components import ClosureAgent, ClosureContext, DefaultSubscription, DefaultTopicId
class MockIntentClassifier(IntentClassifierBase):
diff --git a/python/packages/autogen-core/samples/slow_human_in_loop.py b/python/packages/autogen-core/samples/slow_human_in_loop.py
index 348b156493b..e973717c94d 100644
--- a/python/packages/autogen-core/samples/slow_human_in_loop.py
+++ b/python/packages/autogen-core/samples/slow_human_in_loop.py
@@ -30,16 +30,18 @@
from dataclasses import dataclass
from typing import Any, Mapping, Optional
-from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, CancellationToken, MessageContext
-from autogen_core.base.intervention import DefaultInterventionHandler
-from autogen_core.components import (
+from autogen_core import (
+ AgentId,
+ CancellationToken,
DefaultTopicId,
FunctionCall,
+ MessageContext,
RoutedAgent,
message_handler,
type_subscription,
)
+from autogen_core.application import SingleThreadedAgentRuntime
+from autogen_core.base.intervention import DefaultInterventionHandler
from autogen_core.components.model_context import BufferedChatCompletionContext
from autogen_core.components.models import (
AssistantMessage,
diff --git a/python/packages/autogen-core/samples/worker/agents.py b/python/packages/autogen-core/samples/worker/agents.py
index d90f4b31e24..844ac558b87 100644
--- a/python/packages/autogen-core/samples/worker/agents.py
+++ b/python/packages/autogen-core/samples/worker/agents.py
@@ -1,7 +1,6 @@
from dataclasses import dataclass
-from autogen_core.base import MessageContext
-from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler
+from autogen_core import DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler
@dataclass
diff --git a/python/packages/autogen-core/samples/worker/run_cascading_publisher.py b/python/packages/autogen-core/samples/worker/run_cascading_publisher.py
index 850ced584bc..6e6b256c199 100644
--- a/python/packages/autogen-core/samples/worker/run_cascading_publisher.py
+++ b/python/packages/autogen-core/samples/worker/run_cascading_publisher.py
@@ -1,7 +1,6 @@
from agents import CascadingMessage, ObserverAgent
+from autogen_core import DefaultTopicId, try_get_known_serializers_for_type
from autogen_core.application import WorkerAgentRuntime
-from autogen_core.base import try_get_known_serializers_for_type
-from autogen_core.components import DefaultTopicId
async def main() -> None:
diff --git a/python/packages/autogen-core/samples/worker/run_cascading_worker.py b/python/packages/autogen-core/samples/worker/run_cascading_worker.py
index 31f47b69301..052361d192c 100644
--- a/python/packages/autogen-core/samples/worker/run_cascading_worker.py
+++ b/python/packages/autogen-core/samples/worker/run_cascading_worker.py
@@ -1,8 +1,8 @@
import uuid
from agents import CascadingAgent, ReceiveMessageEvent
+from autogen_core import try_get_known_serializers_for_type
from autogen_core.application import WorkerAgentRuntime
-from autogen_core.base import try_get_known_serializers_for_type
async def main() -> None:
diff --git a/python/packages/autogen-core/samples/worker/run_worker_pub_sub.py b/python/packages/autogen-core/samples/worker/run_worker_pub_sub.py
index 616346770f1..5287e7da80f 100644
--- a/python/packages/autogen-core/samples/worker/run_worker_pub_sub.py
+++ b/python/packages/autogen-core/samples/worker/run_worker_pub_sub.py
@@ -3,9 +3,15 @@
from dataclasses import dataclass
from typing import Any, NoReturn
+from autogen_core import (
+ DefaultSubscription,
+ DefaultTopicId,
+ MessageContext,
+ RoutedAgent,
+ message_handler,
+ try_get_known_serializers_for_type,
+)
from autogen_core.application import WorkerAgentRuntime
-from autogen_core.base import MessageContext, try_get_known_serializers_for_type
-from autogen_core.components import DefaultSubscription, DefaultTopicId, RoutedAgent, message_handler
@dataclass
diff --git a/python/packages/autogen-core/samples/worker/run_worker_rpc.py b/python/packages/autogen-core/samples/worker/run_worker_rpc.py
index 804474ee005..bf5dcffaff9 100644
--- a/python/packages/autogen-core/samples/worker/run_worker_rpc.py
+++ b/python/packages/autogen-core/samples/worker/run_worker_rpc.py
@@ -2,12 +2,15 @@
import logging
from dataclasses import dataclass
-from autogen_core.application import WorkerAgentRuntime
-from autogen_core.base import (
+from autogen_core import (
AgentId,
+ DefaultSubscription,
+ DefaultTopicId,
MessageContext,
+ RoutedAgent,
+ message_handler,
)
-from autogen_core.components import DefaultSubscription, DefaultTopicId, RoutedAgent, message_handler
+from autogen_core.application import WorkerAgentRuntime
@dataclass
diff --git a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py
index cc131f5f270..df9dd633240 100644
--- a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py
+++ b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py
@@ -3,11 +3,16 @@
import os
import sys
-from autogen_core.application import WorkerAgentRuntime
-
# from protos.agents_events_pb2 import NewMessageReceived
-from autogen_core.base import PROTOBUF_DATA_CONTENT_TYPE, AgentId, try_get_known_serializers_for_type
-from autogen_core.components import DefaultSubscription, DefaultTopicId, TypeSubscription
+from autogen_core import (
+ PROTOBUF_DATA_CONTENT_TYPE,
+ AgentId,
+ DefaultSubscription,
+ DefaultTopicId,
+ TypeSubscription,
+ try_get_known_serializers_for_type,
+)
+from autogen_core.application import WorkerAgentRuntime
# Add the local package directory to sys.path
thisdir = os.path.dirname(os.path.abspath(__file__))
diff --git a/python/packages/autogen-core/samples/xlang/hello_python_agent/user_input.py b/python/packages/autogen-core/samples/xlang/hello_python_agent/user_input.py
index d2ab73e6f74..71a0c0929a2 100644
--- a/python/packages/autogen-core/samples/xlang/hello_python_agent/user_input.py
+++ b/python/packages/autogen-core/samples/xlang/hello_python_agent/user_input.py
@@ -2,8 +2,7 @@
import logging
from typing import Union
-from autogen_core.base import MessageContext
-from autogen_core.components import DefaultTopicId, RoutedAgent, message_handler
+from autogen_core import DefaultTopicId, MessageContext, RoutedAgent, message_handler
from protos.agent_events_pb2 import ConversationClosed, Input, NewMessageReceived, Output # type: ignore
input_types = Union[ConversationClosed, Input, Output]
diff --git a/python/packages/autogen-core/src/autogen_core/__init__.py b/python/packages/autogen-core/src/autogen_core/__init__.py
index 9935d7ecf32..41ac49b95f8 100644
--- a/python/packages/autogen-core/src/autogen_core/__init__.py
+++ b/python/packages/autogen-core/src/autogen_core/__init__.py
@@ -1,3 +1,69 @@
import importlib.metadata
__version__ = importlib.metadata.version("autogen_core")
+
+from ._agent import Agent
+from ._agent_id import AgentId
+from ._agent_instantiation import AgentInstantiationContext
+from ._agent_metadata import AgentMetadata
+from ._agent_proxy import AgentProxy
+from ._agent_runtime import AgentRuntime
+from ._agent_type import AgentType
+from ._base_agent import BaseAgent
+from ._cancellation_token import CancellationToken
+from ._closure_agent import ClosureAgent, ClosureContext
+from ._default_subscription import DefaultSubscription, default_subscription, type_subscription
+from ._default_topic import DefaultTopicId
+from ._image import Image
+from ._message_context import MessageContext
+from ._message_handler_context import MessageHandlerContext
+from ._routed_agent import RoutedAgent, event, message_handler, rpc
+from ._serialization import (
+ JSON_DATA_CONTENT_TYPE,
+ PROTOBUF_DATA_CONTENT_TYPE,
+ MessageSerializer,
+ UnknownPayload,
+ try_get_known_serializers_for_type,
+)
+from ._subscription import Subscription
+from ._subscription_context import SubscriptionInstantiationContext
+from ._topic import TopicId
+from ._type_prefix_subscription import TypePrefixSubscription
+from ._type_subscription import TypeSubscription
+from ._types import FunctionCall
+
+__all__ = [
+ "Agent",
+ "AgentId",
+ "AgentProxy",
+ "AgentMetadata",
+ "AgentRuntime",
+ "BaseAgent",
+ "CancellationToken",
+ "AgentInstantiationContext",
+ "TopicId",
+ "Subscription",
+ "MessageContext",
+ "AgentType",
+ "SubscriptionInstantiationContext",
+ "MessageHandlerContext",
+ "MessageSerializer",
+ "try_get_known_serializers_for_type",
+ "UnknownPayload",
+ "Image",
+ "RoutedAgent",
+ "ClosureAgent",
+ "ClosureContext",
+ "message_handler",
+ "event",
+ "rpc",
+ "FunctionCall",
+ "TypeSubscription",
+ "DefaultSubscription",
+ "DefaultTopicId",
+ "default_subscription",
+ "type_subscription",
+ "TypePrefixSubscription",
+ "JSON_DATA_CONTENT_TYPE",
+ "PROTOBUF_DATA_CONTENT_TYPE",
+]
diff --git a/python/packages/autogen-core/src/autogen_core/base/_agent.py b/python/packages/autogen-core/src/autogen_core/_agent.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_agent.py
rename to python/packages/autogen-core/src/autogen_core/_agent.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_agent_id.py b/python/packages/autogen-core/src/autogen_core/_agent_id.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_agent_id.py
rename to python/packages/autogen-core/src/autogen_core/_agent_id.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_agent_instantiation.py b/python/packages/autogen-core/src/autogen_core/_agent_instantiation.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_agent_instantiation.py
rename to python/packages/autogen-core/src/autogen_core/_agent_instantiation.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_agent_metadata.py b/python/packages/autogen-core/src/autogen_core/_agent_metadata.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_agent_metadata.py
rename to python/packages/autogen-core/src/autogen_core/_agent_metadata.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_agent_proxy.py b/python/packages/autogen-core/src/autogen_core/_agent_proxy.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_agent_proxy.py
rename to python/packages/autogen-core/src/autogen_core/_agent_proxy.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_agent_runtime.py b/python/packages/autogen-core/src/autogen_core/_agent_runtime.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_agent_runtime.py
rename to python/packages/autogen-core/src/autogen_core/_agent_runtime.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_agent_type.py b/python/packages/autogen-core/src/autogen_core/_agent_type.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_agent_type.py
rename to python/packages/autogen-core/src/autogen_core/_agent_type.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_base_agent.py b/python/packages/autogen-core/src/autogen_core/_base_agent.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_base_agent.py
rename to python/packages/autogen-core/src/autogen_core/_base_agent.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_cancellation_token.py b/python/packages/autogen-core/src/autogen_core/_cancellation_token.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_cancellation_token.py
rename to python/packages/autogen-core/src/autogen_core/_cancellation_token.py
diff --git a/python/packages/autogen-core/src/autogen_core/components/_closure_agent.py b/python/packages/autogen-core/src/autogen_core/_closure_agent.py
similarity index 89%
rename from python/packages/autogen-core/src/autogen_core/components/_closure_agent.py
rename to python/packages/autogen-core/src/autogen_core/_closure_agent.py
index df8d8154a1f..9a5e1a2c6a2 100644
--- a/python/packages/autogen-core/src/autogen_core/components/_closure_agent.py
+++ b/python/packages/autogen-core/src/autogen_core/_closure_agent.py
@@ -3,23 +3,20 @@
import inspect
from typing import Any, Awaitable, Callable, List, Mapping, Protocol, Sequence, TypeVar, get_type_hints
-from autogen_core.base._serialization import try_get_known_serializers_for_type
-from autogen_core.base._subscription_context import SubscriptionInstantiationContext
-
-from ..base import (
- AgentId,
- AgentInstantiationContext,
- AgentMetadata,
- AgentRuntime,
- AgentType,
- BaseAgent,
- CancellationToken,
- MessageContext,
- Subscription,
- TopicId,
-)
-from ..base._type_helpers import get_types
-from ..base.exceptions import CantHandleException
+from ._agent_id import AgentId
+from ._agent_instantiation import AgentInstantiationContext
+from ._agent_metadata import AgentMetadata
+from ._agent_runtime import AgentRuntime
+from ._agent_type import AgentType
+from ._base_agent import BaseAgent
+from ._cancellation_token import CancellationToken
+from ._message_context import MessageContext
+from ._serialization import try_get_known_serializers_for_type
+from ._subscription import Subscription
+from ._subscription_context import SubscriptionInstantiationContext
+from ._topic import TopicId
+from ._type_helpers import get_types
+from .exceptions import CantHandleException
T = TypeVar("T")
ClosureAgentType = TypeVar("ClosureAgentType", bound="ClosureAgent")
diff --git a/python/packages/autogen-core/src/autogen_core/components/_default_subscription.py b/python/packages/autogen-core/src/autogen_core/_default_subscription.py
similarity index 92%
rename from python/packages/autogen-core/src/autogen_core/components/_default_subscription.py
rename to python/packages/autogen-core/src/autogen_core/_default_subscription.py
index 3e1c0c4301c..d47c621094f 100644
--- a/python/packages/autogen-core/src/autogen_core/components/_default_subscription.py
+++ b/python/packages/autogen-core/src/autogen_core/_default_subscription.py
@@ -1,8 +1,9 @@
from typing import Callable, Type, TypeVar, overload
-from ..base import BaseAgent, SubscriptionInstantiationContext, subscription_factory
-from ..base.exceptions import CantHandleException
+from ._base_agent import BaseAgent, subscription_factory
+from ._subscription_context import SubscriptionInstantiationContext
from ._type_subscription import TypeSubscription
+from .exceptions import CantHandleException
class DefaultSubscription(TypeSubscription):
diff --git a/python/packages/autogen-core/src/autogen_core/components/_default_topic.py b/python/packages/autogen-core/src/autogen_core/_default_topic.py
similarity index 92%
rename from python/packages/autogen-core/src/autogen_core/components/_default_topic.py
rename to python/packages/autogen-core/src/autogen_core/_default_topic.py
index 201ff57db18..b5dde0a0ea9 100644
--- a/python/packages/autogen-core/src/autogen_core/components/_default_topic.py
+++ b/python/packages/autogen-core/src/autogen_core/_default_topic.py
@@ -1,4 +1,5 @@
-from ..base import MessageHandlerContext, TopicId
+from ._message_handler_context import MessageHandlerContext
+from ._topic import TopicId
class DefaultTopicId(TopicId):
diff --git a/python/packages/autogen-core/src/autogen_core/components/_function_utils.py b/python/packages/autogen-core/src/autogen_core/_function_utils.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/components/_function_utils.py
rename to python/packages/autogen-core/src/autogen_core/_function_utils.py
diff --git a/python/packages/autogen-core/src/autogen_core/components/_image.py b/python/packages/autogen-core/src/autogen_core/_image.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/components/_image.py
rename to python/packages/autogen-core/src/autogen_core/_image.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_message_context.py b/python/packages/autogen-core/src/autogen_core/_message_context.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_message_context.py
rename to python/packages/autogen-core/src/autogen_core/_message_context.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_message_handler_context.py b/python/packages/autogen-core/src/autogen_core/_message_handler_context.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_message_handler_context.py
rename to python/packages/autogen-core/src/autogen_core/_message_handler_context.py
diff --git a/python/packages/autogen-core/src/autogen_core/components/_pydantic_compat.py b/python/packages/autogen-core/src/autogen_core/_pydantic_compat.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/components/_pydantic_compat.py
rename to python/packages/autogen-core/src/autogen_core/_pydantic_compat.py
diff --git a/python/packages/autogen-core/src/autogen_core/components/_routed_agent.py b/python/packages/autogen-core/src/autogen_core/_routed_agent.py
similarity index 96%
rename from python/packages/autogen-core/src/autogen_core/components/_routed_agent.py
rename to python/packages/autogen-core/src/autogen_core/_routed_agent.py
index 6f21681fb49..ea23dfe633d 100644
--- a/python/packages/autogen-core/src/autogen_core/components/_routed_agent.py
+++ b/python/packages/autogen-core/src/autogen_core/_routed_agent.py
@@ -1,5 +1,4 @@
import logging
-import warnings
from functools import wraps
from typing import (
Any,
@@ -19,9 +18,11 @@
runtime_checkable,
)
-from ..base import BaseAgent, MessageContext, MessageSerializer, try_get_known_serializers_for_type
-from ..base._type_helpers import AnyType, get_types
-from ..base.exceptions import CantHandleException
+from ._base_agent import BaseAgent
+from ._message_context import MessageContext
+from ._serialization import MessageSerializer, try_get_known_serializers_for_type
+from ._type_helpers import AnyType, get_types
+from .exceptions import CantHandleException
logger = logging.getLogger("autogen_core")
@@ -423,8 +424,8 @@ class RoutedAgent(BaseAgent):
.. code-block:: python
from dataclasses import dataclass
- from autogen_core.base import MessageContext
- from autogen_core.components import RoutedAgent, event, rpc
+ from autogen_core import MessageContext
+ from autogen_core import RoutedAgent, event, rpc
@dataclass
@@ -515,12 +516,3 @@ def _handles_types(cls) -> List[Tuple[Type[Any], List[MessageSerializer[Any]]]]:
types.append((t, try_get_known_serializers_for_type(t)))
return types
-
-
-# Deprecation warning for TypeRoutedAgent
-class TypeRoutedAgent(RoutedAgent):
- """Deprecated. Use :class:`RoutedAgent` instead."""
-
- def __init__(self, description: str) -> None:
- warnings.warn("TypeRoutedAgent is deprecated. Use RoutedAgent instead.", DeprecationWarning, stacklevel=2)
- super().__init__(description)
diff --git a/python/packages/autogen-core/src/autogen_core/base/_serialization.py b/python/packages/autogen-core/src/autogen_core/_serialization.py
similarity index 99%
rename from python/packages/autogen-core/src/autogen_core/base/_serialization.py
rename to python/packages/autogen-core/src/autogen_core/_serialization.py
index 608fe9180d1..37ec9de567b 100644
--- a/python/packages/autogen-core/src/autogen_core/base/_serialization.py
+++ b/python/packages/autogen-core/src/autogen_core/_serialization.py
@@ -6,7 +6,7 @@
from google.protobuf.message import Message
from pydantic import BaseModel
-from autogen_core.base._type_helpers import is_union
+from ._type_helpers import is_union
T = TypeVar("T")
diff --git a/python/packages/autogen-core/src/autogen_core/base/_subscription.py b/python/packages/autogen-core/src/autogen_core/_subscription.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_subscription.py
rename to python/packages/autogen-core/src/autogen_core/_subscription.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_subscription_context.py b/python/packages/autogen-core/src/autogen_core/_subscription_context.py
similarity index 96%
rename from python/packages/autogen-core/src/autogen_core/base/_subscription_context.py
rename to python/packages/autogen-core/src/autogen_core/_subscription_context.py
index e67bcfc9b7a..1cfd3fd882e 100644
--- a/python/packages/autogen-core/src/autogen_core/base/_subscription_context.py
+++ b/python/packages/autogen-core/src/autogen_core/_subscription_context.py
@@ -2,7 +2,7 @@
from contextvars import ContextVar
from typing import Any, ClassVar, Generator
-from autogen_core.base._agent_type import AgentType
+from autogen_core._agent_type import AgentType
class SubscriptionInstantiationContext:
diff --git a/python/packages/autogen-core/src/autogen_core/base/_topic.py b/python/packages/autogen-core/src/autogen_core/_topic.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_topic.py
rename to python/packages/autogen-core/src/autogen_core/_topic.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_type_helpers.py b/python/packages/autogen-core/src/autogen_core/_type_helpers.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/base/_type_helpers.py
rename to python/packages/autogen-core/src/autogen_core/_type_helpers.py
diff --git a/python/packages/autogen-core/src/autogen_core/base/_type_prefix_subscription.py b/python/packages/autogen-core/src/autogen_core/_type_prefix_subscription.py
similarity index 96%
rename from python/packages/autogen-core/src/autogen_core/base/_type_prefix_subscription.py
rename to python/packages/autogen-core/src/autogen_core/_type_prefix_subscription.py
index f0011916509..4c88f12a419 100644
--- a/python/packages/autogen-core/src/autogen_core/base/_type_prefix_subscription.py
+++ b/python/packages/autogen-core/src/autogen_core/_type_prefix_subscription.py
@@ -15,7 +15,7 @@ class TypePrefixSubscription(Subscription):
.. code-block:: python
- from autogen_core.components import TypePrefixSubscription
+ from autogen_core import TypePrefixSubscription
subscription = TypePrefixSubscription(topic_type_prefix="t1", agent_type="a1")
diff --git a/python/packages/autogen-core/src/autogen_core/components/_type_subscription.py b/python/packages/autogen-core/src/autogen_core/_type_subscription.py
similarity index 89%
rename from python/packages/autogen-core/src/autogen_core/components/_type_subscription.py
rename to python/packages/autogen-core/src/autogen_core/_type_subscription.py
index 94def76595d..4ad815418fc 100644
--- a/python/packages/autogen-core/src/autogen_core/components/_type_subscription.py
+++ b/python/packages/autogen-core/src/autogen_core/_type_subscription.py
@@ -1,7 +1,9 @@
import uuid
-from ..base import AgentId, Subscription, TopicId
-from ..base.exceptions import CantHandleException
+from ._agent_id import AgentId
+from ._subscription import Subscription
+from ._topic import TopicId
+from .exceptions import CantHandleException
class TypeSubscription(Subscription):
@@ -13,7 +15,7 @@ class TypeSubscription(Subscription):
.. code-block:: python
- from autogen_core.components import TypeSubscription
+ from autogen_core import TypeSubscription
subscription = TypeSubscription(topic_type="t1", agent_type="a1")
diff --git a/python/packages/autogen-core/src/autogen_core/components/_types.py b/python/packages/autogen-core/src/autogen_core/_types.py
similarity index 100%
rename from python/packages/autogen-core/src/autogen_core/components/_types.py
rename to python/packages/autogen-core/src/autogen_core/_types.py
diff --git a/python/packages/autogen-core/src/autogen_core/application/_helpers.py b/python/packages/autogen-core/src/autogen_core/application/_helpers.py
index 18286c617d5..fe4e1697fb0 100644
--- a/python/packages/autogen-core/src/autogen_core/application/_helpers.py
+++ b/python/packages/autogen-core/src/autogen_core/application/_helpers.py
@@ -1,11 +1,11 @@
from collections import defaultdict
from typing import Awaitable, Callable, DefaultDict, List, Set
-from ..base._agent import Agent
-from ..base._agent_id import AgentId
-from ..base._agent_type import AgentType
-from ..base._subscription import Subscription
-from ..base._topic import TopicId
+from .._agent import Agent
+from .._agent_id import AgentId
+from .._agent_type import AgentType
+from .._subscription import Subscription
+from .._topic import TopicId
async def get_impl(
diff --git a/python/packages/autogen-core/src/autogen_core/application/_single_threaded_agent_runtime.py b/python/packages/autogen-core/src/autogen_core/application/_single_threaded_agent_runtime.py
index 3d81f15eb33..ebd764bc77e 100644
--- a/python/packages/autogen-core/src/autogen_core/application/_single_threaded_agent_runtime.py
+++ b/python/packages/autogen-core/src/autogen_core/application/_single_threaded_agent_runtime.py
@@ -15,9 +15,9 @@
from opentelemetry.trace import TracerProvider
from typing_extensions import deprecated
-from autogen_core.base._serialization import MessageSerializer, SerializationRegistry
+from autogen_core._serialization import MessageSerializer, SerializationRegistry
-from ..base import (
+from .. import (
Agent,
AgentId,
AgentInstantiationContext,
@@ -31,8 +31,8 @@
SubscriptionInstantiationContext,
TopicId,
)
-from ..base.exceptions import MessageDroppedException
from ..base.intervention import DropMessage, InterventionHandler
+from ..exceptions import MessageDroppedException
from ._helpers import SubscriptionManager, get_impl
from .telemetry import EnvelopeMetadata, MessageRuntimeTracingConfig, TraceHelper, get_telemetry_envelope_metadata
diff --git a/python/packages/autogen-core/src/autogen_core/application/_worker_runtime.py b/python/packages/autogen-core/src/autogen_core/application/_worker_runtime.py
index f1208ea11eb..9d186d91f30 100644
--- a/python/packages/autogen-core/src/autogen_core/application/_worker_runtime.py
+++ b/python/packages/autogen-core/src/autogen_core/application/_worker_runtime.py
@@ -34,9 +34,7 @@
from autogen_core.application.protos import cloudevent_pb2
-from ..base import (
- JSON_DATA_CONTENT_TYPE,
- PROTOBUF_DATA_CONTENT_TYPE,
+from .. import (
Agent,
AgentId,
AgentInstantiationContext,
@@ -50,9 +48,15 @@
SubscriptionInstantiationContext,
TopicId,
)
-from ..base._serialization import MessageSerializer, SerializationRegistry
-from ..base._type_helpers import ChannelArgumentType
-from ..components import TypePrefixSubscription, TypeSubscription
+from .._serialization import (
+ JSON_DATA_CONTENT_TYPE,
+ PROTOBUF_DATA_CONTENT_TYPE,
+ MessageSerializer,
+ SerializationRegistry,
+)
+from .._type_helpers import ChannelArgumentType
+from .._type_prefix_subscription import TypePrefixSubscription
+from .._type_subscription import TypeSubscription
from . import _constants
from ._constants import GRPC_IMPORT_ERROR_STR
from ._helpers import SubscriptionManager, get_impl
diff --git a/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host.py b/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host.py
index b9befce585d..ab1239a685e 100644
--- a/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host.py
+++ b/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host.py
@@ -3,7 +3,7 @@
import signal
from typing import Optional, Sequence
-from ..base._type_helpers import ChannelArgumentType
+from .._type_helpers import ChannelArgumentType
from ._constants import GRPC_IMPORT_ERROR_STR
from ._worker_runtime_host_servicer import WorkerAgentRuntimeHostServicer
diff --git a/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host_servicer.py b/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host_servicer.py
index e24a7db3f30..574f0a1b136 100644
--- a/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host_servicer.py
+++ b/python/packages/autogen-core/src/autogen_core/application/_worker_runtime_host_servicer.py
@@ -4,10 +4,8 @@
from asyncio import Future, Task
from typing import Any, Dict, Set, cast
-from autogen_core.base._type_prefix_subscription import TypePrefixSubscription
-
-from ..base import Subscription, TopicId
-from ..components import TypeSubscription
+from .. import Subscription, TopicId, TypeSubscription
+from .._type_prefix_subscription import TypePrefixSubscription
from ._constants import GRPC_IMPORT_ERROR_STR
from ._helpers import SubscriptionManager
diff --git a/python/packages/autogen-core/src/autogen_core/application/logging/events.py b/python/packages/autogen-core/src/autogen_core/application/logging/events.py
index b1446bbb96b..82affae9040 100644
--- a/python/packages/autogen-core/src/autogen_core/application/logging/events.py
+++ b/python/packages/autogen-core/src/autogen_core/application/logging/events.py
@@ -2,7 +2,7 @@
from enum import Enum
from typing import Any, cast
-from autogen_core.base import AgentId
+from autogen_core import AgentId
class LLMCallEvent:
diff --git a/python/packages/autogen-core/src/autogen_core/application/telemetry/_tracing_config.py b/python/packages/autogen-core/src/autogen_core/application/telemetry/_tracing_config.py
index 478712444a6..c21e1bfc627 100644
--- a/python/packages/autogen-core/src/autogen_core/application/telemetry/_tracing_config.py
+++ b/python/packages/autogen-core/src/autogen_core/application/telemetry/_tracing_config.py
@@ -6,7 +6,7 @@
from opentelemetry.util import types
from typing_extensions import NotRequired
-from ...base import AgentId, TopicId
+from ... import AgentId, TopicId
from ._constants import NAMESPACE
logger = logging.getLogger("autogen_core")
diff --git a/python/packages/autogen-core/src/autogen_core/base/__init__.py b/python/packages/autogen-core/src/autogen_core/base/__init__.py
index 24af0b307b6..3691ade5a79 100644
--- a/python/packages/autogen-core/src/autogen_core/base/__init__.py
+++ b/python/packages/autogen-core/src/autogen_core/base/__init__.py
@@ -2,49 +2,137 @@
The :mod:`autogen_core.base` module provides the foundational generic interfaces upon which all else is built. This module must not depend on any other module.
"""
-from ._agent import Agent
-from ._agent_id import AgentId
-from ._agent_instantiation import AgentInstantiationContext
-from ._agent_metadata import AgentMetadata
-from ._agent_proxy import AgentProxy
-from ._agent_runtime import AgentRuntime
-from ._agent_type import AgentType
-from ._base_agent import BaseAgent, subscription_factory
-from ._cancellation_token import CancellationToken
-from ._message_context import MessageContext
-from ._message_handler_context import MessageHandlerContext
-from ._serialization import (
- JSON_DATA_CONTENT_TYPE,
- PROTOBUF_DATA_CONTENT_TYPE,
- MessageSerializer,
- SerializationRegistry,
- UnknownPayload,
- try_get_known_serializers_for_type,
-)
-from ._subscription import Subscription
-from ._subscription_context import SubscriptionInstantiationContext
-from ._topic import TopicId
-
-__all__ = [
- "Agent",
- "AgentId",
- "AgentProxy",
- "AgentMetadata",
- "AgentRuntime",
- "BaseAgent",
- "CancellationToken",
- "AgentInstantiationContext",
- "TopicId",
- "Subscription",
- "MessageContext",
- "SerializationRegistry",
- "AgentType",
- "SubscriptionInstantiationContext",
- "MessageHandlerContext",
- "JSON_DATA_CONTENT_TYPE",
- "PROTOBUF_DATA_CONTENT_TYPE",
- "MessageSerializer",
- "try_get_known_serializers_for_type",
- "UnknownPayload",
- "subscription_factory",
-]
+from typing import Any, TypeVar
+
+from typing_extensions import deprecated
+
+from .._agent import Agent as AgentAlias
+from .._agent_id import AgentId as AgentIdAlias
+from .._agent_instantiation import AgentInstantiationContext as AgentInstantiationContextAlias
+from .._agent_metadata import AgentMetadata as AgentMetadataAlias
+from .._agent_proxy import AgentProxy as AgentProxyAlias
+from .._agent_runtime import AgentRuntime as AgentRuntimeAlias
+from .._agent_type import AgentType as AgentTypeAlias
+from .._base_agent import BaseAgent as BaseAgentAlias
+from .._cancellation_token import CancellationToken as CancellationTokenAlias
+from .._message_context import MessageContext as MessageContextAlias
+from .._message_handler_context import MessageHandlerContext as MessageHandlerContextAlias
+from .._serialization import (
+ MessageSerializer as MessageSerializerAlias,
+)
+from .._serialization import (
+ UnknownPayload as UnknownPayloadAlias,
+)
+from .._serialization import (
+ try_get_known_serializers_for_type as try_get_known_serializers_for_type_alias,
+)
+from .._subscription import Subscription as SubscriptionAlias
+from .._subscription_context import SubscriptionInstantiationContext as SubscriptionInstantiationContextAlias
+from .._topic import TopicId as TopicIdAlias
+
+
+@deprecated("autogen_core.base.Agent moved to autogen_core.Agent. This alias will be removed in 0.4.0.")
+class Agent(AgentAlias):
+ pass
+
+
+@deprecated("autogen_core.base.AgentId moved to autogen_core.AgentId. This alias will be removed in 0.4.0.")
+class AgentId(AgentIdAlias):
+ pass
+
+
+@deprecated(
+ "autogen_core.base.AgentInstantiationContext moved to autogen_core.AgentInstantiationContext. This alias will be removed in 0.4.0."
+)
+class AgentInstantiationContext(AgentInstantiationContextAlias):
+ pass
+
+
+@deprecated("autogen_core.base.AgentMetadata moved to autogen_core.AgentMetadata. This alias will be removed in 0.4.0.")
+class AgentMetadata(AgentMetadataAlias):
+ pass
+
+
+@deprecated("autogen_core.base.AgentProxy moved to autogen_core.AgentProxy. This alias will be removed in 0.4.0.")
+class AgentProxy(AgentProxyAlias):
+ pass
+
+
+@deprecated("autogen_core.base.AgentRuntime moved to autogen_core.AgentRuntime. This alias will be removed in 0.4.0.")
+class AgentRuntime(AgentRuntimeAlias):
+ pass
+
+
+@deprecated("autogen_core.base.AgentType moved to autogen_core.AgentType. This alias will be removed in 0.4.0.")
+class AgentType(AgentTypeAlias):
+ pass
+
+
+@deprecated("autogen_core.base.BaseAgent moved to autogen_core.BaseAgent. This alias will be removed in 0.4.0.")
+class BaseAgent(BaseAgentAlias):
+ pass
+
+
+@deprecated(
+ "autogen_core.base.CancellationToken moved to autogen_core.CancellationToken. This alias will be removed in 0.4.0."
+)
+class CancellationToken(CancellationTokenAlias):
+ pass
+
+
+@deprecated(
+ "autogen_core.base.MessageContext moved to autogen_core.MessageContext. This alias will be removed in 0.4.0."
+)
+class MessageContext(MessageContextAlias):
+ pass
+
+
+@deprecated(
+ "autogen_core.base.MessageHandlerContext moved to autogen_core.MessageHandlerContext. This alias will be removed in 0.4.0."
+)
+class MessageHandlerContext(MessageHandlerContextAlias):
+ pass
+
+
+@deprecated(
+ "autogen_core.base.UnknownPayloadAlias moved to autogen_core.UnknownPayloadAlias. This alias will be removed in 0.4.0."
+)
+class UnknownPayload(UnknownPayloadAlias):
+ pass
+
+
+T = TypeVar("T")
+
+
+@deprecated(
+ "autogen_core.base.MessageSerializer moved to autogen_core.MessageSerializer. This alias will be removed in 0.4.0."
+)
+class MessageSerializer(MessageSerializerAlias[T]):
+ pass
+
+
+@deprecated("autogen_core.base.Subscription moved to autogen_core.Subscription. This alias will be removed in 0.4.0.")
+class Subscription(SubscriptionAlias):
+ pass
+
+
+@deprecated(
+ "autogen_core.base.try_get_known_serializers_for_type moved to autogen_core.try_get_known_serializers_for_type. This alias will be removed in 0.4.0."
+)
+def try_get_known_serializers_for_type(cls: type[Any]) -> list[MessageSerializerAlias[Any]]:
+ return try_get_known_serializers_for_type_alias(cls)
+
+
+@deprecated(
+ "autogen_core.base.SubscriptionInstantiationContext moved to autogen_core.SubscriptionInstantiationContext. This alias will be removed in 0.4.0."
+)
+class SubscriptionInstantiationContext(SubscriptionInstantiationContextAlias):
+ pass
+
+
+@deprecated("autogen_core.base.TopicId moved to autogen_core.TopicId. This alias will be removed in 0.4.0.")
+class TopicId(TopicIdAlias):
+ pass
+
+
+__all__ = [] # type: ignore
diff --git a/python/packages/autogen-core/src/autogen_core/base/exceptions.py b/python/packages/autogen-core/src/autogen_core/base/exceptions.py
index f35c3fbfebf..f1fea9f8162 100644
--- a/python/packages/autogen-core/src/autogen_core/base/exceptions.py
+++ b/python/packages/autogen-core/src/autogen_core/base/exceptions.py
@@ -1,21 +1,37 @@
-__all__ = [
- "CantHandleException",
- "UndeliverableException",
- "MessageDroppedException",
-]
-
-
-class CantHandleException(Exception):
+from typing_extensions import deprecated
+
+from ..exceptions import (
+ CantHandleException as CantHandleExceptionAlias,
+)
+from ..exceptions import (
+ MessageDroppedException as MessageDroppedExceptionAlias,
+)
+from ..exceptions import (
+ NotAccessibleError as NotAccessibleErrorAlias,
+)
+from ..exceptions import (
+ UndeliverableException as UndeliverableExceptionAlias,
+)
+
+
+@deprecated("Moved to autogen_core.exceptions.CantHandleException. Alias will be removed in 0.4.0")
+class CantHandleException(CantHandleExceptionAlias):
"""Raised when a handler can't handle the exception."""
-class UndeliverableException(Exception):
+@deprecated("Moved to autogen_core.exceptions.UndeliverableException. Alias will be removed in 0.4.0")
+class UndeliverableException(UndeliverableExceptionAlias):
"""Raised when a message can't be delivered."""
-class MessageDroppedException(Exception):
+@deprecated("Moved to autogen_core.exceptions.MessageDroppedException. Alias will be removed in 0.4.0")
+class MessageDroppedException(MessageDroppedExceptionAlias):
"""Raised when a message is dropped."""
-class NotAccessibleError(Exception):
+@deprecated("Moved to autogen_core.exceptions.NotAccessibleError. Alias will be removed in 0.4.0")
+class NotAccessibleError(NotAccessibleErrorAlias):
"""Tried to access a value that is not accessible. For example if it is remote cannot be accessed locally."""
+
+
+__all__ = [] # type: ignore
diff --git a/python/packages/autogen-core/src/autogen_core/base/intervention.py b/python/packages/autogen-core/src/autogen_core/base/intervention.py
index 3b771c931a3..5fe337b8776 100644
--- a/python/packages/autogen-core/src/autogen_core/base/intervention.py
+++ b/python/packages/autogen-core/src/autogen_core/base/intervention.py
@@ -1,6 +1,6 @@
from typing import Any, Awaitable, Callable, Protocol, final
-from autogen_core.base import AgentId
+from .._agent_id import AgentId
__all__ = [
"DropMessage",
diff --git a/python/packages/autogen-core/src/autogen_core/components/__init__.py b/python/packages/autogen-core/src/autogen_core/components/__init__.py
index 37d1ad48a06..7ef165f16cc 100644
--- a/python/packages/autogen-core/src/autogen_core/components/__init__.py
+++ b/python/packages/autogen-core/src/autogen_core/components/__init__.py
@@ -2,29 +2,114 @@
The :mod:`autogen_core.components` module provides building blocks for creating single agents
"""
-from ..base._type_prefix_subscription import TypePrefixSubscription
-from ._closure_agent import ClosureAgent, ClosureContext
-from ._default_subscription import DefaultSubscription, default_subscription, type_subscription
-from ._default_topic import DefaultTopicId
-from ._image import Image
-from ._routed_agent import RoutedAgent, TypeRoutedAgent, event, message_handler, rpc
-from ._type_subscription import TypeSubscription
-from ._types import FunctionCall
-
-__all__ = [
- "Image",
- "RoutedAgent",
- "TypeRoutedAgent",
- "ClosureAgent",
- "ClosureContext",
- "message_handler",
- "event",
- "rpc",
- "FunctionCall",
- "TypeSubscription",
- "DefaultSubscription",
- "DefaultTopicId",
- "default_subscription",
- "type_subscription",
- "TypePrefixSubscription",
-]
+from typing import Any, Callable, Type, TypeVar
+
+from typing_extensions import deprecated
+
+from .._base_agent import BaseAgent
+from .._closure_agent import ClosureAgent as ClosureAgentAlias
+from .._closure_agent import ClosureContext as ClosureContextAlias
+from .._default_subscription import (
+ DefaultSubscription as DefaultSubscriptionAlias,
+)
+from .._default_subscription import (
+ default_subscription as default_subscription_alias,
+)
+from .._default_subscription import (
+ type_subscription as type_subscription_alias,
+)
+from .._default_topic import DefaultTopicId as DefaultTopicIdAlias
+from .._image import Image as ImageAlias
+from .._routed_agent import (
+ RoutedAgent as RoutedAgentAlias,
+)
+from .._routed_agent import (
+ event as event_alias,
+)
+from .._routed_agent import (
+ message_handler as message_handler_alias,
+)
+from .._routed_agent import (
+ rpc as rpc_aliass,
+)
+from .._type_prefix_subscription import TypePrefixSubscription as TypePrefixSubscriptionAlias
+from .._type_subscription import TypeSubscription as TypeSubscriptionAlias
+from .._types import FunctionCall as FunctionCallAlias
+
+__all__ = [] # type: ignore
+
+
+@deprecated("Moved to autogen_core.TypePrefixSubscription. Will be removed in 0.4.0")
+class TypePrefixSubscription(TypePrefixSubscriptionAlias):
+ pass
+
+
+@deprecated("Moved to autogen_core.TypeSubscription. Will be removed in 0.4.0")
+class TypeSubscription(TypeSubscriptionAlias):
+ pass
+
+
+@deprecated("Moved to autogen_core.ClosureAgent. Will be removed in 0.4.0")
+class ClosureAgent(ClosureAgentAlias):
+ pass
+
+
+@deprecated("Moved to autogen_core.ClosureContext. Will be removed in 0.4.0")
+class ClosureContext(ClosureContextAlias):
+ pass
+
+
+@deprecated("Moved to autogen_core.DefaultSubscription. Will be removed in 0.4.0")
+class DefaultSubscription(DefaultSubscriptionAlias):
+ pass
+
+
+BaseAgentType = TypeVar("BaseAgentType", bound="BaseAgent")
+
+
+@deprecated("Moved to autogen_core.default_subscription. Will be removed in 0.4.0")
+def default_subscription(
+ cls: Type[BaseAgentType] | None = None,
+) -> Callable[[Type[BaseAgentType]], Type[BaseAgentType]] | Type[BaseAgentType]:
+ return default_subscription_alias(cls) # type: ignore
+
+
+@deprecated("Moved to autogen_core.type_subscription. Will be removed in 0.4.0")
+def type_subscription(topic_type: str) -> Callable[[Type[BaseAgentType]], Type[BaseAgentType]]:
+ return type_subscription_alias(topic_type)
+
+
+@deprecated("Moved to autogen_core.DefaultTopicId. Will be removed in 0.4.0")
+class DefaultTopicId(DefaultTopicIdAlias):
+ pass
+
+
+@deprecated("Moved to autogen_core.Image. Will be removed in 0.4.0")
+class Image(ImageAlias):
+ pass
+
+
+@deprecated("Moved to autogen_core.RoutedAgent. Will be removed in 0.4.0")
+class RoutedAgent(RoutedAgentAlias):
+ pass
+
+
+# Generic forwarding of all args to the alias
+@deprecated("Moved to autogen_core.event. Will be removed in 0.4.0")
+def event(*args: Any, **kwargs: Any) -> Any:
+ return event_alias(*args, **kwargs) # type: ignore
+
+
+@deprecated("Moved to autogen_core.message_handler. Will be removed in 0.4.0")
+def message_handler(*args: Any, **kwargs: Any) -> Any:
+ return message_handler_alias(*args, **kwargs) # type: ignore
+
+
+@deprecated("Moved to autogen_core.rpc. Will be removed in 0.4.0")
+def rpc(*args: Any, **kwargs: Any) -> Any:
+ return rpc_aliass(*args, **kwargs) # type: ignore
+
+
+@deprecated("Moved to autogen_core.FunctionCall. Will be removed in 0.4.0")
+class FunctionCall(FunctionCallAlias):
+ pass
diff --git a/python/packages/autogen-core/src/autogen_core/components/code_executor/_base.py b/python/packages/autogen-core/src/autogen_core/components/code_executor/_base.py
index 238c8d01442..4c12f573580 100644
--- a/python/packages/autogen-core/src/autogen_core/components/code_executor/_base.py
+++ b/python/packages/autogen-core/src/autogen_core/components/code_executor/_base.py
@@ -6,7 +6,7 @@
from dataclasses import dataclass
from typing import List, Protocol, runtime_checkable
-from autogen_core.base import CancellationToken
+from ... import CancellationToken
@dataclass
diff --git a/python/packages/autogen-core/src/autogen_core/components/code_executor/_impl/local_commandline_code_executor.py b/python/packages/autogen-core/src/autogen_core/components/code_executor/_impl/local_commandline_code_executor.py
index 31779f65679..01e09888190 100644
--- a/python/packages/autogen-core/src/autogen_core/components/code_executor/_impl/local_commandline_code_executor.py
+++ b/python/packages/autogen-core/src/autogen_core/components/code_executor/_impl/local_commandline_code_executor.py
@@ -14,7 +14,7 @@
from typing_extensions import ParamSpec
-from ....base import CancellationToken
+from .... import CancellationToken
from .._base import CodeBlock, CodeExecutor
from .._func_with_reqs import (
FunctionWithRequirements,
@@ -69,7 +69,7 @@ class LocalCommandLineCodeExecutor(CodeExecutor):
from pathlib import Path
import asyncio
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
from autogen_core.components.code_executor import CodeBlock, LocalCommandLineCodeExecutor
diff --git a/python/packages/autogen-core/src/autogen_core/components/model_context/_head_and_tail_chat_completion_context.py b/python/packages/autogen-core/src/autogen_core/components/model_context/_head_and_tail_chat_completion_context.py
index ab50df41626..0caa5546095 100644
--- a/python/packages/autogen-core/src/autogen_core/components/model_context/_head_and_tail_chat_completion_context.py
+++ b/python/packages/autogen-core/src/autogen_core/components/model_context/_head_and_tail_chat_completion_context.py
@@ -1,6 +1,6 @@
from typing import Any, List, Mapping
-from .._types import FunctionCall
+from ..._types import FunctionCall
from ..models import AssistantMessage, FunctionExecutionResultMessage, LLMMessage, UserMessage
from ._chat_completion_context import ChatCompletionContext
diff --git a/python/packages/autogen-core/src/autogen_core/components/models/_model_client.py b/python/packages/autogen-core/src/autogen_core/components/models/_model_client.py
index 532bb2ea125..dec6dd221fe 100644
--- a/python/packages/autogen-core/src/autogen_core/components/models/_model_client.py
+++ b/python/packages/autogen-core/src/autogen_core/components/models/_model_client.py
@@ -11,7 +11,7 @@
Union,
)
-from ...base import CancellationToken
+from ... import CancellationToken
from ..tools import Tool, ToolSchema
from ._types import CreateResult, LLMMessage, RequestUsage
diff --git a/python/packages/autogen-core/src/autogen_core/components/models/_types.py b/python/packages/autogen-core/src/autogen_core/components/models/_types.py
index d2048f4b7bf..3bc047d277f 100644
--- a/python/packages/autogen-core/src/autogen_core/components/models/_types.py
+++ b/python/packages/autogen-core/src/autogen_core/components/models/_types.py
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import List, Literal, Optional, Union
-from .. import FunctionCall, Image
+from ... import FunctionCall, Image
@dataclass
diff --git a/python/packages/autogen-core/src/autogen_core/components/tool_agent/_caller_loop.py b/python/packages/autogen-core/src/autogen_core/components/tool_agent/_caller_loop.py
index ea2922f23a7..28cff506645 100644
--- a/python/packages/autogen-core/src/autogen_core/components/tool_agent/_caller_loop.py
+++ b/python/packages/autogen-core/src/autogen_core/components/tool_agent/_caller_loop.py
@@ -1,8 +1,7 @@
import asyncio
from typing import List
-from ...base import AgentId, AgentRuntime, BaseAgent, CancellationToken
-from ...components import FunctionCall
+from ... import AgentId, AgentRuntime, BaseAgent, CancellationToken, FunctionCall
from ..models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-core/src/autogen_core/components/tool_agent/_tool_agent.py b/python/packages/autogen-core/src/autogen_core/components/tool_agent/_tool_agent.py
index 8e1c2993eec..2794a3e4e44 100644
--- a/python/packages/autogen-core/src/autogen_core/components/tool_agent/_tool_agent.py
+++ b/python/packages/autogen-core/src/autogen_core/components/tool_agent/_tool_agent.py
@@ -2,8 +2,7 @@
from dataclasses import dataclass
from typing import List
-from ...base import MessageContext
-from .. import FunctionCall, RoutedAgent, message_handler
+from ... import FunctionCall, MessageContext, RoutedAgent, message_handler
from ..models import FunctionExecutionResult
from ..tools import Tool
diff --git a/python/packages/autogen-core/src/autogen_core/components/tools/_base.py b/python/packages/autogen-core/src/autogen_core/components/tools/_base.py
index eb6a2067ebf..b41d747d65b 100644
--- a/python/packages/autogen-core/src/autogen_core/components/tools/_base.py
+++ b/python/packages/autogen-core/src/autogen_core/components/tools/_base.py
@@ -7,8 +7,8 @@
from pydantic import BaseModel
from typing_extensions import NotRequired
-from ...base import CancellationToken
-from .._function_utils import normalize_annotated_type
+from ... import CancellationToken
+from ..._function_utils import normalize_annotated_type
T = TypeVar("T", bound=BaseModel, contravariant=True)
diff --git a/python/packages/autogen-core/src/autogen_core/components/tools/_code_execution.py b/python/packages/autogen-core/src/autogen_core/components/tools/_code_execution.py
index 48dbe729a7f..5b3f0bcad1b 100644
--- a/python/packages/autogen-core/src/autogen_core/components/tools/_code_execution.py
+++ b/python/packages/autogen-core/src/autogen_core/components/tools/_code_execution.py
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, model_serializer
-from ...base import CancellationToken
+from ... import CancellationToken
from ..code_executor import CodeBlock, CodeExecutor
from ._base import BaseTool
diff --git a/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py b/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py
index cc9145fab1e..45041121cae 100644
--- a/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py
+++ b/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py
@@ -4,8 +4,8 @@
from pydantic import BaseModel
-from ...base import CancellationToken
-from .._function_utils import (
+from ... import CancellationToken
+from ..._function_utils import (
args_base_model_from_signature,
get_typed_signature,
)
@@ -38,7 +38,7 @@ class FunctionTool(BaseTool[BaseModel, BaseModel]):
.. code-block:: python
import random
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
from autogen_core.components.tools import FunctionTool
from typing_extensions import Annotated
import asyncio
diff --git a/python/packages/autogen-core/src/autogen_core/exceptions.py b/python/packages/autogen-core/src/autogen_core/exceptions.py
new file mode 100644
index 00000000000..3f4d76dbc2c
--- /dev/null
+++ b/python/packages/autogen-core/src/autogen_core/exceptions.py
@@ -0,0 +1,17 @@
+__all__ = ["CantHandleException", "UndeliverableException", "MessageDroppedException", "NotAccessibleError"]
+
+
+class CantHandleException(Exception):
+ """Raised when a handler can't handle the exception."""
+
+
+class UndeliverableException(Exception):
+ """Raised when a message can't be delivered."""
+
+
+class MessageDroppedException(Exception):
+ """Raised when a message is dropped."""
+
+
+class NotAccessibleError(Exception):
+ """Tried to access a value that is not accessible. For example if it is remote cannot be accessed locally."""
diff --git a/python/packages/autogen-core/tests/execution/test_commandline_code_executor.py b/python/packages/autogen-core/tests/execution/test_commandline_code_executor.py
index aff36b216ac..4823307143e 100644
--- a/python/packages/autogen-core/tests/execution/test_commandline_code_executor.py
+++ b/python/packages/autogen-core/tests/execution/test_commandline_code_executor.py
@@ -13,7 +13,7 @@
import pytest
import pytest_asyncio
from aiofiles import open
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import CodeBlock, LocalCommandLineCodeExecutor
diff --git a/python/packages/autogen-core/tests/execution/test_user_defined_functions.py b/python/packages/autogen-core/tests/execution/test_user_defined_functions.py
index 84fdec3fa44..6aa3a9e458e 100644
--- a/python/packages/autogen-core/tests/execution/test_user_defined_functions.py
+++ b/python/packages/autogen-core/tests/execution/test_user_defined_functions.py
@@ -6,7 +6,7 @@
import polars
import pytest
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import (
CodeBlock,
FunctionWithRequirements,
diff --git a/python/packages/autogen-core/tests/test_base_agent.py b/python/packages/autogen-core/tests/test_base_agent.py
index 884a42527d3..c7ccfc2d4c1 100644
--- a/python/packages/autogen-core/tests/test_base_agent.py
+++ b/python/packages/autogen-core/tests/test_base_agent.py
@@ -1,5 +1,5 @@
import pytest
-from autogen_core.base import AgentId, AgentInstantiationContext, AgentRuntime
+from autogen_core import AgentId, AgentInstantiationContext, AgentRuntime
from pytest_mock import MockerFixture
from test_utils import NoopAgent
diff --git a/python/packages/autogen-core/tests/test_cancellation.py b/python/packages/autogen-core/tests/test_cancellation.py
index 67852636f6b..930f16d9ea5 100644
--- a/python/packages/autogen-core/tests/test_cancellation.py
+++ b/python/packages/autogen-core/tests/test_cancellation.py
@@ -2,9 +2,15 @@
from dataclasses import dataclass
import pytest
+from autogen_core import (
+ AgentId,
+ AgentInstantiationContext,
+ CancellationToken,
+ MessageContext,
+ RoutedAgent,
+ message_handler,
+)
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, AgentInstantiationContext, CancellationToken, MessageContext
-from autogen_core.components import RoutedAgent, message_handler
@dataclass
diff --git a/python/packages/autogen-core/tests/test_closure_agent.py b/python/packages/autogen-core/tests/test_closure_agent.py
index 328fe237434..38f66cc7b08 100644
--- a/python/packages/autogen-core/tests/test_closure_agent.py
+++ b/python/packages/autogen-core/tests/test_closure_agent.py
@@ -2,9 +2,8 @@
from dataclasses import dataclass
import pytest
+from autogen_core import ClosureAgent, ClosureContext, DefaultSubscription, DefaultTopicId, MessageContext
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import MessageContext
-from autogen_core.components import ClosureAgent, ClosureContext, DefaultSubscription, DefaultTopicId
@dataclass
diff --git a/python/packages/autogen-core/tests/test_intervention.py b/python/packages/autogen-core/tests/test_intervention.py
index 105df32988b..66b45cca046 100644
--- a/python/packages/autogen-core/tests/test_intervention.py
+++ b/python/packages/autogen-core/tests/test_intervention.py
@@ -1,8 +1,8 @@
import pytest
+from autogen_core import AgentId
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId
-from autogen_core.base.exceptions import MessageDroppedException
from autogen_core.base.intervention import DefaultInterventionHandler, DropMessage
+from autogen_core.exceptions import MessageDroppedException
from test_utils import LoopbackAgent, MessageType
diff --git a/python/packages/autogen-core/tests/test_routed_agent.py b/python/packages/autogen-core/tests/test_routed_agent.py
index cab1b1d467f..2408c2b1de7 100644
--- a/python/packages/autogen-core/tests/test_routed_agent.py
+++ b/python/packages/autogen-core/tests/test_routed_agent.py
@@ -3,9 +3,8 @@
from typing import Callable, cast
import pytest
+from autogen_core import AgentId, MessageContext, RoutedAgent, TopicId, TypeSubscription, event, message_handler, rpc
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, MessageContext, TopicId
-from autogen_core.components import RoutedAgent, TypeSubscription, event, message_handler, rpc
from test_utils import LoopbackAgent
diff --git a/python/packages/autogen-core/tests/test_runtime.py b/python/packages/autogen-core/tests/test_runtime.py
index b327be1461e..86441b40a40 100644
--- a/python/packages/autogen-core/tests/test_runtime.py
+++ b/python/packages/autogen-core/tests/test_runtime.py
@@ -1,15 +1,17 @@
import logging
import pytest
-from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import (
+from autogen_core import (
AgentId,
AgentInstantiationContext,
AgentType,
+ DefaultTopicId,
TopicId,
+ TypeSubscription,
try_get_known_serializers_for_type,
+ type_subscription,
)
-from autogen_core.components import DefaultTopicId, TypeSubscription, type_subscription
+from autogen_core.application import SingleThreadedAgentRuntime
from opentelemetry.sdk.trace import TracerProvider
from test_utils import (
CascadingAgent,
diff --git a/python/packages/autogen-core/tests/test_serialization.py b/python/packages/autogen-core/tests/test_serialization.py
index f6ab2067c4d..ea4ab4d220e 100644
--- a/python/packages/autogen-core/tests/test_serialization.py
+++ b/python/packages/autogen-core/tests/test_serialization.py
@@ -2,18 +2,16 @@
from typing import Union
import pytest
-from autogen_core.base import (
+from autogen_core import Image
+from autogen_core._serialization import (
JSON_DATA_CONTENT_TYPE,
- MessageSerializer,
- SerializationRegistry,
- try_get_known_serializers_for_type,
-)
-from autogen_core.base._serialization import (
PROTOBUF_DATA_CONTENT_TYPE,
DataclassJsonMessageSerializer,
+ MessageSerializer,
PydanticJsonMessageSerializer,
+ SerializationRegistry,
+ try_get_known_serializers_for_type,
)
-from autogen_core.components import Image
from PIL import Image as PILImage
from protos.serialization_test_pb2 import NestingProtoMessage, ProtoMessage
from pydantic import BaseModel
diff --git a/python/packages/autogen-core/tests/test_state.py b/python/packages/autogen-core/tests/test_state.py
index ba4fe86cf13..99a7b132f7c 100644
--- a/python/packages/autogen-core/tests/test_state.py
+++ b/python/packages/autogen-core/tests/test_state.py
@@ -1,8 +1,8 @@
from typing import Any, Mapping
import pytest
+from autogen_core import AgentId, BaseAgent, MessageContext
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, BaseAgent, MessageContext
class StatefulAgent(BaseAgent):
diff --git a/python/packages/autogen-core/tests/test_subscription.py b/python/packages/autogen-core/tests/test_subscription.py
index 91223acbbc8..f2c3bd3ee4a 100644
--- a/python/packages/autogen-core/tests/test_subscription.py
+++ b/python/packages/autogen-core/tests/test_subscription.py
@@ -1,8 +1,7 @@
import pytest
+from autogen_core import AgentId, DefaultSubscription, DefaultTopicId, TopicId, TypeSubscription
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, TopicId
-from autogen_core.base.exceptions import CantHandleException
-from autogen_core.components import DefaultSubscription, DefaultTopicId, TypeSubscription
+from autogen_core.exceptions import CantHandleException
from test_utils import LoopbackAgent, MessageType
diff --git a/python/packages/autogen-core/tests/test_tool_agent.py b/python/packages/autogen-core/tests/test_tool_agent.py
index bdbd3b96b72..c7f02b26039 100644
--- a/python/packages/autogen-core/tests/test_tool_agent.py
+++ b/python/packages/autogen-core/tests/test_tool_agent.py
@@ -3,9 +3,8 @@
from typing import Any, AsyncGenerator, List, Mapping, Optional, Sequence, Union
import pytest
+from autogen_core import AgentId, CancellationToken, FunctionCall
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, CancellationToken
-from autogen_core.components import FunctionCall
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-core/tests/test_tools.py b/python/packages/autogen-core/tests/test_tools.py
index e7995969802..b35986423db 100644
--- a/python/packages/autogen-core/tests/test_tools.py
+++ b/python/packages/autogen-core/tests/test_tools.py
@@ -2,8 +2,8 @@
from typing import Annotated, List
import pytest
-from autogen_core.base import CancellationToken
-from autogen_core.components._function_utils import get_typed_signature
+from autogen_core import CancellationToken
+from autogen_core._function_utils import get_typed_signature
from autogen_core.components.tools import BaseTool, FunctionTool
from autogen_core.components.tools._base import ToolSchema
from pydantic import BaseModel, Field, model_serializer
diff --git a/python/packages/autogen-core/tests/test_types.py b/python/packages/autogen-core/tests/test_types.py
index 3959456b35b..16697e006e6 100644
--- a/python/packages/autogen-core/tests/test_types.py
+++ b/python/packages/autogen-core/tests/test_types.py
@@ -2,10 +2,10 @@
from types import NoneType
from typing import Any, List, Optional, Union
-from autogen_core.base import MessageContext
-from autogen_core.base._serialization import has_nested_base_model
-from autogen_core.base._type_helpers import AnyType, get_types
-from autogen_core.components._routed_agent import RoutedAgent, message_handler
+from autogen_core import MessageContext
+from autogen_core._routed_agent import RoutedAgent, message_handler
+from autogen_core._serialization import has_nested_base_model
+from autogen_core._type_helpers import AnyType, get_types
from pydantic import BaseModel
diff --git a/python/packages/autogen-core/tests/test_utils/__init__.py b/python/packages/autogen-core/tests/test_utils/__init__.py
index 3b1ac1101fc..f1aeed2292c 100644
--- a/python/packages/autogen-core/tests/test_utils/__init__.py
+++ b/python/packages/autogen-core/tests/test_utils/__init__.py
@@ -1,8 +1,7 @@
from dataclasses import dataclass
from typing import Any
-from autogen_core.base import BaseAgent, MessageContext
-from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler
+from autogen_core import BaseAgent, DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler
@dataclass
diff --git a/python/packages/autogen-core/tests/test_worker_runtime.py b/python/packages/autogen-core/tests/test_worker_runtime.py
index 2a7d3acdc38..5f2061fa8a2 100644
--- a/python/packages/autogen-core/tests/test_worker_runtime.py
+++ b/python/packages/autogen-core/tests/test_worker_runtime.py
@@ -4,24 +4,22 @@
from typing import Any, List
import pytest
-from autogen_core.application import WorkerAgentRuntime, WorkerAgentRuntimeHost
-from autogen_core.base import (
+from autogen_core import (
PROTOBUF_DATA_CONTENT_TYPE,
AgentId,
AgentType,
+ DefaultTopicId,
MessageContext,
+ RoutedAgent,
Subscription,
TopicId,
- try_get_known_serializers_for_type,
-)
-from autogen_core.components import (
- DefaultTopicId,
- RoutedAgent,
TypeSubscription,
default_subscription,
event,
+ try_get_known_serializers_for_type,
type_subscription,
)
+from autogen_core.application import WorkerAgentRuntime, WorkerAgentRuntimeHost
from protos.serialization_test_pb2 import ProtoMessage
from test_utils import (
CascadingAgent,
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/__init__.py b/python/packages/autogen-ext/src/autogen_ext/agents/__init__.py
index 92a594db66a..1cbcc77516b 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/__init__.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/__init__.py
@@ -1,3 +1,4 @@
+from ._magentic_one_coder_agent import MagenticOneCoderAgent
from ._openai_assistant_agent import OpenAIAssistantAgent
-__all__ = ["OpenAIAssistantAgent"]
+__all__ = ["OpenAIAssistantAgent", "MagenticOneCoderAgent"]
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/_magentic_one_coder_agent.py b/python/packages/autogen-ext/src/autogen_ext/agents/_magentic_one_coder_agent.py
new file mode 100644
index 00000000000..6a4908e77cf
--- /dev/null
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/_magentic_one_coder_agent.py
@@ -0,0 +1,37 @@
+from autogen_agentchat.agents import AssistantAgent
+from autogen_core.components.models import (
+ ChatCompletionClient,
+)
+
+MAGENTIC_ONE_CODER_DESCRIPTION = "A helpful and general-purpose AI assistant that has strong language skills, Python skills, and Linux command line skills."
+
+MAGENTIC_ONE_CODER_SYSTEM_MESSAGE = """You are a helpful AI assistant.
+Solve tasks using your coding and language skills.
+In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.
+ 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.
+ 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.
+Solve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.
+When using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.
+If you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.
+If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.
+When you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.
+Reply "TERMINATE" in the end when everything is done."""
+
+
+class MagenticOneCoderAgent(AssistantAgent):
+ """An agent, used by MagenticOne that provides coding assistance using an LLM model client.
+
+ The prompts and description are sealed, to replicate the original MagenticOne configuration. See AssistantAgent if you wish to modify these values.
+ """
+
+ def __init__(
+ self,
+ name: str,
+ model_client: ChatCompletionClient,
+ ):
+ super().__init__(
+ name,
+ model_client,
+ description=MAGENTIC_ONE_CODER_DESCRIPTION,
+ system_message=MAGENTIC_ONE_CODER_SYSTEM_MESSAGE,
+ )
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/_openai_assistant_agent.py b/python/packages/autogen-ext/src/autogen_ext/agents/_openai_assistant_agent.py
index c72f051ffc2..f672b832cc0 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/_openai_assistant_agent.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/_openai_assistant_agent.py
@@ -32,8 +32,7 @@
ToolCallMessage,
ToolCallResultMessage,
)
-from autogen_core.base import CancellationToken
-from autogen_core.components import FunctionCall
+from autogen_core import CancellationToken, FunctionCall
from autogen_core.components.models._types import FunctionExecutionResult
from autogen_core.components.tools import FunctionTool, Tool
@@ -125,7 +124,7 @@ class OpenAIAssistantAgent(BaseChatAgent):
.. code-block:: python
from openai import AsyncClient
- from autogen_core.base import CancellationToken
+ from autogen_core import CancellationToken
import asyncio
from autogen_ext.agents import OpenAIAssistantAgent
from autogen_agentchat.messages import TextMessage
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py b/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py
index 2a925643c68..fcbc4f58eb7 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py
@@ -9,8 +9,7 @@
MultiModalMessage,
TextMessage,
)
-from autogen_core.base import CancellationToken
-from autogen_core.components import FunctionCall
+from autogen_core import CancellationToken, FunctionCall
from autogen_core.components.models import (
ChatCompletionClient,
LLMMessage,
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/__init__.py b/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/__init__.py
index 414ab8e00c8..cab75c5daad 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/__init__.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/__init__.py
@@ -1,3 +1,3 @@
-from ._video_surfer import VideoSurferAgent
+from ._video_surfer import VideoSurfer
-__all__ = ["VideoSurferAgent"]
+__all__ = ["VideoSurfer"]
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/_video_surfer.py b/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/_video_surfer.py
index 8f8bb276ee1..04dc1c062c6 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/_video_surfer.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/_video_surfer.py
@@ -14,9 +14,9 @@
)
-class VideoSurferAgent(AssistantAgent):
+class VideoSurfer(AssistantAgent):
"""
- VideoSurferAgent is a specialized agent designed to answer questions about a local video file.
+ VideoSurfer is a specialized agent designed to answer questions about a local video file.
This agent utilizes various tools to extract information from the video, such as its length, screenshots at specific timestamps, and audio transcriptions. It processes these elements to provide detailed answers to user queries.
@@ -39,18 +39,19 @@ class VideoSurferAgent(AssistantAgent):
import asyncio
- from autogen_agentchat.task import Console, TextMentionTermination
+ from autogen_agentchat.ui import Console
+ from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models import OpenAIChatCompletionClient
- from autogen_ext.agents.video_surfer import VideoSurferAgent
+ from autogen_ext.agents.video_surfer import VideoSurfer
async def main() -> None:
\"\"\"
Main function to run the video agent.
\"\"\"
# Define an agent
- video_agent = VideoSurferAgent(
- name="VideoSurferAgent",
+ video_agent = VideoSurfer(
+ name="VideoSurfer",
model_client=OpenAIChatCompletionClient(model="gpt-4o-2024-08-06")
)
@@ -66,17 +67,17 @@ async def main() -> None:
asyncio.run(main())
- The following example demonstrates how to create and use a VideoSurferAgent and UserProxyAgent with MagenticOneGroupChat.
+ The following example demonstrates how to create and use a VideoSurfer and UserProxyAgent with MagenticOneGroupChat.
.. code-block:: python
import asyncio
- from autogen_agentchat.task import Console
+ from autogen_agentchat.ui import Console
from autogen_agentchat.teams import MagenticOneGroupChat
from autogen_agentchat.agents import UserProxyAgent
from autogen_ext.models import OpenAIChatCompletionClient
- from autogen_ext.agents.video_surfer import VideoSurferAgent
+ from autogen_ext.agents.video_surfer import VideoSurfer
async def main() -> None:
\"\"\"
@@ -86,8 +87,8 @@ async def main() -> None:
model_client = OpenAIChatCompletionClient(model="gpt-4o-2024-08-06")
# Define an agent
- video_agent = VideoSurferAgent(
- name="VideoSurferAgent",
+ video_agent = VideoSurfer(
+ name="VideoSurfer",
model_client=model_client
)
@@ -127,7 +128,7 @@ def __init__(
system_message: Optional[str] = None,
):
"""
- Initialize the VideoSurferAgent.
+ Initialize the VideoSurfer.
Args:
name (str): The name of the agent.
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/tools.py b/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/tools.py
index bbba4b79a80..395daacb575 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/tools.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/tools.py
@@ -5,7 +5,7 @@
import ffmpeg
import numpy as np
import whisper
-from autogen_core.components import Image as AGImage
+from autogen_core import Image as AGImage
from autogen_core.components.models import (
ChatCompletionClient,
UserMessage,
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py
index eb3d2434c64..69cd067c744 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py
@@ -26,10 +26,9 @@
from autogen_agentchat.agents import BaseChatAgent
from autogen_agentchat.base import Response
from autogen_agentchat.messages import ChatMessage, MultiModalMessage, TextMessage
+from autogen_core import CancellationToken, FunctionCall
+from autogen_core import Image as AGImage
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import CancellationToken
-from autogen_core.components import FunctionCall
-from autogen_core.components import Image as AGImage
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_types.py b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_types.py
index f7fa2cdea78..a3b1cf6c5e6 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_types.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_types.py
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, TypedDict, Union
-from autogen_core.components import FunctionCall, Image
+from autogen_core import FunctionCall, Image
from autogen_core.components.models import FunctionExecutionResult
UserContent = Union[str, List[Union[str, Image]]]
diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_utils.py b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_utils.py
index ddafc8d92bb..c492135b4c7 100644
--- a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_utils.py
+++ b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_utils.py
@@ -1,6 +1,6 @@
from typing import List
-from autogen_core.components import Image
+from autogen_core import Image
from ._types import AssistantContent, FunctionExecutionContent, SystemContent, UserContent
diff --git a/python/packages/autogen-ext/src/autogen_ext/code_executors/_azure_container_code_executor.py b/python/packages/autogen-ext/src/autogen_ext/code_executors/_azure_container_code_executor.py
index d7c5bd55530..f984cdf3abb 100644
--- a/python/packages/autogen-ext/src/autogen_ext/code_executors/_azure_container_code_executor.py
+++ b/python/packages/autogen-ext/src/autogen_ext/code_executors/_azure_container_code_executor.py
@@ -13,7 +13,7 @@
# async functions shouldn't use open()
from anyio import open_file
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import (
CodeBlock,
CodeExecutor,
diff --git a/python/packages/autogen-ext/src/autogen_ext/code_executors/_docker_code_executor.py b/python/packages/autogen-ext/src/autogen_ext/code_executors/_docker_code_executor.py
index eb807db4629..442486a83f1 100644
--- a/python/packages/autogen-ext/src/autogen_ext/code_executors/_docker_code_executor.py
+++ b/python/packages/autogen-ext/src/autogen_ext/code_executors/_docker_code_executor.py
@@ -14,7 +14,7 @@
from types import TracebackType
from typing import Any, Callable, ClassVar, List, Optional, ParamSpec, Type, Union
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import (
CodeBlock,
CodeExecutor,
diff --git a/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py b/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py
index 1d46ecc7e56..851c62358a1 100644
--- a/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py
+++ b/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py
@@ -21,13 +21,13 @@
)
import tiktoken
-from autogen_core.application.logging import EVENT_LOGGER_NAME, TRACE_LOGGER_NAME
-from autogen_core.application.logging.events import LLMCallEvent
-from autogen_core.base import CancellationToken
-from autogen_core.components import (
+from autogen_core import (
+ CancellationToken,
FunctionCall,
Image,
)
+from autogen_core.application.logging import EVENT_LOGGER_NAME, TRACE_LOGGER_NAME
+from autogen_core.application.logging.events import LLMCallEvent
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-ext/src/autogen_ext/models/_reply_chat_completion_client.py b/python/packages/autogen-ext/src/autogen_ext/models/_reply_chat_completion_client.py
index 187dfdace14..9403f2f3330 100644
--- a/python/packages/autogen-ext/src/autogen_ext/models/_reply_chat_completion_client.py
+++ b/python/packages/autogen-ext/src/autogen_ext/models/_reply_chat_completion_client.py
@@ -3,8 +3,8 @@
import logging
from typing import Any, AsyncGenerator, List, Mapping, Optional, Sequence, Union
+from autogen_core import CancellationToken
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import CancellationToken
from autogen_core.components.models import (
ChatCompletionClient,
CreateResult,
diff --git a/python/packages/autogen-ext/src/autogen_ext/tools/_langchain_adapter.py b/python/packages/autogen-ext/src/autogen_ext/tools/_langchain_adapter.py
index 4ac3e6b6371..cb6e82aa829 100644
--- a/python/packages/autogen-ext/src/autogen_ext/tools/_langchain_adapter.py
+++ b/python/packages/autogen-ext/src/autogen_ext/tools/_langchain_adapter.py
@@ -4,7 +4,7 @@
import inspect
from typing import TYPE_CHECKING, Any, Callable, Dict, Type, cast
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.tools import BaseTool
from pydantic import BaseModel, Field, create_model
diff --git a/python/packages/autogen-ext/tests/code_executors/test_aca_dynamic_sessions.py b/python/packages/autogen-ext/tests/code_executors/test_aca_dynamic_sessions.py
index 40eb0721300..df5caf5ce96 100644
--- a/python/packages/autogen-ext/tests/code_executors/test_aca_dynamic_sessions.py
+++ b/python/packages/autogen-ext/tests/code_executors/test_aca_dynamic_sessions.py
@@ -8,7 +8,7 @@
import pytest
from anyio import open_file
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import CodeBlock
from autogen_ext.code_executors import ACADynamicSessionsCodeExecutor
from azure.identity import DefaultAzureCredential
diff --git a/python/packages/autogen-ext/tests/code_executors/test_aca_user_defined_functions.py b/python/packages/autogen-ext/tests/code_executors/test_aca_user_defined_functions.py
index 857a0333a32..7b8f2ef2af1 100644
--- a/python/packages/autogen-ext/tests/code_executors/test_aca_user_defined_functions.py
+++ b/python/packages/autogen-ext/tests/code_executors/test_aca_user_defined_functions.py
@@ -5,7 +5,7 @@
import polars
import pytest
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import (
CodeBlock,
FunctionWithRequirements,
diff --git a/python/packages/autogen-ext/tests/code_executors/test_docker_commandline_code_executor.py b/python/packages/autogen-ext/tests/code_executors/test_docker_commandline_code_executor.py
index 25c3161157c..bee4957f332 100644
--- a/python/packages/autogen-ext/tests/code_executors/test_docker_commandline_code_executor.py
+++ b/python/packages/autogen-ext/tests/code_executors/test_docker_commandline_code_executor.py
@@ -8,7 +8,7 @@
import pytest
import pytest_asyncio
from aiofiles import open
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.code_executor import CodeBlock
from autogen_ext.code_executors import DockerCommandLineCodeExecutor
diff --git a/python/packages/autogen-ext/tests/models/test_openai_model_client.py b/python/packages/autogen-ext/tests/models/test_openai_model_client.py
index b2dc504abd0..dfaef0ccebe 100644
--- a/python/packages/autogen-ext/tests/models/test_openai_model_client.py
+++ b/python/packages/autogen-ext/tests/models/test_openai_model_client.py
@@ -3,8 +3,7 @@
from unittest.mock import MagicMock
import pytest
-from autogen_core.base import CancellationToken
-from autogen_core.components import Image
+from autogen_core import CancellationToken, Image
from autogen_core.components.models import (
AssistantMessage,
CreateResult,
diff --git a/python/packages/autogen-ext/tests/models/test_reply_chat_completion_client.py b/python/packages/autogen-ext/tests/models/test_reply_chat_completion_client.py
index 2f0ba52a8cf..6f79188c756 100644
--- a/python/packages/autogen-ext/tests/models/test_reply_chat_completion_client.py
+++ b/python/packages/autogen-ext/tests/models/test_reply_chat_completion_client.py
@@ -3,9 +3,8 @@
from typing import List
import pytest
+from autogen_core import AgentId, DefaultTopicId, MessageContext, RoutedAgent, default_subscription, message_handler
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, MessageContext
-from autogen_core.components import DefaultTopicId, RoutedAgent, default_subscription, message_handler
from autogen_core.components.models import ChatCompletionClient, CreateResult, SystemMessage, UserMessage
from autogen_ext.models import ReplayChatCompletionClient
diff --git a/python/packages/autogen-ext/tests/test_openai_assistant_agent.py b/python/packages/autogen-ext/tests/test_openai_assistant_agent.py
index efc01dead01..f21d510d382 100644
--- a/python/packages/autogen-ext/tests/test_openai_assistant_agent.py
+++ b/python/packages/autogen-ext/tests/test_openai_assistant_agent.py
@@ -4,7 +4,7 @@
import pytest
from autogen_agentchat.messages import TextMessage
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_core.components.tools._base import BaseTool, Tool
from autogen_ext.agents import OpenAIAssistantAgent
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
diff --git a/python/packages/autogen-ext/tests/test_tools.py b/python/packages/autogen-ext/tests/test_tools.py
index c79d25af3d5..3c9cf415994 100644
--- a/python/packages/autogen-ext/tests/test_tools.py
+++ b/python/packages/autogen-ext/tests/test_tools.py
@@ -1,7 +1,7 @@
from typing import Optional, Type
import pytest
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from autogen_ext.tools import LangChainToolAdapter # type: ignore
from langchain_core.callbacks.manager import AsyncCallbackManagerForToolRun, CallbackManagerForToolRun
from langchain_core.tools import BaseTool as LangChainTool
diff --git a/python/packages/autogen-magentic-one/examples/example.py b/python/packages/autogen-magentic-one/examples/example.py
index 3274ca458de..400e8ddccc9 100644
--- a/python/packages/autogen-magentic-one/examples/example.py
+++ b/python/packages/autogen-magentic-one/examples/example.py
@@ -5,9 +5,9 @@
import logging
import os
+from autogen_core import AgentId, AgentProxy
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import AgentId, AgentProxy
from autogen_core.components.code_executor import CodeBlock
from autogen_ext.code_executors import DockerCommandLineCodeExecutor
from autogen_magentic_one.agents.coder import Coder, Executor
diff --git a/python/packages/autogen-magentic-one/examples/example_coder.py b/python/packages/autogen-magentic-one/examples/example_coder.py
index 4824f7338fd..5e8b36686f4 100644
--- a/python/packages/autogen-magentic-one/examples/example_coder.py
+++ b/python/packages/autogen-magentic-one/examples/example_coder.py
@@ -7,9 +7,9 @@
import asyncio
import logging
+from autogen_core import AgentId, AgentProxy
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import AgentId, AgentProxy
from autogen_core.components.code_executor import CodeBlock
from autogen_ext.code_executors import DockerCommandLineCodeExecutor
from autogen_magentic_one.agents.coder import Coder, Executor
diff --git a/python/packages/autogen-magentic-one/examples/example_file_surfer.py b/python/packages/autogen-magentic-one/examples/example_file_surfer.py
index 9b81ad9055a..4f752896b60 100644
--- a/python/packages/autogen-magentic-one/examples/example_file_surfer.py
+++ b/python/packages/autogen-magentic-one/examples/example_file_surfer.py
@@ -5,9 +5,9 @@
import asyncio
import logging
+from autogen_core import AgentId, AgentProxy
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import AgentId, AgentProxy
from autogen_magentic_one.agents.file_surfer import FileSurfer
from autogen_magentic_one.agents.orchestrator import RoundRobinOrchestrator
from autogen_magentic_one.agents.user_proxy import UserProxy
diff --git a/python/packages/autogen-magentic-one/examples/example_userproxy.py b/python/packages/autogen-magentic-one/examples/example_userproxy.py
index adf69d0a56f..24e907a4f08 100644
--- a/python/packages/autogen-magentic-one/examples/example_userproxy.py
+++ b/python/packages/autogen-magentic-one/examples/example_userproxy.py
@@ -7,9 +7,9 @@
import asyncio
import logging
+from autogen_core import AgentId, AgentProxy
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import AgentId, AgentProxy
# from typing import Any, Dict, List, Tuple, Union
from autogen_magentic_one.agents.coder import Coder
diff --git a/python/packages/autogen-magentic-one/examples/example_websurfer.py b/python/packages/autogen-magentic-one/examples/example_websurfer.py
index 99450dab030..302949fbff4 100644
--- a/python/packages/autogen-magentic-one/examples/example_websurfer.py
+++ b/python/packages/autogen-magentic-one/examples/example_websurfer.py
@@ -7,9 +7,9 @@
import logging
import os
+from autogen_core import AgentId, AgentProxy
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import AgentId, AgentProxy
from autogen_magentic_one.agents.multimodal_web_surfer import MultimodalWebSurfer
from autogen_magentic_one.agents.orchestrator import RoundRobinOrchestrator
from autogen_magentic_one.agents.user_proxy import UserProxy
diff --git a/python/packages/autogen-magentic-one/interface/magentic_one_helper.py b/python/packages/autogen-magentic-one/interface/magentic_one_helper.py
index bf0dd05f637..40edc8ace40 100644
--- a/python/packages/autogen-magentic-one/interface/magentic_one_helper.py
+++ b/python/packages/autogen-magentic-one/interface/magentic_one_helper.py
@@ -8,8 +8,8 @@
from autogen_core.application import SingleThreadedAgentRuntime
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import AgentId, AgentProxy
-from autogen_core.components import DefaultTopicId
+from autogen_core import AgentId, AgentProxy
+from autogen_core import DefaultTopicId
from autogen_core.components.code_executor import LocalCommandLineCodeExecutor
from autogen_ext.code_executor.docker_executor import DockerCommandLineCodeExecutor
from autogen_core.components.code_executor import CodeBlock
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_agent.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_agent.py
index cfca93d330b..aa762811596 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_agent.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_agent.py
@@ -2,9 +2,8 @@
import logging
from typing import Any
+from autogen_core import MessageContext, RoutedAgent, message_handler
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import MessageContext
-from autogen_core.components import RoutedAgent, message_handler
from autogen_magentic_one.messages import (
AgentEvent,
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_orchestrator.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_orchestrator.py
index 75a5c2b76e1..fee0d6c528b 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_orchestrator.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_orchestrator.py
@@ -2,8 +2,8 @@
import time
from typing import List, Optional
+from autogen_core import AgentProxy, CancellationToken, MessageContext
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import AgentProxy, CancellationToken, MessageContext
from autogen_core.components.models import AssistantMessage, LLMMessage, UserMessage
from ..messages import BroadcastMessage, OrchestrationEvent, RequestReplyMessage, ResetMessage
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_worker.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_worker.py
index f92b9dede66..dadd16021d4 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_worker.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/base_worker.py
@@ -1,6 +1,6 @@
from typing import List, Tuple
-from autogen_core.base import CancellationToken, MessageContext, TopicId
+from autogen_core import CancellationToken, MessageContext, TopicId
from autogen_core.components.models import (
AssistantMessage,
LLMMessage,
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/coder.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/coder.py
index e8b3e84421d..1d3e8dbd24f 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/coder.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/coder.py
@@ -1,8 +1,7 @@
import re
from typing import Awaitable, Callable, List, Literal, Tuple, Union
-from autogen_core.base import CancellationToken
-from autogen_core.components import default_subscription
+from autogen_core import CancellationToken, default_subscription
from autogen_core.components.code_executor import CodeBlock, CodeExecutor
from autogen_core.components.models import (
ChatCompletionClient,
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/file_surfer/file_surfer.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/file_surfer/file_surfer.py
index af798af5c5c..3321e9c0aa0 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/file_surfer/file_surfer.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/file_surfer/file_surfer.py
@@ -2,8 +2,7 @@
import time
from typing import List, Optional, Tuple
-from autogen_core.base import CancellationToken
-from autogen_core.components import FunctionCall, default_subscription
+from autogen_core import CancellationToken, FunctionCall, default_subscription
from autogen_core.components.models import (
ChatCompletionClient,
SystemMessage,
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/multimodal_web_surfer/multimodal_web_surfer.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/multimodal_web_surfer/multimodal_web_surfer.py
index e90c50ff911..94454b80e13 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/multimodal_web_surfer/multimodal_web_surfer.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/multimodal_web_surfer/multimodal_web_surfer.py
@@ -12,10 +12,9 @@
from urllib.parse import quote_plus # parse_qs, quote, unquote, urlparse, urlunparse
import aiofiles
+from autogen_core import CancellationToken, FunctionCall, default_subscription
+from autogen_core import Image as AGImage
from autogen_core.application.logging import EVENT_LOGGER_NAME
-from autogen_core.base import CancellationToken
-from autogen_core.components import FunctionCall, default_subscription
-from autogen_core.components import Image as AGImage
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/orchestrator.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/orchestrator.py
index 986ab3a607e..dedd160a2ed 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/orchestrator.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/orchestrator.py
@@ -1,8 +1,7 @@
import json
from typing import Any, Dict, List, Optional
-from autogen_core.base import AgentProxy, CancellationToken, MessageContext, TopicId
-from autogen_core.components import default_subscription
+from autogen_core import AgentProxy, CancellationToken, MessageContext, TopicId, default_subscription
from autogen_core.components.models import (
AssistantMessage,
ChatCompletionClient,
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/user_proxy.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/user_proxy.py
index 67ef2887b4b..805983e10e7 100755
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/user_proxy.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/agents/user_proxy.py
@@ -1,8 +1,7 @@
import asyncio
from typing import Tuple
-from autogen_core.base import CancellationToken
-from autogen_core.components import default_subscription
+from autogen_core import CancellationToken, default_subscription
from ..messages import UserContent
from .base_worker import BaseWorker
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/messages.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/messages.py
index c46ba997b25..35020532f2d 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/messages.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/messages.py
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import Any, Dict, List, Union
-from autogen_core.components import FunctionCall, Image
+from autogen_core import FunctionCall, Image
from autogen_core.components.models import FunctionExecutionResult, LLMMessage
from pydantic import BaseModel
diff --git a/python/packages/autogen-magentic-one/src/autogen_magentic_one/utils.py b/python/packages/autogen-magentic-one/src/autogen_magentic_one/utils.py
index 9b4d62a2954..36da9fc0fe6 100644
--- a/python/packages/autogen-magentic-one/src/autogen_magentic_one/utils.py
+++ b/python/packages/autogen-magentic-one/src/autogen_magentic_one/utils.py
@@ -5,8 +5,8 @@
from datetime import datetime
from typing import Any, Dict, List, Literal
+from autogen_core import Image
from autogen_core.application.logging.events import LLMCallEvent
-from autogen_core.components import Image
from autogen_core.components.models import (
ChatCompletionClient,
ModelCapabilities,
diff --git a/python/packages/autogen-magentic-one/tests/headless_web_surfer/test_web_surfer.py b/python/packages/autogen-magentic-one/tests/headless_web_surfer/test_web_surfer.py
index 769ac5080e8..9298fd0a61e 100644
--- a/python/packages/autogen-magentic-one/tests/headless_web_surfer/test_web_surfer.py
+++ b/python/packages/autogen-magentic-one/tests/headless_web_surfer/test_web_surfer.py
@@ -8,9 +8,8 @@
from typing import Mapping
import pytest
+from autogen_core import AgentId, AgentProxy, FunctionCall
from autogen_core.application import SingleThreadedAgentRuntime
-from autogen_core.base import AgentId, AgentProxy
-from autogen_core.components import FunctionCall
from autogen_core.components.models import (
UserMessage,
)
diff --git a/python/packages/autogen-studio/autogenstudio/database/component_factory.py b/python/packages/autogen-studio/autogenstudio/database/component_factory.py
index 2e9e014d7d8..a3ae77b3bf7 100644
--- a/python/packages/autogen-studio/autogenstudio/database/component_factory.py
+++ b/python/packages/autogen-studio/autogenstudio/database/component_factory.py
@@ -7,7 +7,7 @@
import aiofiles
import yaml
from autogen_agentchat.agents import AssistantAgent, UserProxyAgent
-from autogen_agentchat.task import MaxMessageTermination, StopMessageTermination, TextMentionTermination
+from autogen_agentchat.conditions import MaxMessageTermination, StopMessageTermination, TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat, SelectorGroupChat
from autogen_core.components.tools import FunctionTool
from autogen_ext.agents.web_surfer import MultimodalWebSurfer
diff --git a/python/packages/autogen-studio/autogenstudio/teammanager.py b/python/packages/autogen-studio/autogenstudio/teammanager.py
index 9dcca06c8a3..bc3e0157708 100644
--- a/python/packages/autogen-studio/autogenstudio/teammanager.py
+++ b/python/packages/autogen-studio/autogenstudio/teammanager.py
@@ -3,7 +3,7 @@
from autogen_agentchat.base import TaskResult
from autogen_agentchat.messages import AgentMessage, ChatMessage
-from autogen_core.base import CancellationToken
+from autogen_core import CancellationToken
from .database import Component, ComponentFactory
from .datamodel import ComponentConfigInput, TeamResult
diff --git a/python/packages/autogen-studio/autogenstudio/web/managers/connection.py b/python/packages/autogen-studio/autogenstudio/web/managers/connection.py
index cc83995be6b..1b7550bdc1e 100644
--- a/python/packages/autogen-studio/autogenstudio/web/managers/connection.py
+++ b/python/packages/autogen-studio/autogenstudio/web/managers/connection.py
@@ -6,8 +6,8 @@
from autogen_agentchat.base._task import TaskResult
from autogen_agentchat.messages import AgentMessage, ChatMessage, MultiModalMessage, TextMessage
-from autogen_core.base import CancellationToken
-from autogen_core.components import Image as AGImage
+from autogen_core import CancellationToken
+from autogen_core import Image as AGImage
from fastapi import WebSocket, WebSocketDisconnect
from ...database import DatabaseManager
diff --git a/python/packages/autogen-studio/notebooks/tutorial.ipynb b/python/packages/autogen-studio/notebooks/tutorial.ipynb
index 432f9458765..17dbab020ac 100644
--- a/python/packages/autogen-studio/notebooks/tutorial.ipynb
+++ b/python/packages/autogen-studio/notebooks/tutorial.ipynb
@@ -20,10 +20,10 @@
"metadata": {},
"outputs": [],
"source": [
- "from autogenstudio.teammanager import TeamManager \n",
- " \n",
- "wm = TeamManager() \n",
- "result = await wm.run(task=\"What is the weather in New York?\", team_config=\"team.json\") \n",
+ "from autogenstudio.teammanager import TeamManager\n",
+ "\n",
+ "wm = TeamManager()\n",
+ "result = await wm.run(task=\"What is the weather in New York?\", team_config=\"team.json\")\n",
"print(result)"
]
},
@@ -33,7 +33,7 @@
"metadata": {},
"outputs": [],
"source": [
- "result_stream = wm.run_stream(task=\"What is the weather in New York?\", team_config=\"team.json\") \n",
+ "result_stream = wm.run_stream(task=\"What is the weather in New York?\", team_config=\"team.json\")\n",
"async for response in result_stream:\n",
" print(response)"
]
@@ -49,7 +49,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
@@ -64,21 +64,21 @@
}
],
"source": [
- "from autogenstudio.database import DatabaseManager \n",
- "import os \n",
+ "from autogenstudio.database import DatabaseManager\n",
+ "import os\n",
"# delete database\n",
"# if os.path.exists(\"test.db\"):\n",
- "# os.remove(\"test.db\") \n",
+ "# os.remove(\"test.db\")\n",
"\n",
"os.makedirs(\"test\", exist_ok=True)\n",
"# create a database\n",
"dbmanager = DatabaseManager(engine_uri=\"sqlite:///test.db\", base_dir=\"test\")\n",
- "dbmanager.initialize_database() "
+ "dbmanager.initialize_database()"
]
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -95,10 +95,10 @@
"\n",
"adding_tool = Tool(user_id=user_id, config=ToolConfig(name=\"add\", description=\"Add two numbers\", content=\"async def add(a: int, b: int) -> int:\\n return a + b\", tool_type=ToolTypes.PYTHON_FUNCTION).model_dump() )\n",
"\n",
- "writing_agent = Agent(user_id=user_id, \n",
+ "writing_agent = Agent(user_id=user_id,\n",
" config=AgentConfig(\n",
- " name=\"writing_agent\", \n",
- " tools=[weather_tool.config], \n",
+ " name=\"writing_agent\",\n",
+ " tools=[weather_tool.config],\n",
" agent_type=AgentTypes.ASSISTANT,\n",
" model_client=gpt4_model.config\n",
" ).model_dump()\n",
@@ -159,10 +159,9 @@
"metadata": {},
"outputs": [],
"source": [
- "from autogenstudio.database import ConfigurationManager \n",
+ "from autogenstudio.database import ConfigurationManager\n",
"\n",
- "config_manager = ConfigurationManager(dbmanager)\n",
- " "
+ "config_manager = ConfigurationManager(dbmanager)\n"
]
},
{
@@ -209,9 +208,9 @@
"outputs": [],
"source": [
"from autogen_agentchat.agents import AssistantAgent\n",
- "from autogen_agentchat.task import TextMentionTermination\n",
+ "from autogen_agentchat.conditions import TextMentionTermination\n",
"from autogen_agentchat.teams import RoundRobinGroupChat, SelectorGroupChat\n",
- "from autogen_ext.models import OpenAIChatCompletionClient \n",
+ "from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"planner_agent = AssistantAgent(\n",
" \"planner_agent\",\n",
@@ -256,7 +255,7 @@
"\n",
"result = group_chat.run_stream(task=\"Plan a 3 day trip to Nepal.\")\n",
"async for response in result:\n",
- " print(response) "
+ " print(response)"
]
},
{
@@ -275,9 +274,9 @@
"metadata": {},
"outputs": [],
"source": [
- "from autogenstudio.components import UserProxyAgent \n",
+ "from autogenstudio.components import UserProxyAgent\n",
"\n",
- "def input_func(prompt: str) -> str: \n",
+ "def input_func(prompt: str) -> str:\n",
" return \"Hello World there\" + str(prompt)\n",
"user_agent = UserProxyAgent(name=\"user_agent\", description=\"a human user\", input_func=input_func)"
]
@@ -288,7 +287,7 @@
"metadata": {},
"outputs": [],
"source": [
- "from autogen_core.base import CancellationToken \n",
+ "from autogen_core import CancellationToken\n",
"cancellation_token = CancellationToken()\n",
"stream = user_agent.run_stream(task=\"hello there\", cancellation_token=cancellation_token)\n",
"\n",
diff --git a/python/packages/autogen-studio/tests/test_component_factory.py b/python/packages/autogen-studio/tests/test_component_factory.py
index 4fc4aed8c66..eb8255bbf36 100644
--- a/python/packages/autogen-studio/tests/test_component_factory.py
+++ b/python/packages/autogen-studio/tests/test_component_factory.py
@@ -3,7 +3,7 @@
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat, SelectorGroupChat
-from autogen_agentchat.task import MaxMessageTermination, StopMessageTermination, TextMentionTermination
+from autogen_agentchat.conditions import MaxMessageTermination, StopMessageTermination, TextMentionTermination
from autogen_core.components.tools import FunctionTool
from autogenstudio.datamodel.types import (