Skip to content

Commit

Permalink
Validate llm_config passed to ConversableAgent
Browse files Browse the repository at this point in the history
Based on microsoft#1522, this commit implements the additional validation checks in
`ConversableAgent.`

Add the following validation and `raise ValueError` if:

 - The `llm_config` is `None` (validated in `ConversableAgent`).
 - The `llm_config` has no `model` specified and `config_list` is empty
   (validated in `OpenAIWrapper`).
 - The `config_list` has at least one entry, but not all the entries have
   the `model` is specified (validated in `OpenAIWrapper`).

The rest of the changes are code churn to adjust or add the test cases.
  • Loading branch information
gunnarku committed Feb 13, 2024
1 parent 1734486 commit daa77dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 3 additions & 1 deletion test/agentchat/contrib/test_web_surfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def test_web_surfer() -> None:
mp.setenv("OPENAI_API_KEY", "mock")
page_size = 4096
web_surfer = WebSurferAgent(
"web_surfer", llm_config={"config_list": []}, browser_config={"viewport_size": page_size}
"web_surfer",
llm_config={"config_list": [{"model": "gpt-4", "api_key": ""}]},
browser_config={"viewport_size": page_size},
)

# Sneak a peak at the function map, allowing us to call the functions for testing here
Expand Down
4 changes: 0 additions & 4 deletions test/agentchat/test_conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,6 @@ def test_register_for_llm_without_LLM():
assert e.args[0] == "Please specify the value for 'llm_config'."


def test_register_for_llm_without_configuration_but_with_model_name():
ConversableAgent(name="agent", llm_config={"model": "gpt-4", "config_list": []})


def test_register_for_llm_without_configuration():
try:
ConversableAgent(name="agent", llm_config={"config_list": []})
Expand Down

0 comments on commit daa77dc

Please sign in to comment.