Skip to content

Commit 802f099

Browse files
committed
Merge branch 'main' into headless_web_surfer
2 parents 0a52483 + 08ba070 commit 802f099

File tree

142 files changed

+9904
-3719
lines changed

Some content is hidden

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

142 files changed

+9904
-3719
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
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: SamplesToolsTests
5+
6+
on:
7+
pull_request:
8+
branches: ["main"]
9+
paths:
10+
- "autogen/**"
11+
- "samples/tools/**"
12+
- ".github/workflows/samples-tools-tests.yml"
13+
- "setup.py"
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
17+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
18+
permissions: {}
19+
jobs:
20+
SamplesToolsFineTuningTests:
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ubuntu-latest, macos-latest]
26+
python-version: ["3.9", "3.10", "3.11"]
27+
steps:
28+
- uses: actions/checkout@v3
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Install packages and dependencies for all tests
34+
run: |
35+
python -m pip install --upgrade pip wheel
36+
pip install -e .
37+
pip install pytest
38+
- name: Set AUTOGEN_USE_DOCKER based on OS
39+
shell: bash
40+
run: |
41+
if [[ ${{ matrix.os }} != ubuntu-latest ]]; then
42+
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
43+
fi
44+
- name: Test finetuning tools
45+
run: |
46+
pytest samples/tools/finetuning/tests/

