Skip to content

Commit

Permalink
Filter models with tags instead of model name (#2912)
Browse files Browse the repository at this point in the history
* identify model with tags instead of model name

* models

* model to tag

* add more model name

* format

* Update test/agentchat/test_function_call.py

Co-authored-by: Chi Wang <[email protected]>

* Update test/agentchat/test_function_call.py

Co-authored-by: Chi Wang <[email protected]>

* Update test/agentchat/test_tool_calls.py

Co-authored-by: Chi Wang <[email protected]>

* Update test/agentchat/test_tool_calls.py

Co-authored-by: Chi Wang <[email protected]>

* remove uncessary tags

* use gpt-4 as tag

* model to tag

* add tag for teachable agent test

---------

Co-authored-by: Chi Wang <[email protected]>
Co-authored-by: AutoGen-Hub <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2024
1 parent c54e8a5 commit 6d4cf40
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 34 deletions.
4 changes: 1 addition & 3 deletions test/agentchat/contrib/capabilities/test_context_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ def test_transform_chat_history_with_agents():
config_list = autogen.config_list_from_json(
OAI_CONFIG_LIST,
KEY_LOC,
filter_dict={
"model": "gpt-3.5-turbo",
},
filter_dict={"tags": ["gpt-3.5-turbo"]},
)
assistant = AssistantAgent("assistant", llm_config={"config_list": config_list}, max_consecutive_auto_reply=1)
context_handling = TransformChatHistory(max_messages=10, max_tokens_per_message=5, max_tokens=1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# filter_dict={"model": ["gpt-3.5-turbo-1106"]}
# filter_dict={"model": ["gpt-3.5-turbo-0613"]}
# filter_dict={"model": ["gpt-4"]}
filter_dict = {"model": ["gpt-35-turbo-16k", "gpt-3.5-turbo-16k"]}
filter_dict = {"tags": ["gpt-35-turbo-16k", "gpt-3.5-turbo-16k"]}


def create_teachable_agent(reset_db=False, verbosity=0):
Expand Down
2 changes: 1 addition & 1 deletion test/agentchat/test_agent_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
config_list = autogen.config_list_from_json(
OAI_CONFIG_LIST,
filter_dict={
"model": ["gpt-3.5-turbo"],
"tags": ["gpt-3.5-turbo"],
},
file_location=KEY_LOC,
)
Expand Down
24 changes: 13 additions & 11 deletions test/agentchat/test_conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

here = os.path.abspath(os.path.dirname(__file__))

gpt4_config_list = [{"model": "gpt-4"}, {"model": "gpt-4-turbo"}, {"model": "gpt-4-32k"}, {"model": "gpt-4o"}]


@pytest.fixture
def conversable_agent():
Expand Down Expand Up @@ -502,7 +504,7 @@ async def test_a_generate_reply_with_messages_and_sender_none(conversable_agent)
def test_update_function_signature_and_register_functions() -> None:
with pytest.MonkeyPatch.context() as mp:
mp.setenv("OPENAI_API_KEY", MOCK_OPEN_AI_API_KEY)
agent = ConversableAgent(name="agent", llm_config={"config_list": [{"model": "gpt-4"}]})
agent = ConversableAgent(name="agent", llm_config={"config_list": gpt4_config_list})

def exec_python(cell: str) -> None:
pass
Expand Down Expand Up @@ -656,9 +658,9 @@ def get_origin(d: Dict[str, Callable[..., Any]]) -> Dict[str, Callable[..., Any]
def test_register_for_llm():
with pytest.MonkeyPatch.context() as mp:
mp.setenv("OPENAI_API_KEY", MOCK_OPEN_AI_API_KEY)
agent3 = ConversableAgent(name="agent3", llm_config={"config_list": [{"model": "gpt-4"}]})
agent2 = ConversableAgent(name="agent2", llm_config={"config_list": [{"model": "gpt-4"}]})
agent1 = ConversableAgent(name="agent1", llm_config={"config_list": [{"model": "gpt-4"}]})
agent3 = ConversableAgent(name="agent3", llm_config={"config_list": gpt4_config_list})
agent2 = ConversableAgent(name="agent2", llm_config={"config_list": gpt4_config_list})
agent1 = ConversableAgent(name="agent1", llm_config={"config_list": gpt4_config_list})

@agent3.register_for_llm()
@agent2.register_for_llm(name="python")
Expand Down Expand Up @@ -729,9 +731,9 @@ async def exec_sh(script: Annotated[str, "Valid shell script to execute."]) -> s
def test_register_for_llm_api_style_function():
with pytest.MonkeyPatch.context() as mp:
mp.setenv("OPENAI_API_KEY", MOCK_OPEN_AI_API_KEY)
agent3 = ConversableAgent(name="agent3", llm_config={"config_list": [{"model": "gpt-4"}]})
agent2 = ConversableAgent(name="agent2", llm_config={"config_list": [{"model": "gpt-4"}]})
agent1 = ConversableAgent(name="agent1", llm_config={"config_list": [{"model": "gpt-4"}]})
agent3 = ConversableAgent(name="agent3", llm_config={"config_list": gpt4_config_list})
agent2 = ConversableAgent(name="agent2", llm_config={"config_list": gpt4_config_list})
agent1 = ConversableAgent(name="agent1", llm_config={"config_list": gpt4_config_list})

@agent3.register_for_llm(api_style="function")
@agent2.register_for_llm(name="python", api_style="function")
Expand Down Expand Up @@ -800,7 +802,7 @@ async def exec_sh(script: Annotated[str, "Valid shell script to execute."]) -> s
def test_register_for_llm_without_description():
with pytest.MonkeyPatch.context() as mp:
mp.setenv("OPENAI_API_KEY", MOCK_OPEN_AI_API_KEY)
agent = ConversableAgent(name="agent", llm_config={"config_list": [{"model": "gpt-4"}]})
agent = ConversableAgent(name="agent", llm_config={"config_list": gpt4_config_list})

with pytest.raises(ValueError) as e:

Expand Down Expand Up @@ -877,7 +879,7 @@ async def exec_sh(script: Annotated[str, "Valid shell script to execute."]):
def test_register_functions():
with pytest.MonkeyPatch.context() as mp:
mp.setenv("OPENAI_API_KEY", MOCK_OPEN_AI_API_KEY)
agent = ConversableAgent(name="agent", llm_config={"config_list": [{"model": "gpt-4"}]})
agent = ConversableAgent(name="agent", llm_config={"config_list": gpt4_config_list})
user_proxy = UserProxyAgent(name="user_proxy")

def exec_python(cell: Annotated[str, "Valid Python cell to execute."]) -> str:
Expand Down Expand Up @@ -1001,7 +1003,7 @@ async def test_function_registration_e2e_async() -> None:
config_list = autogen.config_list_from_json(
OAI_CONFIG_LIST,
filter_dict={
"model": ["gpt-4", "gpt-4-0314", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"],
"tags": ["gpt-4", "gpt-4-0314", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"],
},
file_location=KEY_LOC,
)
Expand Down Expand Up @@ -1072,7 +1074,7 @@ def stopwatch(num_seconds: Annotated[str, "Number of seconds in the stopwatch."]

@pytest.mark.skipif(skip_openai, reason=reason)
def test_max_turn():
config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"model": ["gpt-3.5-turbo"]})
config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo"]})

# create an AssistantAgent instance named "assistant"
assistant = autogen.AssistantAgent(
Expand Down
10 changes: 7 additions & 3 deletions test/agentchat/test_function_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@

@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip")
def test_eval_math_responses():
config_list = autogen.config_list_from_models(
KEY_LOC, model_list=["gpt-4-0613", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k"]
config_list = autogen.config_list_from_json(
OAI_CONFIG_LIST,
filter_dict={
"tags": ["gpt-4", "gpt-3.5-turbo", "gpt-3.5-turbo-16k"],
},
file_location=KEY_LOC,
)
functions = [
{
Expand Down Expand Up @@ -209,7 +213,7 @@ def test_update_function():
config_list_gpt4 = autogen.config_list_from_json(
OAI_CONFIG_LIST,
filter_dict={
"model": ["gpt-4", "gpt-4-0314", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"],
"tags": ["gpt-4", "gpt-4-32k", "gpt-4o"],
},
file_location=KEY_LOC,
)
Expand Down
18 changes: 13 additions & 5 deletions test/agentchat/test_tool_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

@pytest.mark.skipif(skip_openai or not TOOL_ENABLED, reason="openai>=1.1.0 not installed or requested to skip")
def test_eval_math_responses():
config_list = autogen.config_list_from_models(
KEY_LOC, model_list=["gpt-4-0613", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k"]
config_list = autogen.config_list_from_json(
OAI_CONFIG_LIST,
KEY_LOC,
filter_dict={"tags": ["tool"]},
)
tools = [
{
Expand Down Expand Up @@ -78,9 +80,15 @@ def test_eval_math_responses():

@pytest.mark.skipif(skip_openai or not TOOL_ENABLED, reason="openai>=1.1.0 not installed or requested to skip")
def test_eval_math_responses_api_style_function():
config_list = autogen.config_list_from_models(
# config_list = autogen.config_list_from_models(
# KEY_LOC,
# model_list=["gpt-4-0613", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k"],
# )

config_list = autogen.config_list_from_json(
OAI_CONFIG_LIST,
KEY_LOC,
model_list=["gpt-4-0613", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k"],
filter_dict={"tags": ["tool"]},
)
functions = [
{
Expand Down Expand Up @@ -136,7 +144,7 @@ def test_update_tool():
config_list_gpt4 = autogen.config_list_from_json(
OAI_CONFIG_LIST,
filter_dict={
"model": ["gpt-4", "gpt-4-0314", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"],
"tags": ["gpt-4"],
},
file_location=KEY_LOC,
)
Expand Down
20 changes: 13 additions & 7 deletions test/oai/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_aoai_chat_completion():
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"api_type": ["azure"], "model": ["gpt-3.5-turbo", "gpt-35-turbo"]},
filter_dict={"api_type": ["azure"], "tags": ["gpt-3.5-turbo"]},
)
client = OpenAIWrapper(config_list=config_list)
response = client.create(messages=[{"role": "user", "content": "2+2="}], cache_seed=None)
Expand All @@ -58,7 +58,7 @@ def test_oai_tool_calling_extraction():
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"api_type": ["azure"], "model": ["gpt-3.5-turbo", "gpt-35-turbo"]},
filter_dict={"api_type": ["azure"], "tags": ["gpt-3.5-turbo"]},
)
client = OpenAIWrapper(config_list=config_list)
response = client.create(
Expand Down Expand Up @@ -105,7 +105,9 @@ def test_chat_completion():
@pytest.mark.skipif(skip, reason="openai>=1 not installed")
def test_completion():
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo-instruct"]}
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"tags": ["gpt-35-turbo-instruct", "gpt-3.5-turbo-instruct"]},
)
client = OpenAIWrapper(config_list=config_list)
response = client.create(prompt="1+1=")
Expand All @@ -123,7 +125,9 @@ def test_completion():
)
def test_cost(cache_seed):
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo-instruct"]}
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"tags": ["gpt-35-turbo-instruct", "gpt-3.5-turbo-instruct"]},
)
client = OpenAIWrapper(config_list=config_list, cache_seed=cache_seed)
response = client.create(prompt="1+3=")
Expand All @@ -145,7 +149,9 @@ def test_customized_cost():
@pytest.mark.skipif(skip, reason="openai>=1 not installed")
def test_usage_summary():
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo-instruct"]}
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"tags": ["gpt-35-turbo-instruct", "gpt-3.5-turbo-instruct"]},
)
client = OpenAIWrapper(config_list=config_list)
response = client.create(prompt="1+3=", cache_seed=None)
Expand Down Expand Up @@ -181,7 +187,7 @@ def test_legacy_cache():
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"model": ["gpt-3.5-turbo", "gpt-35-turbo"]},
filter_dict={"tags": ["gpt-3.5-turbo"]},
)

# Prompt to use for testing.
Expand Down Expand Up @@ -250,7 +256,7 @@ def test_cache():
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"model": ["gpt-3.5-turbo", "gpt-35-turbo"]},
filter_dict={"tags": ["gpt-3.5-turbo"]},
)

# Prompt to use for testing.
Expand Down
6 changes: 3 additions & 3 deletions test/oai/test_client_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_aoai_chat_completion_stream() -> None:
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"api_type": ["azure"], "model": ["gpt-3.5-turbo", "gpt-35-turbo"]},
filter_dict={"api_type": ["azure"], "tags": ["gpt-3.5-turbo"]},
)
client = OpenAIWrapper(config_list=config_list)
response = client.create(messages=[{"role": "user", "content": "2+2="}], stream=True)
Expand All @@ -50,7 +50,7 @@ def test_chat_completion_stream() -> None:
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"model": ["gpt-3.5-turbo", "gpt-35-turbo"]},
filter_dict={"tags": ["gpt-3.5-turbo"]},
)
client = OpenAIWrapper(config_list=config_list)
response = client.create(messages=[{"role": "user", "content": "1+1="}], stream=True)
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_chat_functions_stream() -> None:
config_list = config_list_from_json(
env_or_file=OAI_CONFIG_LIST,
file_location=KEY_LOC,
filter_dict={"model": ["gpt-3.5-turbo", "gpt-35-turbo"]},
filter_dict={"tags": ["gpt-3.5-turbo"]},
)
functions = [
{
Expand Down

0 comments on commit 6d4cf40

Please sign in to comment.