Skip to content

Commit a533baa

Browse files
committed
Merge main
2 parents 588ec69 + 0dd0fc5 commit a533baa

File tree

81 files changed

+1804
-441
lines changed

Some content is hidden

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

81 files changed

+1804
-441
lines changed

.github/workflows/build.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
python -m pip install --upgrade pip wheel
4141
pip install -e .
4242
python -c "import autogen"
43-
pip install -e.[mathchat,retrievechat,test] datasets pytest
43+
pip install -e. pytest
4444
pip uninstall -y openai
4545
- name: Install unstructured if not windows
4646
if: matrix.os != 'windows-2019'
@@ -53,7 +53,8 @@ jobs:
5353
- name: Coverage
5454
if: matrix.python-version == '3.10'
5555
run: |
56-
pip install coverage
56+
pip install -e .[mathchat,test]
57+
pip uninstall -y openai
5758
coverage run -a -m pytest test
5859
coverage xml
5960
- name: Upload coverage to Codecov

.github/workflows/contrib-openai.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflow will install Python dependencies and run tests
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: OpenAI4ContribTests
5+
6+
on:
7+
pull_request_target:
8+
branches: ['main']
9+
paths:
10+
- 'autogen/**'
11+
- 'test/agentchat/contrib/**'
12+
- '.github/workflows/contrib-openai.yml'
13+
- 'setup.py'
14+
15+
jobs:
16+
RetrieveChatTest:
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest]
20+
python-version: ["3.10"]
21+
runs-on: ${{ matrix.os }}
22+
environment: openai1
23+
steps:
24+
# checkout to pr branch
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
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
34+
run: |
35+
docker --version
36+
python -m pip install --upgrade pip wheel
37+
pip install -e .
38+
python -c "import autogen"
39+
pip install coverage pytest-asyncio
40+
- name: Install packages for test when needed
41+
run: |
42+
pip install docker
43+
pip install qdrant_client[fastembed]
44+
pip install -e .[retrievechat]
45+
- name: Coverage
46+
env:
47+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
48+
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
49+
AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }}
50+
OAI_CONFIG_LIST: ${{ secrets.OAI_CONFIG_LIST }}
51+
run: |
52+
coverage run -a -m pytest test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py
53+
coverage xml
54+
- name: Upload coverage to Codecov
55+
uses: codecov/codecov-action@v3
56+
with:
57+
file: ./coverage.xml
58+
flags: unittests