.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 |

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
<img src="https://github.com/microsoft/autogen/blob/main/website/static/img/flaml.svg" width=200>
1313
<br>
1414
</p> -->
15+
:fire: Mar 3: What's new in AutoGen? 📰[Blog](https://microsoft.github.io/autogen/blog/2024/03/03/AutoGen-Update); 📺[Youtube](https://www.youtube.com/watch?v=j_mtwQiaLGU).
16+
1517
:fire: Mar 1: the first AutoGen multi-agent experiment on the challenging [GAIA](https://huggingface.co/spaces/gaia-benchmark/leaderboard) benchmark achieved the No. 1 accuracy in all the three levels.
1618

1719
:fire: Jan 30: AutoGen is highlighted by Peter Lee in Microsoft Research Forum [Keynote](https://t.co/nUBSjPDjqD).
1820

19-
:warning: Jan 23: **Breaking Change in Latest Release v0.2.8** `use_docker` defaults to `True` for code-execution. See [blog post](https://microsoft.github.io/autogen/blog/2024/01/23/Code-execution-in-docker) for details and [FAQ](https://microsoft.github.io/autogen/docs/FAQ#agents-are-throwing-due-to-docker-not-running-how-can-i-resolve-this) for troubleshooting any issues.
20-
2121
:fire: Dec 31: [AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation Framework](https://arxiv.org/abs/2308.08155) is selected by [TheSequence: My Five Favorite AI Papers of 2023](https://thesequence.substack.com/p/my-five-favorite-ai-papers-of-2023).
2222

2323
<!-- :fire: Nov 24: pyautogen [v0.2](https://github.com/microsoft/autogen/releases/tag/v0.2.0) is released with many updates and new features compared to v0.1.1. It switches to using openai-python v1. Please read the [migration guide](https://microsoft.github.io/autogen/docs/Installation#python). -->

autogen/agentchat/chat.py

+21-31
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,19 @@ def __post_carryover_processing(chat_info: Dict[str, Any]):
111111
if isinstance(chat_info["carryover"], list)
112112
else chat_info["carryover"]
113113
)
114+
message = chat_info.get("message")
115+
if isinstance(message, str):
116+
print_message = message
117+
elif callable(message):
118+
print_message = "Callable: " + message.__name__
119+
elif isinstance(message, dict):
120+
print_message = "Dict: " + str(message)
121+
elif message is None:
122+
print_message = "None"
114123
print(colored("\n" + "*" * 80, "blue"), flush=True, sep="")
115124
print(
116125
colored(
117-
"Start a new chat with the following message: \n"
118-
+ chat_info.get("message")
119-
+ "\n\nWith the following carryover: \n"
120-
+ print_carryover,
126+
"Starting a new chat....\n\nMessage:\n" + print_message + "\n\nCarryover: \n" + print_carryover,
121127
"blue",
122128
),
123129
flush=True,
@@ -132,35 +138,19 @@ def initiate_chats(chat_queue: List[Dict[str, Any]]) -> List[ChatResult]:
132138
chat_queue (List[Dict]): a list of dictionaries containing the information of the chats.
133139
Each dictionary should contain the input arguments for `ConversableAgent.initiate_chat`.
134140
More specifically, each dictionary could include the following fields:
135-
- recipient: the recipient agent.
136141
- "sender": the sender agent.
137142
- "recipient": the recipient agent.
138-
- clear_history (bool): whether to clear the chat history with the agent. Default is True.
139-
- silent (bool or None): (Experimental) whether to print the messages for this conversation. Default is False.
140-
- cache (Cache or None): the cache client to be used for this conversation. Default is None.
141-
- max_turns (int or None): the maximum number of turns for the chat. If None, the chat will continue until a termination condition is met. Default is None.
142-
- "message" needs to be provided if the `generate_init_message` method is not overridden.
143-
Otherwise, input() will be called to get the initial message.
144-
- "summary_method": a string or callable specifying the method to get a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".
145-
- Supported string are "last_msg" and "reflection_with_llm":
146-
when set "last_msg", it returns the last message of the dialog as the summary.
147-
when set "reflection_with_llm", it returns a summary extracted using an llm client.
148-
`llm_config` must be set in either the recipient or sender.
149-
"reflection_with_llm" requires the llm_config to be set in either the sender or the recipient.
150-
- A callable summary_method should take the recipient and sender agent in a chat as input and return a string of summary. E.g,
151-
```python
152-
def my_summary_method(
153-
sender: ConversableAgent,
154-
recipient: ConversableAgent,
155-
):
156-
return recipient.last_message(sender)["content"]
157-
```
158-
- "summary_prompt": This filed can be used to specify the prompt used to extract a summary when summary_method is "reflection_with_llm".
159-
Default is None and the following default prompt will be used when "summary_method" is set to "reflection_with_llm":
160-
"Identify and extract the final solution to the originally asked question based on the conversation."
161-
- "carryover": It can be used to specify the carryover information to be passed to this chat.
162-
If provided, we will combine this carryover with the "message" content when generating the initial chat
163-
message in `generate_init_message`.
143+
- "clear_history" (bool): whether to clear the chat history with the agent. Default is True.
144+
- "silent" (bool or None): (Experimental) whether to print the messages for this conversation. Default is False.
145+
- "cache" (Cache or None): the cache client to be used for this conversation. Default is None.
146+
- "max_turns" (int or None): the maximum number of turns for the chat. If None, the chat will continue until a termination condition is met. Default is None.
147+
- "summary_method" (str or callable): a string or callable specifying the method to get a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".
148+
- "summary_args" (dict): a dictionary of arguments to be passed to the summary_method. Default is {}.
149+
- "message" (str, callable or None): if None, input() will be called to get the initial message.
150+
- **context: additional context information to be passed to the chat.
151+
- "carryover": It can be used to specify the carryover information to be passed to this chat.
152+
If provided, we will combine this carryover with the "message" content when generating the initial chat
153+
message in `generate_init_message`.
164154
165155
Returns:
166156
(list): a list of ChatResult objects corresponding to the finished chats in the chat_queue.

autogen/agentchat/contrib/compressible_agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def colored(x, *args, **kwargs):
1919

2020

2121
class CompressibleAgent(ConversableAgent):
22-
"""(Experimental) CompressibleAgent agent. While this agent retains all the default functionalities of the `AssistantAgent`,
22+
"""(CompressibleAgent will be deprecated. Refer to https://github.com/microsoft/autogen/blob/main/notebook/agentchat_capability_long_context_handling.ipynb for long context handling capability.) CompressibleAgent agent. While this agent retains all the default functionalities of the `AssistantAgent`,
2323
it also provides the added feature of compression when activated through the `compress_config` setting.
2424
2525
`compress_config` is set to False by default, making this agent equivalent to the `AssistantAgent`.

autogen/agentchat/contrib/math_user_proxy_agent.py

+22-15
Original file line numberDiff line numberDiff line change
@@ -177,28 +177,35 @@ def __init__(
177177
self._previous_code = ""
178178
self.last_reply = None
179179

180-
def generate_init_message(self, problem, prompt_type="default", customized_prompt=None):
180+
@staticmethod
181+
def message_generator(sender, recipient, context):
181182
"""Generate a prompt for the assistant agent with the given problem and prompt.
182183
183184
Args:
184-
problem (str): the problem to be solved.
185-
prompt_type (str): the type of the prompt. Possible values are "default", "python", "wolfram".
186-
(1) "default": the prompt that allows the agent to choose between 3 ways to solve a problem:
187-
1. write a python program to solve it directly.
188-
2. solve it directly without python.
189-
3. solve it step by step with python.
190-
(2) "python":
191-
a simplified prompt from the third way of the "default" prompt, that asks the assistant
192-
to solve the problem step by step with python.
193-
(3) "two_tools":
194-
a simplified prompt similar to the "python" prompt, but allows the model to choose between
195-
Python and Wolfram Alpha to solve the problem.
196-
customized_prompt (str): a customized prompt to be used. If it is not None, the prompt_type will be ignored.
185+
sender (Agent): the sender of the message.
186+
recipient (Agent): the recipient of the message.
187+
context (dict): a dictionary with the following fields:
188+
problem (str): the problem to be solved.
189+
prompt_type (str, Optional): the type of the prompt. Possible values are "default", "python", "wolfram".
190+
(1) "default": the prompt that allows the agent to choose between 3 ways to solve a problem:
191+
1. write a python program to solve it directly.
192+
2. solve it directly without python.
193+
3. solve it step by step with python.
194+
(2) "python":
195+
a simplified prompt from the third way of the "default" prompt, that asks the assistant
196+
to solve the problem step by step with python.
197+
(3) "two_tools":
198+
a simplified prompt similar to the "python" prompt, but allows the model to choose between
199+
Python and Wolfram Alpha to solve the problem.
200+
customized_prompt (str, Optional): a customized prompt to be used. If it is not None, the prompt_type will be ignored.
197201
198202
Returns:
199203
str: the generated prompt ready to be sent to the assistant agent.
200204
"""
201-
self._reset()
205+
sender._reset()
206+
problem = context.get("problem")
207+
prompt_type = context.get("prompt_type", "default")
208+
customized_prompt = context.get("customized_prompt", None)
202209
if customized_prompt is not None:
203210
return customized_prompt + problem
204211
return PROMPTS[prompt_type] + problem

0 commit comments

Comments
 (0)