A programming framework for agentic AI
Change examples and docs to use docker executor by default (#494)
Jack Gerrits0376a0b399c9
diff --git a/python/packages/autogen-core/docs/src/getting-started/quickstart.ipynb b/python/packages/autogen-core/docs/src/getting-started/quickstart.ipynbindex 1972ce068..081220032 100644--- a/python/packages/autogen-core/docs/src/getting-started/quickstart.ipynb+++ b/python/packages/autogen-core/docs/src/getting-started/quickstart.ipynb@@ -153,7 +153,7 @@"\n","from autogen_core.application import SingleThreadedAgentRuntime\n","from autogen_core.components import DefaultSubscription\n",- "from autogen_core.components.code_executor import LocalCommandLineCodeExecutor\n",+ "from autogen_core.components.code_executor import DockerCommandLineCodeExecutor\n","from autogen_core.components.models import OpenAIChatCompletionClient\n","\n","work_dir = tempfile.mkdtemp()\n",@@ -175,7 +175,7 @@")\n","await runtime.register(\n"," \"executor\",\n",- " lambda: Executor(LocalCommandLineCodeExecutor(work_dir=work_dir)),\n",+ " lambda: Executor(DockerCommandLineCodeExecutor(work_dir=work_dir)),\n"," subscriptions=lambda: [DefaultSubscription()],\n",")\n","\n",diff --git a/python/packages/autogen-core/docs/src/getting-started/tools.ipynb b/python/packages/autogen-core/docs/src/getting-started/tools.ipynbindex f1b3cb011..beca83c34 100644--- a/python/packages/autogen-core/docs/src/getting-started/tools.ipynb+++ b/python/packages/autogen-core/docs/src/getting-started/tools.ipynb@@ -44,11 +44,11 @@],"source": ["from autogen_core.base import CancellationToken\n",- "from autogen_core.components.code_executor import LocalCommandLineCodeExecutor\n",+ "from autogen_core.components.code_executor import DockerCommandLineCodeExecutor\n","from autogen_core.components.tools import PythonCodeExecutionTool\n","\n","# Create the tool.\n",- "code_executor = LocalCommandLineCodeExecutor()\n",+ "code_executor = DockerCommandLineCodeExecutor()\n","code_execution_tool = PythonCodeExecutionTool(code_executor)\n","cancellation_token = CancellationToken()\n","\n",@@ -62,7 +62,7 @@"cell_type": "markdown","metadata": {},"source": [- "The {py:class}`~autogen_core.components.code_executor.LocalCommandLineCodeExecutor`\n",+ "The {py:class}`~autogen_core.components.code_executor.DockerCommandLineCodeExecutor`\n","class is a built-in code executor that runs Python code snippets in a subprocess\n","in the local command line environment.\n","The {py:class}`~autogen_core.components.tools.PythonCodeExecutionTool` class wraps the code executor\n",diff --git a/python/packages/autogen-core/samples/patterns/coder_executor.py b/python/packages/autogen-core/samples/patterns/coder_executor.pyindex 9d96c3d39..acd0b8c30 100644--- a/python/packages/autogen-core/samples/patterns/coder_executor.py+++ b/python/packages/autogen-core/samples/patterns/coder_executor.py@@ -22,7 +22,7 @@ from typing import Dict, Listfrom autogen_core.application import SingleThreadedAgentRuntimefrom autogen_core.components import DefaultSubscription, DefaultTopicId, RoutedAgent, message_handler-from autogen_core.components.code_executor import CodeBlock, CodeExecutor, LocalCommandLineCodeExecutor+from autogen_core.components.code_executor import CodeBlock, CodeExecutor, DockerCommandLineCodeExecutorfrom autogen_core.components.models import (AssistantMessage,ChatCompletionClient,@@ -194,7 +194,7 @@ async def main(task: str, temp_dir: str) -> None:)await runtime.register("executor",- lambda: Executor(executor=LocalCommandLineCodeExecutor(work_dir=temp_dir)),+ lambda: Executor(executor=DockerCommandLineCodeExecutor(work_dir=temp_dir)),lambda: [DefaultSubscription()],)runtime.start()diff --git a/python/packages/autogen-core/samples/tool-use/coding_direct.py b/python/packages/autogen-core/samples/tool-use/coding_direct.pyindex 24c347250..52b42960f 100644--- a/python/packages/autogen-core/samples/tool-use/coding_direct.py+++ b/python/packages/autogen-core/samples/tool-use/coding_direct.py@@ -19,7 +19,7 @@ from typing import Listfrom autogen_core.application import SingleThreadedAgentRuntimefrom autogen_core.base import AgentId, AgentInstantiationContextfrom autogen_core.components import FunctionCall, RoutedAgent, message_handler-from autogen_core.components.code_executor import LocalCommandLineCodeExecutor+from autogen_core.components.code_executor import DockerCommandLineCodeExecutorfrom autogen_core.components.models import (AssistantMessage,ChatCompletionClient,@@ -103,7 +103,7 @@ async def main() -> None:tools: List[Tool] = [# A tool that executes Python code.PythonCodeExecutionTool(- LocalCommandLineCodeExecutor(),+ DockerCommandLineCodeExecutor(),)]# Register agents.diff --git a/python/packages/autogen-core/samples/tool-use/coding_direct_with_intercept.py b/python/packages/autogen-core/samples/tool-use/coding_direct_with_intercept.pyindex 25af7a3b5..23f113f9f 100644--- a/python/packages/autogen-core/samples/tool-use/coding_direct_with_intercept.py+++ b/python/packages/autogen-core/samples/tool-use/coding_direct_with_intercept.py@@ -14,7 +14,7 @@ from autogen_core.application import SingleThreadedAgentRuntimefrom autogen_core.base import AgentId, AgentInstantiationContextfrom autogen_core.base.intervention import DefaultInterventionHandler, DropMessagefrom autogen_core.components import FunctionCall-from autogen_core.components.code_executor import LocalCommandLineCodeExecutor+from autogen_core.components.code_executor import DockerCommandLineCodeExecutorfrom autogen_core.components.models import SystemMessagefrom autogen_core.components.tool_agent import ToolAgent, ToolExceptionfrom autogen_core.components.tools import PythonCodeExecutionTool, Tool@@ -44,7 +44,7 @@ async def main() -> None:tools: List[Tool] = [# A tool that executes Python code.PythonCodeExecutionTool(- LocalCommandLineCodeExecutor(),+ DockerCommandLineCodeExecutor(),)]# Register agents.diff --git a/python/packages/autogen-core/samples/tool-use/coding_pub_sub.py b/python/packages/autogen-core/samples/tool-use/coding_pub_sub.pyindex d6e3847dd..ee40388d2 100644--- a/python/packages/autogen-core/samples/tool-use/coding_pub_sub.py+++ b/python/packages/autogen-core/samples/tool-use/coding_pub_sub.py@@ -21,7 +21,7 @@ from typing import Dict, Listfrom autogen_core.application import SingleThreadedAgentRuntimefrom autogen_core.components import DefaultSubscription, DefaultTopicId, FunctionCall, RoutedAgent, message_handler-from autogen_core.components.code_executor import LocalCommandLineCodeExecutor+from autogen_core.components.code_executor import DockerCommandLineCodeExecutorfrom autogen_core.components.models import (AssistantMessage,ChatCompletionClient,@@ -187,7 +187,7 @@ async def main() -> None:# Define the tools.tools: List[Tool] = [PythonCodeExecutionTool(- LocalCommandLineCodeExecutor(),+ DockerCommandLineCodeExecutor(),)]# Register agents.diff --git a/python/packages/team-one/src/team_one/agents/coder.py b/python/packages/team-one/src/team_one/agents/coder.pyindex 13149a131..34b725129 100644--- a/python/packages/team-one/src/team_one/agents/coder.py+++ b/python/packages/team-one/src/team_one/agents/coder.py@@ -2,7 +2,7 @@ import refrom typing import List, Optional, Tuple, Unionfrom autogen_core.base import CancellationToken-from autogen_core.components.code_executor import CodeBlock, CodeExecutor, LocalCommandLineCodeExecutor+from autogen_core.components.code_executor import CodeBlock, CodeExecutor, DockerCommandLineCodeExecutorfrom autogen_core.components.models import (ChatCompletionClient,SystemMessage,@@ -62,7 +62,7 @@ class Executor(BaseWorker):check_last_n_message: int = 5,) -> None:super().__init__(description)- self._executor = executor or LocalCommandLineCodeExecutor()+ self._executor = executor or DockerCommandLineCodeExecutor()self._check_last_n_message = check_last_n_messageasync def _generate_reply(self, cancellation_token: CancellationToken) -> Tuple[bool, UserContent]: