Skip to content

Commit

Permalink
Merge branch 'main' into 3903-update-net-deps-to-release-vers-when-ne…
Browse files Browse the repository at this point in the history
…t-9-is-finalized
  • Loading branch information
rysweet authored Nov 25, 2024
2 parents a486ace + 1a02e2b commit 471725d
Show file tree
Hide file tree
Showing 39 changed files with 395 additions and 208 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ jobs:
poe --directory ${{ matrix.package }} docs-check
working-directory: ./python

docs-example-check:
runs-on: ubuntu-latest
strategy:
matrix:
package: ["./packages/autogen-core"]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: uv sync --locked --all-extras
working-directory: ./python
- name: Run task
run: |
source ${{ github.workspace }}/python/.venv/bin/activate
poe --directory ${{ matrix.package }} docs-check-examples
working-directory: ./python

check-proto-changes-python:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
{ ref: "v0.4.0.dev4", dest-dir: "0.4.0.dev4" },
{ ref: "v0.4.0.dev5", dest-dir: "0.4.0.dev5" },
{ ref: "v0.4.0.dev6", dest-dir: "0.4.0.dev6" },
{ ref: "v0.4.0.dev7", dest-dir: "0.4.0.dev7" },
]
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ We look forward to your contributions!
First install the packages:

```bash
pip install 'autogen-agentchat==0.4.0.dev6' 'autogen-ext[openai]==0.4.0.dev6'
pip install 'autogen-agentchat==0.4.0.dev7' 'autogen-ext[openai]==0.4.0.dev7'
```

The following code uses OpenAI's GPT-4o model and you need to provide your
Expand Down
7 changes: 6 additions & 1 deletion docs/switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
{
"name": "0.4.0.dev6",
"version": "0.4.0.dev6",
"url": "/autogen/0.4.0.dev6/",
"url": "/autogen/0.4.0.dev6/"
},
{
"name": "0.4.0.dev7",
"version": "0.4.0.dev7",
"url": "/autogen/0.4.0.dev7/",
"preferred": true
}
]
6 changes: 5 additions & 1 deletion dotnet/samples/Hello/HelloAgent/HelloAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
<PackageReference Include="Grpc.AspNetCore" />
<PackageReference Include="Grpc.Net.ClientFactory" />
<PackageReference Include="Grpc.Tools" PrivateAssets="All" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" />
<PackageReference Include="Microsoft.Orleans.Sdk" />
<PackageReference Include="Microsoft.SemanticKernel" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static IHostApplicationBuilder AddAgentService(this IHostApplicationBuild

public static IHostApplicationBuilder AddLocalAgentService(this IHostApplicationBuilder builder, bool useGrpc = true)
{
return builder.AddAgentService(local: false, useGrpc);
return builder.AddAgentService(local: true, useGrpc);
}

public static WebApplication MapAgentService(this WebApplication app, bool local = false, bool useGrpc = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// IGateway.cs
using Microsoft.AutoGen.Abstractions;

namespace Microsoft.AutoGen.Abstractions;
namespace Microsoft.AutoGen.Agents;

public interface IGateway : IGrainObserver
{
Expand Down
4 changes: 2 additions & 2 deletions python/packages/autogen-agentchat/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "autogen-agentchat"
version = "0.4.0.dev6"
version = "0.4.0.dev7"
license = {file = "LICENSE-CODE"}
description = "AutoGen agents and teams library"
readme = "README.md"
Expand All @@ -15,7 +15,7 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"autogen-core==0.4.0.dev6",
"autogen-core==0.4.0.dev7",
]

[tool.uv]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class CodeExecutorAgent(BaseChatAgent):
.. code-block:: python
import asyncio
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
async def run_code_executor_agent() -> None:
Expand All @@ -51,8 +53,7 @@ async def run_code_executor_agent() -> None:
await code_executor.stop()
# Use asyncio.run(run_code_executor_agent()) when running in a script.
await run_code_executor_agent()
asyncio.run(run_code_executor_agent())
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class TerminationCondition(ABC):
.. code-block:: python
import asyncio
from autogen_agentchat.teams import MaxTurnsTermination, TextMentionTermination
from autogen_agentchat.task import MaxMessageTermination, TextMentionTermination
async def main() -> None:
# Terminate the conversation after 10 turns or if the text "TERMINATE" is mentioned.
cond1 = MaxTurnsTermination(10) | TextMentionTermination("TERMINATE")
cond1 = MaxMessageTermination(10) | TextMentionTermination("TERMINATE")
# Terminate the conversation after 10 turns and if the text "TERMINATE" is mentioned.
cond2 = MaxTurnsTermination(10) & TextMentionTermination("TERMINATE")
cond2 = MaxMessageTermination(10) & TextMentionTermination("TERMINATE")
# ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ class ExternalTermination(TerminationCondition):
.. code-block:: python
from autogen_agentchat.task import ExternalTermination
termination = ExternalTermination()
# Run the team in an asyncio task.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,18 @@ async def book_trip() -> str:
.. code-block:: python
import asyncio
from typing import Sequence
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.messages import AgentMessage
async def main() -> None:
model_client = OpenAIChatCompletionClient(model="gpt-4o")
def check_caculation(x: int, y: int, answer: int) -> str:
def check_calculation(x: int, y: int, answer: int) -> str:
if x + y == answer:
return "Correct!"
else:
Expand All @@ -281,12 +283,12 @@ def check_caculation(x: int, y: int, answer: int) -> str:
agent2 = AssistantAgent(
"Agent2",
model_client,
tools=[check_caculation],
tools=[check_calculation],
description="For checking calculation",
system_message="Check the answer and respond with 'Correct!' or 'Incorrect!'",
)
def selector_func(messages):
def selector_func(messages: Sequence[AgentMessage]) -> str | None:
if len(messages) == 1 or messages[-1].content == "Incorrect!":
return "Agent1"
if messages[-1].source == "Agent1":
Expand Down
98 changes: 98 additions & 0 deletions python/packages/autogen-core/docs/src/_extension/code_lint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Modified from: https://github.com/kai687/sphinxawesome-codelinter

import tempfile
from typing import AbstractSet, Any, Iterable

from docutils import nodes
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.util import logging
from sphinx.util.console import darkgreen, darkred, red, teal, faint # type: ignore[attr-defined]

from pygments import highlight # type: ignore
from pygments.lexers import PythonLexer
from pygments.formatters import TerminalFormatter

logger = logging.getLogger(__name__)

__version__ = "0.1.0"


class CodeLinter(Builder):
"""Iterate over all ``literal_block`` nodes.
pipe them into any command line tool that
can read from standard input.
"""

name = "code_lint"
allow_parallel = True

def init(self) -> None:
"""Initialize."""
self._had_errors = False
pass

def get_outdated_docs(self) -> str | Iterable[str]:
"""Check for outdated files.
Return an iterable of outdated output files, or a string describing what an
update will build.
"""
return self.env.found_docs

def get_target_uri(self, docname: str, typ: str | None = None) -> str:
"""Return Target URI for a document name."""
return ""

def prepare_writing(self, docnames: AbstractSet[str]) -> None:
"""Run these steps before documents are written."""
return

def write_doc(self, docname: str, doctree: nodes.Node) -> None:
path_prefix: str = self.app.config.code_lint_path_prefix
supported_languages = set(["python"])

if not docname.startswith(path_prefix):
return

for code in doctree.findall(nodes.literal_block):
if code["language"] in supported_languages:
logger.info("Checking a code block in %s...", docname, nonl=True)
if "ignore" in code["classes"]:
logger.info(" " + darkgreen("OK[ignored]"))
continue

# Create a temporary file to store the code block
with tempfile.NamedTemporaryFile(mode="wb", suffix=".py") as temp_file:
temp_file.write(code.astext().encode())
temp_file.flush()

# Run pyright on the temporary file using subprocess.run
import subprocess

result = subprocess.run(["pyright", temp_file.name], capture_output=True, text=True)
if result.returncode != 0:
logger.info(" " + darkred("FAIL"))
highlighted_code = highlight(code.astext(), PythonLexer(), TerminalFormatter()) # type: ignore
output = f"{faint('========================================================')}\n{red('Error')}: Pyright found issues in {teal(docname)}:\n{faint('--------------------------------------------------------')}\n{highlighted_code}\n{faint('--------------------------------------------------------')}\n\n{teal('pyright output:')}\n{red(result.stdout)}{faint('========================================================')}\n"
logger.info(output)
self._had_errors = True
else:
logger.info(" " + darkgreen("OK"))

def finish(self) -> None:
"""Finish the build process."""
if self._had_errors:
raise RuntimeError("Code linting failed - see earlier output")


def setup(app: Sphinx) -> dict[str, Any]:
app.add_builder(CodeLinter)
app.add_config_value("code_lint_path_prefix", "", "env")

return {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}
11 changes: 10 additions & 1 deletion python/packages/autogen-core/docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"sphinx_copybutton",
"_extension.gallery_directive",
"myst_nb",
"sphinxcontrib.autodoc_pydantic"
"sphinxcontrib.autodoc_pydantic",
"_extension.code_lint",
]
suppress_warnings = ["myst.header"]

Expand Down Expand Up @@ -148,6 +149,14 @@

intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}

code_lint_path_prefix = "reference/python"

nb_mime_priority_overrides = [
('code_lint', 'image/jpeg', 100),
('code_lint', 'image/png', 100),
('code_lint', 'text/plain', 100)
]


