Skip to content

LLM backend signature not unified #44

@allenanie

Description

@allenanie

Currently LLM backend __init__ signature is not unified (this is a legacy backward compatibility issue mostly with AutoGen).

For three backends, the signatures are:

class AutoGenLLM(AbstractModel):
    def __init__(self, config_list: List = None, filter_dict: Dict = None, reset_freq: Union[int, None] = None) -> None

class LiteLLM(AbstractModel):
    def __init__(self, model: Union[str, None] = None, reset_freq: Union[int, None] = None,
                 cache=True) -> None:

class CustomLLM(AbstractModel):
    def __init__(self, model: Union[str, None] = None, reset_freq: Union[int, None] = None,
                 cache=True) -> None:

Essentially two of them allow user to set model, but one can't. It is true that with AutoGen, the model setup/configuration is from the config_list side -- but we could consider unifying the AutoGen interface by dynamically creating a config_list by grabbing the API key from environment variables, see this convenience function:

def auto_construct_oai_config_list_from_env() -> List:
    """
    Collect various API keys saved in the environment and return a format like:
    [{"model": "gpt-4", "api_key": xxx}, {"model": "claude-3.5-sonnet", "api_key": xxx}]

    Note this is a lazy function that defaults to gpt-40 and claude-3.5-sonnet.
    If you want to specify your own model, please provide an OAI_CONFIG_LIST in the environment or as a file
    """
    config_list = []
    if os.environ.get("OPENAI_API_KEY") is not None:
        config_list.append(
            {"model": "gpt-4o", "api_key": os.environ.get("OPENAI_API_KEY")}
        )
    if os.environ.get("ANTHROPIC_API_KEY") is not None:
        config_list.append(
            {
                "model": "claude-3-5-sonnet-latest",
                "api_key": os.environ.get("ANTHROPIC_API_KEY"),
            }
        )
    return config_list

If you approve this solution, I can implement this! Otherwise, we can stay with the current design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions