Skip to content

Commit 7362fb9

Browse files
committed
Merge remote-tracking branch 'origin/main' into add-output-protocol
2 parents 991bb14 + 146d49b commit 7362fb9

File tree

89 files changed

+5846
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5846
-161
lines changed

.devcontainer/Dockerfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:3.10
99
# Update the OS and maybe install packages
1010
#
1111
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# add git lhs to apt
14+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
15+
1216
RUN apt-get update \
1317
&& apt-get upgrade -y \
14-
&& apt-get -y install --no-install-recommends build-essential npm \
18+
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \
1519
&& apt-get autoremove -y \
1620
&& apt-get clean -y \
1721
&& arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \
@@ -22,6 +26,7 @@ ENV DEBIAN_FRONTEND=dialog
2226

2327
# For docs
2428
RUN npm install --global yarn
29+
RUN pip install --upgrade pip
2530
RUN pip install pydoc-markdown
2631
RUN pip install pyyaml
2732
RUN pip install colored

.devcontainer/dev/Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Basic setup
22
FROM python:3.11-slim-bookworm
33

4+
# add git lhs to apt
5+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
6+
47
# Update and install necessary packages
58
RUN apt-get update && apt-get -y update
69
# added vim and nano for convenience
7-
RUN apt-get install -y sudo git npm vim nano curl wget
10+
RUN apt-get install -y sudo git npm vim nano curl wget git-lfs
811

912
# Setup a non-root user 'autogen' with sudo access
1013
RUN adduser --disabled-password --gecos '' autogen
@@ -44,6 +47,7 @@ ENV PATH="${PATH}:/home/autogen/quarto/quarto-1.5.23/bin/"
4447
EXPOSE 3000
4548

4649
# Pre-load popular Python packages
50+
RUN pip install --upgrade pip
4751
RUN pip install numpy pandas matplotlib seaborn scikit-learn requests urllib3 nltk pillow pytest beautifulsoup4
4852

4953
# Set the default command to bash

.devcontainer/full/Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
FROM python:3.11-slim-bookworm
22

