# This file was auto-generated by Fern from our API Definition.

from ..core.pydantic_utilities import UniversalBaseModel
import typing
import pydantic
from .pydantic_program_mode import PydanticProgramMode
from .base_prompt_template import BasePromptTemplate
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class Llm(UniversalBaseModel):
    """
    The LLM class is the main class for interacting with language models.

    Attributes:
        system_prompt (Optional[str]):
            System prompt for LLM calls.
        messages_to_prompt (Callable):
            Function to convert a list of messages to an LLM prompt.
        completion_to_prompt (Callable):
            Function to convert a completion to an LLM prompt.
        output_parser (Optional[BaseOutputParser]):
            Output parser to parse, validate, and correct errors programmatically.
        pydantic_program_mode (PydanticProgramMode):
            Pydantic program mode to use for structured prediction.
    """

    callback_manager: typing.Optional[typing.Optional[typing.Any]] = None
    system_prompt: typing.Optional[str] = pydantic.Field(default=None)
    """
    System prompt for LLM calls.
    """

    messages_to_prompt: typing.Optional[str] = pydantic.Field(default=None)
    """
    Function to convert a list of messages to an LLM prompt.
    """

    completion_to_prompt: typing.Optional[str] = pydantic.Field(default=None)
    """
    Function to convert a completion to an LLM prompt.
    """

    output_parser: typing.Optional[typing.Optional[typing.Any]] = None
    pydantic_program_mode: typing.Optional[PydanticProgramMode] = None
    query_wrapper_prompt: typing.Optional[BasePromptTemplate] = pydantic.Field(default=None)
    """
    Query wrapper prompt for LLM calls.
    """

    class_name: typing.Optional[str] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
