Skip to content

A programming framework for agentic AI

Added m1 cli package (#4949)

afourney7131dc945d93
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 347e3f704..34d71e3b2 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -58,6 +58,7 @@ jobs:
"./packages/agbench",
"./packages/autogen-ext",
"./packages/autogen-agentchat",
+ "./packages/magentic-one-cli",
]
steps:
- uses: actions/checkout@v4
@@ -86,6 +87,7 @@ jobs:
"./packages/agbench",
"./packages/autogen-ext",
"./packages/autogen-agentchat",
+ "./packages/magentic-one-cli",
]
steps:
- uses: actions/checkout@v4
@@ -132,7 +134,7 @@ jobs:
source ${{ github.workspace }}/python/.venv/bin/activate
poe --directory ${{ matrix.package }} test
working-directory: ./python
-
+
codecov:
runs-on: ubuntu-latest
strategy:
@@ -213,7 +215,7 @@ jobs:
source ${{ github.workspace }}/python/.venv/bin/activate
poe --directory ${{ matrix.package }} docs-check-examples
working-directory: ./python
-
+
samples-code-check:
runs-on: ubuntu-latest
steps:
diff --git a/.github/workflows/single-python-package.yml b/.github/workflows/single-python-package.yml
index b4657a5f5..1c73ceb35 100644
--- a/.github/workflows/single-python-package.yml
+++ b/.github/workflows/single-python-package.yml
@@ -14,6 +14,7 @@ on:
- agbench
- autogen-magentic-one
- autogen-studio
+ - magentic-one-cli
ref:
description: 'Tag to deploy'
required: true
diff --git a/python/packages/autogen-core/docs/src/index.md b/python/packages/autogen-core/docs/src/index.md
index 0af7d1079..469f697f8 100644
--- a/python/packages/autogen-core/docs/src/index.md
+++ b/python/packages/autogen-core/docs/src/index.md
@@ -60,7 +60,7 @@ A multi-agent assistant for web and file-based tasks.
Built on AgentChat.
```bash
-pip install magentic-one
+pip install magentic-one-cli
m1 "Find flights from Seattle to Paris and format the result in a table"
```
diff --git a/python/packages/autogen-ext/pyproject.toml b/python/packages/autogen-ext/pyproject.toml
index a4e7d0d9f..8b972e98b 100644
--- a/python/packages/autogen-ext/pyproject.toml
+++ b/python/packages/autogen-ext/pyproject.toml
@@ -18,14 +18,11 @@ dependencies = [
"autogen-core==0.4.0.dev13",
]
-[project.scripts]
-m1 = "autogen_ext.teams.magentic_one_cli:main"
-
[project.optional-dependencies]
langchain = ["langchain_core~= 0.3.3"]
azure = ["azure-core", "azure-identity"]
docker = ["docker~=7.0"]
-openai = ["openai>=1.52.2", "aiofiles"]
+openai = ["openai>=1.52.2", "tiktoken>=0.8.0", "aiofiles"]
file-surfer = [
"autogen-agentchat==0.4.0.dev13",
"markitdown>=0.0.1a2",
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 31db4974b..0a811dacc 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
@@ -409,14 +409,14 @@ class BaseOpenAIChatCompletionClient(ChatCompletionClient):
# TODO: allow custom handling.
# For now we raise an error if images are present and vision is not supported
- if self.capabilities["vision"] is False:
+ if self.model_info["vision"] is False:
for message in messages:
if isinstance(message, UserMessage):
if isinstance(message.content, list) and any(isinstance(x, Image) for x in message.content):
raise ValueError("Model does not support vision and image was provided")
if json_output is not None:
- if self.capabilities["json_output"] is False and json_output is True:
+ if self.model_info["json_output"] is False and json_output is True:
raise ValueError("Model does not support JSON output")
if json_output is True:
@@ -424,13 +424,13 @@ class BaseOpenAIChatCompletionClient(ChatCompletionClient):
else:
create_args["response_format"] = {"type": "text"}
- if self.capabilities["json_output"] is False and json_output is True:
+ if self.model_info["json_output"] is False and json_output is True:
raise ValueError("Model does not support JSON output")
oai_messages_nested = [to_oai_type(m) for m in messages]
oai_messages = [item for sublist in oai_messages_nested for item in sublist]
- if self.capabilities["function_calling"] is False and len(tools) > 0:
+ if self.model_info["function_calling"] is False and len(tools) > 0:
raise ValueError("Model does not support function calling")
future: Union[Task[ParsedChatCompletion[BaseModel]], Task[ChatCompletion]]
if len(tools) > 0:
@@ -622,14 +622,14 @@ class BaseOpenAIChatCompletionClient(ChatCompletionClient):
# TODO: allow custom handling.
# For now we raise an error if images are present and vision is not supported
- if self.capabilities["vision"] is False:
+ if self.model_info["vision"] is False:
for message in messages:
if isinstance(message, UserMessage):
if isinstance(message.content, list) and any(isinstance(x, Image) for x in message.content):
raise ValueError("Model does not support vision and image was provided")
if json_output is not None:
- if self.capabilities["json_output"] is False and json_output is True:
+ if self.model_info["json_output"] is False and json_output is True:
raise ValueError("Model does not support JSON output")
if json_output is True:
diff --git a/python/packages/magentic-one-cli/LICENSE-CODE b/python/packages/magentic-one-cli/LICENSE-CODE
new file mode 100644
index 000000000..9e841e7a2
--- /dev/null
+++ b/python/packages/magentic-one-cli/LICENSE-CODE
@@ -0,0 +1,21 @@
+ MIT License
+
+ Copyright (c) Microsoft Corporation.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE
diff --git a/python/packages/magentic-one-cli/README.md b/python/packages/magentic-one-cli/README.md
new file mode 100644
index 000000000..ccc319776
--- /dev/null
+++ b/python/packages/magentic-one-cli/README.md
@@ -0,0 +1 @@
+# magentic-one-cli
diff --git a/python/packages/magentic-one-cli/pyproject.toml b/python/packages/magentic-one-cli/pyproject.toml
new file mode 100644
index 000000000..b5db07ed7
--- /dev/null
+++ b/python/packages/magentic-one-cli/pyproject.toml
@@ -0,0 +1,47 @@
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[project]
+name = "magentic-one-cli"
+version = "0.1.0"
+license = {file = "LICENSE-CODE"}
+description = "Magentic-One is a generalist multi-agent system, built on `AutoGen-AgentChat`, for solving complex web and file-based tasks. This package installs the `m1` command-line utility to quickly get started with Magentic-One."
+readme = "README.md"
+requires-python = ">=3.10"
+classifiers = [
+ "Programming Language :: Python :: 3",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+]
+dependencies = [
+ "autogen-agentchat", #>=0.4.0<0.5
+ "autogen-ext[openai,magentic-one]", #>=0.4.0<0.5
+]
+
+[project.scripts]
+m1 = "magentic_one_cli._m1:main"
+
+[dependency-groups]
+dev = []
+
+
+[tool.ruff]
+extend = "../../pyproject.toml"
+include = ["src/**", "tests/*.py"]
+
+[tool.pyright]
+extends = "../../pyproject.toml"
+include = ["src"]
+
+[tool.pytest.ini_options]
+minversion = "6.0"
+testpaths = ["tests"]
+
+[tool.poe]
+include = "../../shared_tasks.toml"
+
+[tool.poe.tasks]
+mypy = "mypy --config-file $POE_ROOT/../../pyproject.toml src"
+test = "true"
+coverage = "true"
diff --git a/python/packages/magentic-one-cli/src/magentic_one_cli/__init__.py b/python/packages/magentic-one-cli/src/magentic_one_cli/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/python/packages/magentic-one-cli/src/magentic_one_cli/__main__.py b/python/packages/magentic-one-cli/src/magentic_one_cli/__main__.py
new file mode 100644
index 000000000..44220c725
--- /dev/null
+++ b/python/packages/magentic-one-cli/src/magentic_one_cli/__main__.py
@@ -0,0 +1,3 @@
+from ._m1 import main
+
+main()
diff --git a/python/packages/autogen-ext/src/autogen_ext/teams/magentic_one_cli.py b/python/packages/magentic-one-cli/src/magentic_one_cli/_m1.py
similarity index 90%
rename from python/packages/autogen-ext/src/autogen_ext/teams/magentic_one_cli.py
rename to python/packages/magentic-one-cli/src/magentic_one_cli/_m1.py
index 97abac593..d2698d23f 100644
--- a/python/packages/autogen-ext/src/autogen_ext/teams/magentic_one_cli.py
+++ b/python/packages/magentic-one-cli/src/magentic_one_cli/_m1.py
@@ -1,11 +1,14 @@
import argparse
import asyncio
+import warnings
from autogen_agentchat.ui import Console
-
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.teams.magentic_one import MagenticOne
+# Suppress warnings about the requests.Session() not being closed
+warnings.filterwarnings(action="ignore", message="unclosed", category=ResourceWarning)
+
def main() -> None:
"""
diff --git a/python/packages/magentic-one-cli/src/magentic_one_cli/py.typed b/python/packages/magentic-one-cli/src/magentic_one_cli/py.typed
new file mode 100644
index 000000000..e69de29bb
diff --git a/python/pyproject.toml b/python/pyproject.toml
index f3b5c9453..56e7c1f61 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -31,9 +31,10 @@ autogen-agentchat = { workspace = true }
autogen-core = { workspace = true }
autogen-ext = { workspace = true }
autogen-magentic-one = { workspace = true }
-autogenstudio = { workspace = true }
autogen-test-utils = { workspace = true }
+autogenstudio = { workspace = true }
component-schema-gen = { workspace = true }
+magentic-one-cli = { workspace = true }
[tool.ruff]
line-length = 120
diff --git a/python/uv.lock b/python/uv.lock
index 9f8ed0980..330f570ef 100644
--- a/python/uv.lock
+++ b/python/uv.lock
@@ -26,6 +26,7 @@ members = [
"autogen-test-utils",
"autogenstudio",
"component-schema-gen",
+ "magentic-one-cli",
]
[manifest.dependency-groups]
@@ -509,6 +510,7 @@ magentic-one = [
openai = [
{ name = "aiofiles" },
{ name = "openai" },
+ { name = "tiktoken" },
]
video-surfer = [
{ name = "autogen-agentchat" },
@@ -553,6 +555,7 @@ requires-dist = [
{ name = "pillow", marker = "extra == 'web-surfer'", specifier = ">=11.0.0" },
{ name = "playwright", marker = "extra == 'magentic-one'", specifier = ">=1.48.0" },
{ name = "playwright", marker = "extra == 'web-surfer'", specifier = ">=1.48.0" },
+ { name = "tiktoken", marker = "extra == 'openai'", specifier = ">=0.8.0" },
]
[package.metadata.requires-dev]
@@ -2463,6 +2466,24 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/ba/b2/6a22fb5c0885da3b00e116aee81f0b829ec9ac8f736cd414b4a09413fc7d/lxml-5.3.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:6e91cf736959057f7aac7adfc83481e03615a8e8dd5758aa1d95ea69e8931dba", size = 3487557 },
]
+[[package]]
+name = "magentic-one-cli"
+version = "0.1.0"
+source = { editable = "packages/magentic-one-cli" }
+dependencies = [
+ { name = "autogen-agentchat" },
+ { name = "autogen-ext", extra = ["magentic-one", "openai"] },
+]
+
+[package.metadata]
+requires-dist = [
+ { name = "autogen-agentchat", editable = "packages/autogen-agentchat" },
+ { name = "autogen-ext", extras = ["openai", "magentic-one"], editable = "packages/autogen-ext" },
+]
+
+[package.metadata.requires-dev]
+dev = []
+
[[package]]
name = "mako"
version = "1.3.6"