Skip to content

chat_llm

ChatOutput

Bases: BaseModel

Chat output

Attributes:

Name Type Description
content str

Content of the message

Source code in api/routes/chat_llm.py
class ChatOutput(BaseModel):
    """
    Chat output

    Attributes:
        content (str): Content of the message
    """

    content: str = Field(
        ...,
        title="Content of the message",
        description="Content of the message",
        examples=["Hello, how can I help you today?"],
    )

chat(chat_input, chat_model=Depends(get_chat_model))

Chat with the chat model

Parameters:

Name Type Description Default
chat_input ChatInput

Chat input

required
chat_model BaseChatModel

Chat model

Depends(get_chat_model)

Returns:

Name Type Description
ChatOutput Annotated[ChatOutput, 'Chat Output']

Chat output

Source code in api/routes/chat_llm.py
@router.post(
    "",
    description="Chat with the chat model",
    summary="Chat with the chat model",
    response_description="Response of the model",
)
def chat(
    chat_input: Annotated[ChatInput, "Chat Input"], chat_model=Depends(get_chat_model)
) -> Annotated[ChatOutput, "Chat Output"]:
    """
    Chat with the chat model

    Args:
        chat_input (ChatInput): Chat input
        chat_model (BaseChatModel): Chat model

    Returns:
        ChatOutput: Chat output
    """
    chat_llm = ChatLLM(chat_model=chat_model)
    res = chat_llm.chat(chat_input=chat_input)
    return ChatOutput(content=res)