Skip to content

chat_llm

ChatInput

Bases: BaseModel

Chat input

Attributes:

Name Type Description
messages list[ChatMessage]

Messages

Source code in core/chat_llm.py
class ChatInput(BaseModel):
    """
    Chat input

    Attributes:
        messages (list[ChatMessage]): Messages
    """

    messages: list[ChatMessage] = Field(
        ...,
        title="Messages",
        description="Messages",
    )

ChatLLM

Chat with a language model

Attributes:

Name Type Description
chat_model BaseChatModel

A chat model

Source code in core/chat_llm.py
class ChatLLM:
    """
    Chat with a language model

    Attributes:
        chat_model (BaseChatModel): A chat model
    """

    def __init__(
        self,
        chat_model: Annotated[ChatLLMModel, "A chat model"],
    ) -> None:
        """
        Create a ChatLLM

        Args:
            chat_model (BaseChatModel): A chat model
        """
        self.chat_model = chat_model

    def chat(self, chat_input: Annotated[ChatInput, "Chat Input"]) -> str:
        """
        Chat with the chat model

        Args:
            chat_input (LanguageModelInput): Chat input

        Returns:
            str: Chat output
        """
        return self.chat_model.chat(chat_input)

__init__(chat_model)

Create a ChatLLM

Parameters:

Name Type Description Default
chat_model BaseChatModel

A chat model

required
Source code in core/chat_llm.py
def __init__(
    self,
    chat_model: Annotated[ChatLLMModel, "A chat model"],
) -> None:
    """
    Create a ChatLLM

    Args:
        chat_model (BaseChatModel): A chat model
    """
    self.chat_model = chat_model

chat(chat_input)

Chat with the chat model

Parameters:

Name Type Description Default
chat_input LanguageModelInput

Chat input

required

Returns:

Name Type Description
str str

Chat output

Source code in core/chat_llm.py
def chat(self, chat_input: Annotated[ChatInput, "Chat Input"]) -> str:
    """
    Chat with the chat model

    Args:
        chat_input (LanguageModelInput): Chat input

    Returns:
        str: Chat output
    """
    return self.chat_model.chat(chat_input)

ChatLLMModel

Bases: ABC

Chat with a language model

Source code in core/chat_llm.py
class ChatLLMModel(ABC):
    """Chat with a language model"""

    @abstractmethod
    def chat(self, chat_input: Annotated[ChatInput, "Chat Input"]) -> str:
        """
        Chat with the chat model

        Args:
            chat_input (ChatInput): Chat input

        Returns:
            str: Chat output
        """

chat(chat_input) abstractmethod

Chat with the chat model

Parameters:

Name Type Description Default
chat_input ChatInput

Chat input

required

Returns:

Name Type Description
str str

Chat output

Source code in core/chat_llm.py
@abstractmethod
def chat(self, chat_input: Annotated[ChatInput, "Chat Input"]) -> str:
    """
    Chat with the chat model

    Args:
        chat_input (ChatInput): Chat input

    Returns:
        str: Chat output
    """