Skip to content

Commit e43a86c

Browse files
committed
Merge remote-tracking branch 'origin/main' into retry_reply
2 parents 6f663ef + 9708058 commit e43a86c

File tree

89 files changed

+3378
-980
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

+3378
-980
lines changed

.github/workflows/dotnet-build.yml

+112-7
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@
44
name: dotnet-ci
55

66
on:
7+
workflow_dispatch:
78
pull_request:
8-
branches: [ "main" ]
9+
branches: [ "dotnet" ]
910
paths:
1011
- 'dotnet/**'
12+
push:
13+
branches: [ "dotnet" ]
1114

1215
concurrency:
1316
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
14-
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
17+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' || github.ref != 'refs/heads/dotnet' }}
1518

1619
permissions:
1720
contents: read
21+
packages: write
1822

1923
jobs:
2024
build:
21-
name: CI
25+
name: Build
2226
runs-on: ubuntu-latest
2327
defaults:
2428
run:
@@ -28,10 +32,111 @@ jobs:
2832
- name: Setup .NET
2933
uses: actions/setup-dotnet@v3
3034
with:
31-
global-json-file: global.json
35+
global-json-file: dotnet/global.json
3236
- name: Restore dependencies
33-
run: dotnet restore
37+
run: |
38+
# dotnet nuget add source --name dotnet-tool https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json --configfile NuGet.config
39+
dotnet restore -bl
3440
- name: Build
35-
run: dotnet build --no-restore
41+
run: |
42+
echo "Build AutoGen"
43+
dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true
3644
- name: Unit Test
37-
run: dotnet test --no-build --verbosity normal
45+
run: dotnet test --no-build -bl --configuration Release
46+
openai-test:
47+
name: Run openai test
48+
runs-on: ubuntu-latest
49+
environment: dotnet
50+
defaults:
51+
run:
52+
working-directory: dotnet
53+
if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dotnet')
54+
needs: build
55+
steps:
56+
- uses: actions/checkout@v3
57+
- name: Setup .NET
58+
uses: actions/setup-dotnet@v3
59+
with:
60+
global-json-file: dotnet/global.json
61+
- name: Restore dependencies
62+
run: |
63+
dotnet restore -bl
64+
- name: Build
65+
run: |
66+
echo "Build AutoGen"
67+
dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true
68+
- name: OpenAI Test
69+
run: dotnet test --no-build -bl --configuration Release
70+
env:
71+
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
72+
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
73+
AZURE_GPT_35_MODEL_ID: ${{ secrets.AZURE_GPT_35_MODEL_ID }}
74+
OEPNAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
75+
- name: Pack
76+
run: |
77+
echo "Create nightly build package"
78+
dotnet pack --no-build --configuration Release --output './output/nightly' -p:VersionSuffix=nightly-${{github.run_id}} -bl
79+
80+
echo "Create release build package"
81+
dotnet pack --no-build --configuration Release --output './output/release' -bl
82+
83+
echo "ls output directory"
84+
ls -R ./output
85+
- name: Upload package
86+
uses: actions/upload-artifact@v2
87+
with:
88+
name: nightly
89+
path: ./dotnet/output/nightly
90+
- name: Upload package
91+
uses: actions/upload-artifact@v2
92+
with:
93+
name: release
94+
path: ./dotnet/output/release
95+
publish:
96+
environment: dotnet-internal-feed
97+
name: Publish to nightly feeds
98+
runs-on: ubuntu-latest
99+
defaults:
100+
run:
101+
working-directory: dotnet
102+
needs: openai-test
103+
steps:
104+
- name: Setup .NET
105+
uses: actions/setup-dotnet@v3
106+
with:
107+
dotnet-version: '6.0.x'
108+
source-url: https://devdiv.pkgs.visualstudio.com/DevDiv/_packaging/AutoGen/nuget/v3/index.json
109+
env:
110+
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_TOKEN }}
111+
- uses: actions/download-artifact@v2
112+
with:
113+
name: nightly
114+
path: ./dotnet/output/nightly
115+
- uses: actions/download-artifact@v2
116+
with:
117+
name: release
118+
path: ./dotnet/output/release
119+
- name: Publish nightly package to Azure Devops
120+
run: |
121+
echo "Publish nightly package to Azure Devops"
122+
echo "ls output directory"
123+
ls -R ./output/nightly
124+
dotnet nuget push --api-key AzureArtifacts ./output/nightly/*.nupkg --skip-duplicate
125+
env:
126+
AZURE_ARTIFACTS_FEED_URL: https://devdiv.pkgs.visualstudio.com/DevDiv/_packaging/AutoGen/nuget/v3/index.json
127+
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_TOKEN }}
128+
- name: Publish nightly package to github package
129+
run: |
130+
echo "Publish nightly package to github package"
131+
echo "ls output directory"
132+
ls -R ./output/nightly
133+
dotnet nuget push --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/microsoft/index.json" ./output/nightly/*.nupkg --skip-duplicate
134+
- name: Publish nightly package to agentchat myget feed
135+
run: |
136+
echo "Publish nightly package to agentchat myget feed"
137+
echo "ls output directory"
138+
ls -R ./output/nightly
139+
dotnet nuget push --api-key ${{ secrets.MYGET_TOKEN }} --source "https://www.myget.org/F/agentchat/api/v3/index.json" ./output/nightly/*.nupkg --skip-duplicate
140+
env:
141+
MYGET_TOKEN: ${{ secrets.MYGET_TOKEN }}
142+

.github/workflows/dotnet-run-openai-test-and-notebooks.yml

-58
This file was deleted.

OAI_CONFIG_LIST_sample

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"api_key": "<your Azure OpenAI API key here>",
1313
"base_url": "<your Azure OpenAI API base here>",
1414
"api_type": "azure",
15-
"api_version": "2023-07-01-preview"
15+
"api_version": "2024-02-15-preview"
1616
},
1717
{
1818
"model": "<your Azure OpenAI deployment name>",
1919
"api_key": "<your Azure OpenAI API key here>",
2020
"base_url": "<your Azure OpenAI API base here>",
2121
"api_type": "azure",
22-
"api_version": "2023-07-01-preview"
22+
"api_version": "2024-02-15-preview"
2323
}
2424
]

TRANSPARENCY_FAQS.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ While AutoGen automates LLM workflows, decisions about how to use specific LLM o
3030
## How was AutoGen evaluated? What metrics are used to measure performance?
3131
- Current version of AutoGen was evaluated on six applications to illustrate its potential in simplifying the development of high-performance multi-agent applications. These applications are selected based on their real-world relevance, problem difficulty and problem solving capabilities enabled by AutoGen, and innovative potential.
3232
- These applications involve using AutoGen to solve math problems, question answering, decision making in text world environments, supply chain optimization, etc. For each of these domains AutoGen was evaluated on various success based metrics (i.e., how often the AutoGen based implementation solved the task). And, in some cases, AutoGen based approach was also evaluated on implementation efficiency (e.g., to track reductions in developer effort to build). More details can be found at: https://aka.ms/AutoGen/TechReport
33+
- The team has conducted tests where a “red” agent attempts to get the default AutoGen assistant to break from its alignment and guardrails. The team has observed that out of 70 attempts to break guardrails, only 1 was successful in producing text that would have been flagged as problematic by Azure OpenAI filters. The team has not observed any evidence that AutoGen (or GPT models as hosted by OpenAI or Azure) can produce novel code exploits or jailbreak prompts, since direct prompts to “be a hacker”, “write exploits”, or “produce a phishing email” are refused by existing filters.
3334

3435
## What are the limitations of AutoGen? How can users minimize the impact of AutoGen’s limitations when using the system?
3536
AutoGen relies on existing LLMs. Experimenting with AutoGen would retain common limitations of large language models; including:

autogen/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .version import __version__
33
from .oai import *
44
from .agentchat import *
5+
from .exception_utils import *
56
from .code_utils import DEFAULT_MODEL, FAST_MODEL
67

78

autogen/agentchat/assistant_agent.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Callable, Dict, Literal, Optional, Union
22

33
from .conversable_agent import ConversableAgent
4+
from autogen.runtime_logging import logging_enabled, log_new_agent
45

56

67
class AssistantAgent(ConversableAgent):
@@ -45,7 +46,7 @@ def __init__(
4546
name (str): agent name.
4647
system_message (str): system message for the ChatCompletion inference.
4748
Please override this attribute if you want to reprogram the agent.
48-
llm_config (dict): llm inference configuration.
49+
llm_config (dict or False or None): llm inference configuration.
4950
Please refer to [OpenAIWrapper.create](/docs/reference/oai/client#create)
5051
for available options.
5152
is_termination_msg (function): a function that takes a message in the form of a dictionary
@@ -67,6 +68,8 @@ def __init__(
6768
description=description,
6869
**kwargs,
6970
)
71+
if logging_enabled():
72+
log_new_agent(self, locals())
7073

7174
# Update the provided description if None, and we are using the default system_message,
7275
# then use the default description.

autogen/agentchat/chat.py

+30-24
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,37 @@ def initiate_chats(chat_queue: List[Dict[str, Any]]) -> List[ChatResult]:
3434
3535
args:
3636
chat_queue (List[Dict]): a list of dictionaries containing the information of the chats.
37-
Each dictionary should contain the following fields:
37+
Each dictionary should contain the input arguments for `ConversableAgent.initiate_chat`.
38+
More specifically, each dictionary could include the following fields:
39+
recipient: the recipient agent.
40+
- "sender": the sender agent.
3841
- "recipient": the recipient agent.
39-
- "context": any context information, e.g., the request message. The following fields are reserved:
40-
"message" needs to be provided if the `generate_init_message` method is not overridden.
41-
Otherwise, input() will be called to get the initial message.
42-
"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".
43-
- Supported string are "last_msg" and "reflection_with_llm":
44-
when set "last_msg", it returns the last message of the dialog as the summary.
45-
when set "reflection_with_llm", it returns a summary extracted using an llm client.
46-
`llm_config` must be set in either the recipient or sender.
47-
"reflection_with_llm" requires the llm_config to be set in either the sender or the recipient.
48-
- A callable summary_method should take the recipient and sender agent in a chat as input and return a string of summary. E.g,
49-
```python
50-
def my_summary_method(
51-
sender: ConversableAgent,
52-
recipient: ConversableAgent,
53-
):
54-
return recipient.last_message(sender)["content"]
55-
```
56-
"summary_prompt" can be used to specify the prompt used to extract a summary when summary_method is "reflection_with_llm".
57-
Default is None and the following default prompt will be used when "summary_method" is set to "reflection_with_llm":
58-
"Identify and extract the final solution to the originally asked question based on the conversation."
59-
"carryover" can be used to specify the carryover information to be passed to this chat.
60-
If provided, we will combine this carryover with the "message" content when generating the initial chat
61-
message in `generate_init_message`.
42+
- clear_history (bool): whether to clear the chat history with the agent. Default is True.
43+
- silent (bool or None): (Experimental) whether to print the messages for this conversation. Default is False.
44+
- cache (Cache or None): the cache client to be used for this conversation. Default is None.
45+
- 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.
46+
- "message" needs to be provided if the `generate_init_message` method is not overridden.
47+
Otherwise, input() will be called to get the initial message.
48+
- "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".
49+
- Supported string are "last_msg" and "reflection_with_llm":
50+
when set "last_msg", it returns the last message of the dialog as the summary.
51+
when set "reflection_with_llm", it returns a summary extracted using an llm client.
52+
`llm_config` must be set in either the recipient or sender.
53+
"reflection_with_llm" requires the llm_config to be set in either the sender or the recipient.
54+
- A callable summary_method should take the recipient and sender agent in a chat as input and return a string of summary. E.g,
55+
```python
56+
def my_summary_method(
57+
sender: ConversableAgent,
58+
recipient: ConversableAgent,
59+
):
60+
return recipient.last_message(sender)["content"]
61+
```
62+
"summary_prompt" can be used to specify the prompt used to extract a summary when summary_method is "reflection_with_llm".
63+
Default is None and the following default prompt will be used when "summary_method" is set to "reflection_with_llm":
64+
"Identify and extract the final solution to the originally asked question based on the conversation."
65+
"carryover" can be used to specify the carryover information to be passed to this chat.
66+
If provided, we will combine this carryover with the "message" content when generating the initial chat
67+
message in `generate_init_message`.
6268
6369
6470
returns:

autogen/agentchat/contrib/capabilities/context_handling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_to_agent(self, agent: ConversableAgent):
4545
"""
4646
Adds TransformChatHistory capability to the given agent.
4747
"""
48-
agent.register_hook(hookable_method=agent.process_all_messages, hook=self._transform_messages)
48+
agent.register_hook(hookable_method="process_all_messages", hook=self._transform_messages)
4949

5050
def _transform_messages(self, messages: List[Dict]) -> List[Dict]:
5151
"""

autogen/agentchat/contrib/capabilities/teachability.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def add_to_agent(self, agent: ConversableAgent):
6161
self.teachable_agent = agent
6262

6363
# Register a hook for processing the last message.
64-
agent.register_hook(hookable_method=agent.process_last_message, hook=self.process_last_message)
64+
agent.register_hook(hookable_method="process_last_message", hook=self.process_last_message)
6565

6666
# Was an llm_config passed to the constructor?
6767
if self.llm_config is None:

autogen/agentchat/contrib/gpt_assistant_agent.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,16 @@ def __init__(
5353
- Other kwargs: Except verbose, others are passed directly to ConversableAgent.
5454
"""
5555
# Use AutoGen OpenAIWrapper to create a client
56-
oai_wrapper = OpenAIWrapper(**llm_config)
56+
openai_client_cfg = None
57+
model_name = "gpt-4-1106-preview"
58+
if llm_config and llm_config.get("config_list") is not None and len(llm_config["config_list"]) > 0:
59+
openai_client_cfg = llm_config["config_list"][0].copy()
60+
model_name = openai_client_cfg.pop("model", "gpt-4-1106-preview")
61+
62+
oai_wrapper = OpenAIWrapper(**openai_client_cfg)
5763
if len(oai_wrapper._clients) > 1:
5864
logger.warning("GPT Assistant only supports one OpenAI client. Using the first client in the list.")
65+
5966
self._openai_client = oai_wrapper._clients[0]._oai_client
6067
openai_assistant_id = llm_config.get("assistant_id", None)
6168
if openai_assistant_id is None:
@@ -79,7 +86,7 @@ def __init__(
7986
name=name,
8087
instructions=instructions,
8188
tools=llm_config.get("tools", []),
82-
model=llm_config.get("model", "gpt-4-1106-preview"),
89+
model=model_name,
8390
file_ids=llm_config.get("file_ids", []),
8491
)
8592
else:

0 commit comments

Comments
 (0)