LlmConfig (llms/configs.py)

mem0 · mem0/llms/configs.py · python · Apache-2.0
ai, AI / Agents

Pydantic model defining LLM provider and config with validation for supported providers.

# Source: https://github.com/mem0ai/mem0 | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
from typing import Optional

from pydantic import BaseModel, Field, field_validator


class LlmConfig(BaseModel):
    provider: str = Field(description="Provider of the LLM (e.g., 'ollama', 'openai')", default="openai")
    config: Optional[dict] = Field(description="Configuration for the specific LLM", default={})

    @field_validator("config")
    def validate_config(cls, v, values):
        provider = values.data.get("provider")
        if provider in (
            "openai",
            "ollama",
            "anthropic",
            "groq",
            "together",
            "aws_bedrock",

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key