3+
# add git lhs to apt
4+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
5+
36
# Update and install dependencies
47
RUN apt-get update \
58
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
6-
software-properties-common sudo\
9+
software-properties-common sudo git-lfs \
710
&& apt-get clean \
811
&& rm -rf /var/lib/apt/lists/*
912

.devcontainer/studio/Dockerfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:3.10
99
# Update the OS and maybe install packages
1010
#
1111
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# add git lhs to apt
14+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
15+
1216
RUN apt-get update \
1317
&& apt-get upgrade -y \
14-
&& apt-get -y install --no-install-recommends build-essential npm \
18+
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \
1519
&& apt-get autoremove -y \
1620
&& apt-get clean -y \
1721
&& rm -rf /var/lib/apt/lists/*
1822
ENV DEBIAN_FRONTEND=dialog
1923

2024
# For docs
2125
RUN npm install --global yarn
26+
RUN pip install --upgrade pip
2227
RUN pip install pydoc-markdown

.gitattributes

Whitespace-only changes.

.github/workflows/dotnet-release.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: dotnet-release
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- dotnet/release
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
jobs:
21+
build:
22+
name: Build and release
23+
runs-on: ubuntu-latest
24+
environment: dotnet
25+
defaults:
26+
run:
27+
working-directory: dotnet
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Setup .NET
31+
uses: actions/setup-dotnet@v3
32+
with:
33+
global-json-file: dotnet/global.json
34+
- name: Restore dependencies
35+
run: |
36+
dotnet restore -bl
37+
- name: Build
38+
run: |
39+
echo "Build AutoGen"
40+
dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true
41+
- name: Unit Test
42+
run: dotnet test --no-build -bl --configuration Release
43+
env:
44+
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
45+
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
46+
AZURE_GPT_35_MODEL_ID: ${{ secrets.AZURE_GPT_35_MODEL_ID }}
47+
OEPNAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
48+
- name: Pack
49+
run: |
50+
echo "Create release build package"
51+
dotnet pack --no-build --configuration Release --output './output/release' -bl
52+
53+
echo "ls output directory"
54+
ls -R ./output
55+
- name: Publish package to Nuget
56+
run: |
57+
echo "Publish package to Nuget"
58+
echo "ls output directory"
59+
ls -R ./output/release
60+
dotnet nuget push --api-key AzureArtifacts ./output/release/*.nupkg --skip-duplicate --api-key ${{ secrets.AUTOGEN_NUGET_API_KEY }}
61+
- name: Tag commit
62+
run: |
63+
Write-Host "Tag commit"
64+
# version = eng/MetaInfo.props.Project.PropertyGroup.VersionPrefix
65+
$metaInfoContent = cat ./eng/MetaInfo.props
66+
$version = $metaInfoContent | Select-String -Pattern "<VersionPrefix>(.*)</VersionPrefix>" | ForEach-Object { $_.Matches.Groups[1].Value }
67+
git tag -a "$version" -m "AutoGen.Net release $version"
68+
git push origin --tags
69+
shell: pwsh

.github/workflows/type-check.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ jobs:
1919
- uses: actions/setup-python@v4
2020
- run: pip install ".[jupyter-executor]" mypy
2121
# As more modules are type check clean, add them here
22-
- run: mypy --install-types --non-interactive autogen/logger
22+
- run: |
23+
mypy --install-types --non-interactive \
24+
autogen/logger \
25+
autogen/exception_utils.py

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,7 @@ test/agentchat/test_agent_scripts/*
178178

179179
# test cache
180180
.cache_test
181+
.db
182+
181183

182184
notebook/result.png

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
rev: v2.2.6
3636
hooks:
3737
- id: codespell
38-
args: ["-L", "ans,linar,nam,"]
38+
args: ["-L", "ans,linar,nam,tread,ot,"]
3939
exclude: |
4040
(?x)^(
4141
pyproject.toml |

autogen/agentchat/conversable_agent.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ def __init__(
131131
description (str): a short description of the agent. This description is used by other agents
132132
(e.g. the GroupChatManager) to decide when to call upon this agent. (Default: system_message)
133133
"""
134+
# we change code_execution_config below and we have to make sure we don't change the input
135+
# in case of UserProxyAgent, without this we could even change the default value {}
136+
code_execution_config = (
137+
code_execution_config.copy() if hasattr(code_execution_config, "copy") else code_execution_config
138+
)
139+
134140
self._name = name
135141
# a dictionary of conversations, default value is list
136142
self._oai_messages = defaultdict(list)
@@ -265,13 +271,10 @@ def description(self, description: str):
265271
self._description = description
266272

267273
@property
268-
def code_executor(self) -> CodeExecutor:
269-
"""The code executor used by this agent. Raise if code execution is disabled."""
274+
def code_executor(self) -> Optional[CodeExecutor]:
275+
"""The code executor used by this agent. Returns None if code execution is disabled."""
270276
if not hasattr(self, "_code_executor"):
271-
raise ValueError(
272-
"No code executor as code execution is disabled. "
273-
"To enable code execution, set code_execution_config."
274-
)
277+
return None
275278
return self._code_executor
276279

277280
def register_reply(

autogen/agentchat/user_proxy_agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(
3030
max_consecutive_auto_reply: Optional[int] = None,
3131
human_input_mode: Literal["ALWAYS", "TERMINATE", "NEVER"] = "ALWAYS",
3232
function_map: Optional[Dict[str, Callable]] = None,
33-
code_execution_config: Optional[Union[Dict, Literal[False]]] = None,
33+
code_execution_config: Union[Dict, Literal[False]] = {},
3434
default_auto_reply: Optional[Union[str, Dict, None]] = "",
3535
llm_config: Optional[Union[Dict, Literal[False]]] = False,
3636
system_message: Optional[Union[str, List]] = "",

autogen/coding/base.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Protocol, Union, runtime_checkable
1+
from typing import Any, Dict, List, Optional, Protocol, Union, runtime_checkable
22

33
from pydantic import BaseModel, Field
44

@@ -77,3 +77,12 @@ class IPythonCodeResult(CodeResult):
7777
default_factory=list,
7878
description="The list of files that the executed code blocks generated.",
7979
)
80+
81+
82+
class CommandLineCodeResult(CodeResult):
83+
"""(Experimental) A code result class for command line code executor."""
84+
85+
code_file: Optional[str] = Field(
86+
default=None,
87+
description="The file that the executed code block was saved to.",
88+
)

autogen/coding/docker_commandline_code_executor.py

+11-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from docker.models.containers import Container
1212
from docker.errors import ImageNotFound
1313

14-
from .local_commandline_code_executor import CommandLineCodeResult
14+
from .utils import _get_file_name_from_content
15+
from .base import CommandLineCodeResult
1516

1617
from ..code_utils import TIMEOUT_MSG, _cmd
1718
from .base import CodeBlock, CodeExecutor, CodeExtractor
@@ -168,25 +169,15 @@ def execute_code_blocks(self, code_blocks: List[CodeBlock]) -> CommandLineCodeRe
168169
lang = code_block.language
169170
code = code_block.code
170171

171-
code_hash = md5(code.encode()).hexdigest()
172-
173-
# Check if there is a filename comment
174-
# Get first line
175-
first_line = code.split("\n")[0]
176-
if first_line.startswith("# filename:"):
177-
filename = first_line.split(":")[1].strip()
178-
179-
# Handle relative paths in the filename
180-
path = Path(filename)
181-
if not path.is_absolute():
182-
path = Path("/workspace") / path
183-
path = path.resolve()
184-
try:
185-
path.relative_to(Path("/workspace"))
186-
except ValueError:
187-
return CommandLineCodeResult(exit_code=1, output="Filename is not in the workspace")
188-
else:
189-
# create a file with a automatically generated name
172+
try:
173+
# Check if there is a filename comment
174+
filename = _get_file_name_from_content(code, Path("/workspace"))
175+
except ValueError:
176+
return CommandLineCodeResult(exit_code=1, output="Filename is not in the workspace")
177+
178+
if filename is None:
179+
# create a file with an automatically generated name
180+
code_hash = md5(code.encode()).hexdigest()
190181
filename = f"tmp_code_{code_hash}.{'py' if lang.startswith('python') else lang}"
191182

192183
code_path = self._work_dir / filename

0 commit comments

Comments
 (0)