Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added m1 cli package #4949

Merged
merged 7 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
"./packages/agbench",
"./packages/autogen-ext",
"./packages/autogen-agentchat",
"./packages/magentic-one-cli",
]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -86,6 +87,7 @@ jobs:
"./packages/agbench",
"./packages/autogen-ext",
"./packages/autogen-agentchat",
"./packages/magentic-one-cli",
]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/single-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- agbench
- autogen-magentic-one
- autogen-studio
- magentic-one-cli
ref:
description: 'Tag to deploy'
required: true
Expand Down
2 changes: 1 addition & 1 deletion python/packages/autogen-core/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```

Expand Down
5 changes: 1 addition & 4 deletions python/packages/autogen-ext/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,28 +409,28 @@ async def create(

# 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:
create_args["response_format"] = {"type": "json_object"}
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:
Expand Down Expand Up @@ -622,14 +622,14 @@ async def create_stream(

# 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:
Expand Down
21 changes: 21 additions & 0 deletions python/packages/magentic-one-cli/LICENSE-CODE
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions python/packages/magentic-one-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# magentic-one-cli
47 changes: 47 additions & 0 deletions python/packages/magentic-one-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._m1 import main

main()
Empty file.
3 changes: 2 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading