Skip to content

Baichuan openai style llm

BAICHUANOpenAIStyleLLM

Bases: OpenAIStyleLLM

BAICHUAN OpenAI Style LLM Args: api_key (Optional[str]): API key for the model. Defaults to None. api_base (Optional[str]): API base URL for the model. Defaults to "https://api.openai.com/v1".

Source code in agentuniverse/llm/default/baichuan_openai_style_llm.py
Python
class BAICHUANOpenAIStyleLLM(OpenAIStyleLLM):
    """
    BAICHUAN OpenAI Style LLM
    Args:
        api_key (Optional[str]): API key for the model. Defaults to None.
        api_base (Optional[str]): API base URL for the model. Defaults to "https://api.openai.com/v1".
    """

    api_key: Optional[str] = Field(default_factory=lambda: get_from_env("BAICHUAN_API_KEY"))
    api_base: Optional[str] = "https://api.baichuan-ai.com/v1"
    proxy: Optional[str] = Field(default_factory=lambda: get_from_env("BAICHUAN_PROXY"))
    organization: Optional[str] = Field(default_factory=lambda: get_from_env("BAICHUAN_ORGANIZATION"))

    def max_context_length(self) -> int:
        if super().max_context_length():
            return super().max_context_length()
        return BAICHUAN_Max_CONTEXT_LENGTH.get(self.model_name, 8000)