def setup_to_main(
app: Sphinx, pagename: str, templatename: str, context, doctree
Expand Down
4 changes: 2 additions & 2 deletions python/packages/autogen-core/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ AgentChat </div>
High-level API that includes preset agents and teams for building multi-agent systems.

```sh
pip install 'autogen-agentchat==0.4.0.dev6'
pip install 'autogen-agentchat==0.4.0.dev7'
```

💡 *Start here if you are looking for an API similar to AutoGen 0.2*
Expand All @@ -82,7 +82,7 @@ Get Started
Provides building blocks for creating asynchronous, event driven multi-agent systems.

```sh
pip install 'autogen-core==0.4.0.dev6'
pip install 'autogen-core==0.4.0.dev7'
```

+++
Expand Down
12 changes: 6 additions & 6 deletions python/packages/autogen-core/docs/src/packages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ myst:
Library that is at a similar level of abstraction as AutoGen 0.2, including default agents and group chat.

```sh
pip install 'autogen-agentchat==0.4.0.dev6'
pip install 'autogen-agentchat==0.4.0.dev7'
```

[{fas}`circle-info;pst-color-primary` User Guide](/user-guide/agentchat-user-guide/index.md) | [{fas}`file-code;pst-color-primary` API Reference](/reference/python/autogen_agentchat/autogen_agentchat.rst) | [{fab}`python;pst-color-primary` PyPI](https://pypi.org/project/autogen-agentchat/0.4.0.dev6/) | [{fab}`github;pst-color-primary` Source](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-agentchat)
[{fas}`circle-info;pst-color-primary` User Guide](/user-guide/agentchat-user-guide/index.md) | [{fas}`file-code;pst-color-primary` API Reference](/reference/python/autogen_agentchat/autogen_agentchat.rst) | [{fab}`python;pst-color-primary` PyPI](https://pypi.org/project/autogen-agentchat/0.4.0.dev7/) | [{fab}`github;pst-color-primary` Source](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-agentchat)
:::

(pkg-info-autogen-core)=
Expand All @@ -46,10 +46,10 @@ pip install 'autogen-agentchat==0.4.0.dev6'
Implements the core functionality of the AutoGen framework, providing basic building blocks for creating multi-agent systems.

```sh
pip install 'autogen-core==0.4.0.dev6'
pip install 'autogen-core==0.4.0.dev7'
```

[{fas}`circle-info;pst-color-primary` User Guide](/user-guide/core-user-guide/index.md) | [{fas}`file-code;pst-color-primary` API Reference](/reference/python/autogen_core/autogen_core.rst) | [{fab}`python;pst-color-primary` PyPI](https://pypi.org/project/autogen-core/0.4.0.dev6/) | [{fab}`github;pst-color-primary` Source](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core)
[{fas}`circle-info;pst-color-primary` User Guide](/user-guide/core-user-guide/index.md) | [{fas}`file-code;pst-color-primary` API Reference](/reference/python/autogen_core/autogen_core.rst) | [{fab}`python;pst-color-primary` PyPI](https://pypi.org/project/autogen-core/0.4.0.dev7/) | [{fab}`github;pst-color-primary` Source](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core)
:::

(pkg-info-autogen-ext)=
Expand All @@ -61,7 +61,7 @@ pip install 'autogen-core==0.4.0.dev6'
Implementations of core components that interface with external services, or use extra dependencies. For example, Docker based code execution.

```sh
pip install 'autogen-ext==0.4.0.dev6'
pip install 'autogen-ext==0.4.0.dev7'
```

Extras:
Expand All @@ -71,7 +71,7 @@ Extras:
- `docker` needed for {py:class}`~autogen_ext.code_executors.DockerCommandLineCodeExecutor`
- `openai` needed for {py:class}`~autogen_ext.models.OpenAIChatCompletionClient`

[{fas}`circle-info;pst-color-primary` User Guide](/user-guide/extensions-user-guide/index.md) | [{fas}`file-code;pst-color-primary` API Reference](/reference/python/autogen_ext/autogen_ext.rst) | [{fab}`python;pst-color-primary` PyPI](https://pypi.org/project/autogen-ext/0.4.0.dev6/) | [{fab}`github;pst-color-primary` Source](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-ext)
[{fas}`circle-info;pst-color-primary` User Guide](/user-guide/extensions-user-guide/index.md) | [{fas}`file-code;pst-color-primary` API Reference](/reference/python/autogen_ext/autogen_ext.rst) | [{fab}`python;pst-color-primary` PyPI](https://pypi.org/project/autogen-ext/0.4.0.dev7/) | [{fab}`github;pst-color-primary` Source](https://github.com/microsoft/autogen/tree/main/python/packages/autogen-ext)
:::

(pkg-info-autogen-magentic-one)=
Expand Down
Loading

0 comments on commit 471725d

Please sign in to comment.