Skip to content

Commit

Permalink
Merge branch 'microsoft:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Steellgold committed Oct 10, 2023
2 parents 0b11c0f + 37a07a8 commit aaed8ec
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
11 changes: 11 additions & 0 deletions autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from typing import Dict, List, Optional, Union
from .agent import Agent
from .conversable_agent import ConversableAgent
import logging

logger = logging.getLogger(__name__)


@dataclass
Expand Down Expand Up @@ -42,6 +45,14 @@ def select_speaker_msg(self):
def select_speaker(self, last_speaker: Agent, selector: ConversableAgent):
"""Select the next speaker."""
selector.update_system_message(self.select_speaker_msg())

# Warn if GroupChat is underpopulated, without established changing behavior
n_agents = len(self.agent_names)
if n_agents < 3:
logger.warning(
f"GroupChat is underpopulated with {n_agents} agents. Direct communication would be more efficient."
)

final, name = selector.generate_oai_reply(
self.messages
+ [
Expand Down
11 changes: 10 additions & 1 deletion autogen/code_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def execute_code(
timeout: Optional[int] = None,
filename: Optional[str] = None,
work_dir: Optional[str] = None,
use_docker: Optional[Union[List[str], str, bool]] = docker is not None,
use_docker: Optional[Union[List[str], str, bool]] = True,
lang: Optional[str] = "python",
) -> Tuple[int, str, str]:
"""Execute code in a docker container.
Expand Down Expand Up @@ -257,6 +257,15 @@ def execute_code(
logger.error(error_msg)
raise AssertionError(error_msg)

# Warn if docker was requested but cannot be provided. In this case
# the current behavior is to fall back to run natively, but this behavior
# is subject to change.
if use_docker and docker is None:
use_docker = False
logger.warning(
"execute_code was called with use_docker evaluating to True, but the python docker package is not available. Falling back to native code execution. Note: this fallback behavior is subject to change"
)

timeout = timeout or DEFAULT_TIMEOUT
original_filename = filename
if WIN32 and lang in ["sh", "shell"] and (not use_docker):
Expand Down
7 changes: 7 additions & 0 deletions autogen/oai/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,13 @@ def yes_or_no_filter(context, config, response):
"""
if ERROR:
raise ERROR

# Warn if a config list was provided but was empty
if type(config_list) is list and len(config_list) == 0:
logger.warning(
"Completion was provided with a config_list, but the list was empty. Adopting default OpenAI behavior, which reads from the 'model' parameter instead."
)

if config_list:
last = len(config_list) - 1
cost = 0
Expand Down
4 changes: 3 additions & 1 deletion autogen/oai/openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ def config_list_from_json(
if json_str:
config_list = json.loads(json_str)
else:
config_list_path = os.path.join(file_location, env_or_file)
try:
with open(os.path.join(file_location, env_or_file)) as json_file:
with open(config_list_path) as json_file:
config_list = json.load(json_file)
except FileNotFoundError:
logging.warning(f"The specified config_list file '{config_list_path}' does not exist.")
return []
return filter_config(config_list, filter_dict)

Expand Down
2 changes: 1 addition & 1 deletion autogen/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.8"
__version__ = "0.1.10"

0 comments on commit aaed8ec

Please sign in to comment.