.github/workflows/contrib-tests.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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: ContribTests
5+
6+
on:
7+
pull_request:
8+
branches: ['main', 'dev/v0.2']
9+
paths:
10+
- 'autogen/**'
11+
- 'test/agentchat/contrib/**'
12+
- '.github/workflows/contrib-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+
19+
jobs:
20+
RetrieveChatTest:
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ubuntu-latest, macos-latest, windows-2019]
26+
python-version: ["3.8", "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 pytest
37+
- name: Install qdrant_client when python-version is 3.10
38+
if: matrix.python-version == '3.10' || matrix.python-version == '3.8'
39+
run: |
40+
pip install qdrant_client[fastembed]
41+
- name: Install packages and dependencies for RetrieveChat
42+
run: |
43+
pip install -e .[retrievechat]
44+
pip uninstall -y openai
45+
- name: Test RetrieveChat
46+
run: |
47+
pytest test/test_retrieve_utils.py test/agentchat/contrib/test_retrievechat.py test/agentchat/contrib/test_qdrant_retrievechat.py
48+
- name: Coverage
49+
if: matrix.python-version == '3.10'
50+
run: |
51+
pip install coverage>=5.3
52+
coverage run -a -m pytest test/test_retrieve_utils.py test/agentchat/contrib
53+
coverage xml
54+
- name: Upload coverage to Codecov
55+
if: matrix.python-version == '3.10'
56+
uses: codecov/codecov-action@v3
57+
with:
58+
file: ./coverage.xml
59+
flags: unittests

.github/workflows/openai.yml

+8-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
1+
# This workflow will install Python dependencies and run tests with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

44
name: OpenAI
@@ -11,9 +11,6 @@ on:
1111
- 'test/**'
1212
- 'notebook/agentchat_auto_feedback_from_code_execution.ipynb'
1313
- 'notebook/agentchat_function_call.ipynb'
14-
- 'notebook/agentchat_MathChat.ipynb'
15-
- 'notebook/oai_completion.ipynb'
16-
- 'notebook/oai_chatgpt_gpt4.ipynb'
1714
- '.github/workflows/openai.yml'
1815

1916
jobs:
@@ -23,7 +20,7 @@ jobs:
2320
os: [ubuntu-latest]
2421
python-version: ["3.9", "3.10", "3.11"]
2522
runs-on: ${{ matrix.os }}
26-
environment: openai
23+
environment: openai1
2724
steps:
2825
# checkout to pr branch
2926
- name: Checkout
@@ -38,28 +35,17 @@ jobs:
3835
run: |
3936
docker --version
4037
python -m pip install --upgrade pip wheel
41-
pip install -e.[blendsearch]
38+
pip install -e.
4239
python -c "import autogen"
43-
pip install coverage pytest-asyncio datasets
40+
pip install coverage pytest-asyncio
4441
- name: Install packages for test when needed
4542
if: matrix.python-version == '3.9'
4643
run: |
4744
pip install docker
48-
- name: Install packages for MathChat when needed
49-
if: matrix.python-version != '3.11'
45+
- name: Install dependencies for test when needed
46+
if: matrix.python-version == '3.10' # test_agentchat_function_call
5047
run: |
51-
pip install -e .[mathchat]
52-
- name: Install packages for RetrieveChat when needed
53-
if: matrix.python-version == '3.9'
54-
run: |
55-
pip install -e .[retrievechat]
56-
- name: Install packages for Teachable when needed
57-
run: |
58-
pip install -e .[teachable]
59-
- name: Install packages for RetrieveChat with QDrant when needed
60-
if: matrix.python-version == '3.11'
61-
run: |
62-
pip install -e .[retrievechat] qdrant_client[fastembed]
48+
pip install -e.[mathchat]
6349
- name: Coverage
6450
if: matrix.python-version == '3.9'
6551
env:
@@ -80,8 +66,7 @@ jobs:
8066
OAI_CONFIG_LIST: ${{ secrets.OAI_CONFIG_LIST }}
8167
run: |
8268
pip install nbconvert nbformat ipykernel
83-
coverage run -a -m pytest test/agentchat/test_qdrant_retrievechat.py
84-
coverage run -a -m pytest test/test_with_openai.py
69+
coverage run -a -m pytest test/agentchat/test_function_call_groupchat.py
8570
coverage run -a -m pytest test/test_notebook.py
8671
coverage xml
8772
cat "$(pwd)/test/executed_openai_notebook_output.txt"

OAI_CONFIG_LIST_sample

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
{
88
"model": "gpt-4",
99
"api_key": "<your Azure OpenAI API key here>",
10-
"api_base": "<your Azure OpenAI API base here>",
10+
"base_url": "<your Azure OpenAI API base here>",
1111
"api_type": "azure",
1212
"api_version": "2023-07-01-preview"
1313
},
1414
{
1515
"model": "gpt-3.5-turbo",
1616
"api_key": "<your Azure OpenAI API key here>",
17-
"api_base": "<your Azure OpenAI API base here>",
17+
"base_url": "<your Azure OpenAI API base here>",
1818
"api_type": "azure",
1919
"api_version": "2023-07-01-preview"
2020
}

README.md

+13-11
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ AutoGen is a framework that enables the development of LLM applications using mu
2828

2929
![AutoGen Overview](https://github.com/microsoft/autogen/blob/main/website/static/img/autogen_agentchat.png)
3030

31-
- AutoGen enables building next-gen LLM applications based on **multi-agent conversations** with minimal effort. It simplifies the orchestration, automation, and optimization of a complex LLM workflow. It maximizes the performance of LLM models and overcomes their weaknesses.
32-
- It supports **diverse conversation patterns** for complex workflows. With customizable and conversable agents, developers can use AutoGen to build a wide range of conversation patterns concerning conversation autonomy,
31+
- AutoGen enables building next-gen LLM applications based on [multi-agent conversations](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat) with minimal effort. It simplifies the orchestration, automation, and optimization of a complex LLM workflow. It maximizes the performance of LLM models and overcomes their weaknesses.
32+
- It supports [diverse conversation patterns](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat#supporting-diverse-conversation-patterns) for complex workflows. With customizable and conversable agents, developers can use AutoGen to build a wide range of conversation patterns concerning conversation autonomy,
3333
the number of agents, and agent conversation topology.
34-
- It provides a collection of working systems with different complexities. These systems span a **wide range of applications** from various domains and complexities. This demonstrates how AutoGen can easily support diverse conversation patterns.
35-
- AutoGen provides **enhanced LLM inference**. It offers easy performance tuning, plus utilities like API unification and caching, and advanced usage patterns, such as error handling, multi-config inference, context programming, etc.
34+
- It provides a collection of working systems with different complexities. These systems span a [wide range of applications](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat#diverse-applications-implemented-with-autogen) from various domains and complexities. This demonstrates how AutoGen can easily support diverse conversation patterns.
35+
- AutoGen provides [enhanced LLM inference](https://microsoft.github.io/autogen/docs/Use-Cases/enhanced_inference#api-unification). It offers utilities like API unification and caching, and advanced usage patterns, such as error handling, multi-config inference, context programming, etc.
3636

3737
AutoGen is powered by collaborative [research studies](https://microsoft.github.io/autogen/docs/Research) from Microsoft, Penn State University, and the University of Washington.
3838

@@ -42,14 +42,14 @@ The easiest way to start playing is
4242

4343
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/autogen?quickstart=1)
4444

45-
2. Copy OAI_CONFIG_LIST_sample to /notebook folder, name to OAI_CONFIG_LIST, and set the correct configuration.
45+
2. Copy OAI_CONFIG_LIST_sample to ./notebook folder, name to OAI_CONFIG_LIST, and set the correct configuration.
4646
3. Start playing with the notebooks!
4747

4848

4949

5050
## Installation
5151

52-
AutoGen requires **Python version >= 3.8**. It can be installed from pip:
52+
AutoGen requires **Python version >= 3.8, < 3.12**. It can be installed from pip:
5353

5454
```bash
5555
pip install pyautogen
@@ -72,7 +72,7 @@ For LLM inference configurations, check the [FAQs](https://microsoft.github.io/a
7272

7373
## Multi-Agent Conversation Framework
7474

75-
Autogen enables the next-gen LLM applications with a generic multi-agent conversation framework. It offers customizable and conversable agents that integrate LLMs, tools, and humans.
75+
Autogen enables the next-gen LLM applications with a generic [multi-agent conversation](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat) framework. It offers customizable and conversable agents that integrate LLMs, tools, and humans.
7676
By automating chat among multiple capable agents, one can easily make them collectively perform tasks autonomously or with human feedback, including tasks that require using tools via code.
7777

7878
Features of this use case include:
@@ -106,14 +106,16 @@ After the repo is cloned.
106106
The figure below shows an example conversation flow with AutoGen.
107107
![Agent Chat Example](https://github.com/microsoft/autogen/blob/main/website/static/img/chat_example.png)
108108

109-
Please find more [code examples](https://microsoft.github.io/autogen/docs/Examples/AutoGen-AgentChat) for this feature.
109+
Please find more [code examples](https://microsoft.github.io/autogen/docs/Examples/AgentChat) for this feature.
110110

111111
## Enhanced LLM Inferences
112112

113-
Autogen also helps maximize the utility out of the expensive LLMs such as ChatGPT and GPT-4. It offers enhanced LLM inference with powerful functionalities like tuning, caching, error handling, and templating. For example, you can optimize generations by LLM with your own tuning data, success metrics, and budgets.
113+
Autogen also helps maximize the utility out of the expensive LLMs such as ChatGPT and GPT-4. It offers [enhanced LLM inference](https://microsoft.github.io/autogen/docs/Use-Cases/enhanced_inference#api-unification) with powerful functionalities like caching, error handling, multi-config inference and templating.
114+
115+
<!-- For example, you can optimize generations by LLM with your own tuning data, success metrics, and budgets.
114116
115117
```python
116-
# perform tuning
118+
# perform tuning for openai<1
117119
config, analysis = autogen.Completion.tune(
118120
data=tune_data,
119121
metric="success",
@@ -127,7 +129,7 @@ config, analysis = autogen.Completion.tune(
127129
response = autogen.Completion.create(context=test_instance, **config)
128130
```
129131
130-
Please find more [code examples](https://microsoft.github.io/autogen/docs/Examples/AutoGen-Inference) for this feature.
132+
Please find more [code examples](https://microsoft.github.io/autogen/docs/Examples/Inference) for this feature. -->
131133

132134
## Documentation
133135

autogen/agentchat/assistant_agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
system_message (str): system message for the ChatCompletion inference.
4444
Please override this attribute if you want to reprogram the agent.
4545
llm_config (dict): llm inference configuration.
46-
Please refer to [Completion.create](/docs/reference/oai/completion#create)
46+
Please refer to [OpenAIWrapper.create](/docs/reference/oai/client#create)
4747
for available options.
4848
is_termination_msg (function): a function that takes a message in the form of a dictionary
4949
and returns a boolean value indicating if this received message is a termination message.

autogen/agentchat/contrib/teachable_agent.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def colored(x, *args, **kwargs):
1818

1919

2020
class TeachableAgent(ConversableAgent):
21-
"""Teachable Agent, a subclass of ConversableAgent using a vector database to remember user teachings.
21+
"""(Experimental) Teachable Agent, a subclass of ConversableAgent using a vector database to remember user teachings.
2222
In this class, the term 'user' refers to any caller (human or not) sending messages to this agent.
2323
Not yet tested in the group-chat setting."""
2424

@@ -40,7 +40,7 @@ def __init__(
4040
system_message (str): system message for the ChatCompletion inference.
4141
human_input_mode (str): This agent should NEVER prompt the human for input.
4242
llm_config (dict or False): llm inference configuration.
43-
Please refer to [Completion.create](/docs/reference/oai/completion#create)
43+
Please refer to [OpenAIWrapper.create](/docs/reference/oai/client#create)
4444
for available options.
4545
To disable llm-based auto reply, set to False.
4646
analyzer_llm_config (dict or False): llm inference configuration passed to TextAnalyzerAgent.
@@ -125,11 +125,8 @@ def _generate_teachable_assistant_reply(
125125
messages = messages.copy()
126126
messages[-1]["content"] = new_user_text
127127

128-
# Generate a response.
129-
msgs = self._oai_system_message + messages
130-
response = oai.ChatCompletion.create(messages=msgs, **self.llm_config)
131-
response_text = oai.ChatCompletion.extract_text_or_function_call(response)[0]
132-
return True, response_text
128+
# Generate a response by reusing existing generate_oai_reply
129+
return self.generate_oai_reply(messages, sender, config)
133130

134131
def learn_from_user_feedback(self):
135132
"""Reviews the user comments from the last chat, and decides what teachings to store as memos."""
@@ -265,12 +262,14 @@ def analyze(self, text_to_analyze, analysis_instructions):
265262
self.send(recipient=self.analyzer, message=analysis_instructions, request_reply=True) # Request the reply.
266263
return self.last_message(self.analyzer)["content"]
267264
else:
265+
# TODO: This is not an encouraged usage pattern. It breaks the conversation-centric design.
266+
# consider using the arg "silent"
268267
# Use the analyzer's method directly, to leave analyzer message out of the printed chat.
269268
return self.analyzer.analyze_text(text_to_analyze, analysis_instructions)
270269

271270

272271
class MemoStore:
273-
"""
272+
"""(Experimental)
274273
Provides memory storage and retrieval for a TeachableAgent, using a vector database.
275274
Each DB entry (called a memo) is a pair of strings: an input text and an output text.
276275
The input text might be a question, or a task to perform.

autogen/agentchat/contrib/text_analyzer_agent.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class TextAnalyzerAgent(ConversableAgent):
13-
"""Text Analysis agent, a subclass of ConversableAgent designed to analyze text as instructed."""
13+
"""(Experimental) Text Analysis agent, a subclass of ConversableAgent designed to analyze text as instructed."""
1414

1515
def __init__(
1616
self,
@@ -26,7 +26,7 @@ def __init__(
2626
system_message (str): system message for the ChatCompletion inference.
2727
human_input_mode (str): This agent should NEVER prompt the human for input.
2828
llm_config (dict or False): llm inference configuration.
29-
Please refer to [Completion.create](/docs/reference/oai/completion#create)
29+
Please refer to [OpenAIWrapper.create](/docs/reference/oai/client#create)
3030
for available options.
3131
To disable llm-based auto reply, set to False.
3232
teach_config (dict or None): Additional parameters used by TeachableAgent.
@@ -74,9 +74,5 @@ def analyze_text(self, text_to_analyze, analysis_instructions):
7474
msg_text = "\n".join(
7575
[analysis_instructions, text_to_analyze, analysis_instructions]
7676
) # Repeat the instructions.
77-
messages = self._oai_system_message + [{"role": "user", "content": msg_text}]
78-
7977
# Generate and return the analysis string.
80-
response = oai.ChatCompletion.create(context=None, messages=messages, **self.llm_config)
81-
output_text = oai.ChatCompletion.extract_text_or_function_call(response)[0]
82-
return output_text
78+
return self.generate_oai_reply([{"role": "user", "content": msg_text}], None, None)[1]

0 commit comments

Comments
 (0)