Skip to content

Commit 3f7c648

Browse files
Merge branch 'dotnet' into u/xiaoyun/dotnet/middleware
2 parents df54732 + 4dfe314 commit 3f7c648

File tree

96 files changed

+4487
-1410
lines changed

Some content is hidden

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

96 files changed

+4487
-1410
lines changed

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

-60
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)