Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Throw an error when the OAI_CONFIG_LIST is missing. #1082

Merged
merged 8 commits into from
Jan 3, 2024
10 changes: 3 additions & 7 deletions autogen/oai/openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,9 @@ def config_list_from_json(
config_list = json.loads(json_str)
else:
config_list_path = os.path.join(file_location, env_or_file)
try:
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)
with open(config_list_path) as json_file:
sonichi marked this conversation as resolved.
Show resolved Hide resolved
config_list = json.load(json_file)
return filter_config(config_list, filter_dict)
sonichi marked this conversation as resolved.
Show resolved Hide resolved


def get_config(
Expand Down
7 changes: 7 additions & 0 deletions test/oai/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def test_config_list_from_json():
del os.environ["config_list_test"]
os.remove(json_file)

# Test that an error is thrown when the config list is missing
try:
autogen.config_list_from_json("OAI_CONFIG_LIST.missing", file_location=KEY_LOC)
assert False # We should not be able to get here, since the file should be missing
except FileNotFoundError:
pass
sonichi marked this conversation as resolved.
Show resolved Hide resolved


def test_config_list_openai_aoai():
# Testing the functionality for loading configurations for different API types
Expand Down
Loading