Skip to content

Commit

Permalink
Flatten core base and components (#4513)
Browse files Browse the repository at this point in the history
* Flatten core base and components

* remove extra files

* dont export from deprecated locations

* format

* fmt
  • Loading branch information
jackgerrits authored Dec 4, 2024
1 parent 6706dce commit 3022369
Show file tree
Hide file tree
Showing 171 changed files with 1,202 additions and 959 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

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 (
ChatCompletionClient,
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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()],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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()],
)
Expand All @@ -163,7 +163,7 @@ async def main() -> None:

runtime.start()
await runtime.publish_message(
ResetMessage(),
ResetMessage(),
topic_id=DefaultTopicId(),
)
await runtime.publish_message(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -260,7 +260,7 @@ async def main() -> None:
client=cdp_session,
# azure_config=llm_config,
)

print("FINAL SCORE: " + str(score))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
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,
Expand Down Expand Up @@ -74,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
Expand Down Expand Up @@ -107,7 +106,7 @@ async def main() -> None:
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.messages import TextMessage
from autogen_agentchat.ui import Console
from autogen_core.base import CancellationToken
from autogen_core import CancellationToken
async def get_current_time() -> str:
Expand Down Expand Up @@ -136,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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -216,7 +217,7 @@ async def main() -> None:
from autogen_agentchat.agents import AssistantAgent
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
Expand Down Expand Up @@ -317,7 +318,7 @@ async def main() -> None:
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,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
Expand Down
3 changes: 1 addition & 2 deletions python/packages/autogen-agentchat/tests/test_group_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
Swarm,
)
from autogen_agentchat.ui import Console
from autogen_core.base import CancellationToken
from autogen_core.components import FunctionCall
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 3022369

Please sign in to comment.