autogenhub / autogen

A programming framework for agentic AI. Discord: https://discord.gg/pAbnFJrkgZ
https://autogenhub.github.io/autogen/
Apache License 2.0
119 stars 22 forks source link

Custom Model Client class support for 'auto' speaker selection in Group Chat #65

Closed marklysze closed 1 month ago

marklysze commented 1 month ago

Why are these changes needed?

If you are you using a custom model client class and want to use it for the the inner speaker selection chat when using auto speaker selection, it isn't possible at the moment as it uses the GroupChatManager's config by default.

This addresses this bug by registering the custom model client class during the creation of the inner speaker_selection_agent.

To assign a custom model client class and config to the inner auto speaker selection agent you need to register the config and client class with the GroupChat object, see example below.

# Import your custom model client class
from mycustommodelclient import MyCustomModelClient

# Example llm_config
custom_llm_config = {
    "config_list":
    [
        {
            "model_client_cls": "MyCustomModelClient",
        }
    ]
}

# Updated GroupChat creation with config and client classes registered
gc = GroupChat(
    agents=[mark, alexandra, elizabeth],
    speaker_selection_method="auto",
    allow_repeat_speaker=False,
    select_speaker_auto_verbose=True,
    select_speaker_auto_llm_config=custom_llm_config,
    select_speaker_auto_model_client_cls=MyCustomModelClient,
    max_round=5,
    messages=[]
)

Two new properties exist:

Documentation update to come.

Related issue number

Raised by Jason_DataScience on Discord.

Checks

Hk669 commented 1 month ago

@marklysze have you tested this PR.

marklysze commented 1 month ago

Hey @Hk669, yes, I've tested it and also passes pytest :)

I'm in the process of adding some documentation before final review.

marklysze commented 1 month ago

Okay, @Hk669, I've added a documentation page as well, so good for review.

Hk669 commented 1 month ago

Thanks @marklysze , let me go through the docs and test it locally.

qingyun-wu commented 1 month ago

@Hk669 Have you finished testing? Thank you!