Chat Service

class app.services.chat_service.ChatService(llm_service: LLMService, context_manager: ContextManager)[source]

Bases: object

A service class for managing chat interactions with an AI assistant.

This class integrates the LLM service for generating responses and a context manager for maintaining conversation history.

clear_conversation() None[source]

Clear the current conversation history from the context manager.

get_context_info() Dict[str, int][source]

Get information about the current context.

Returns:

A dictionary containing the current and maximum context length.

async get_conversation_history() List[Tuple[str, str]][source]

Retrieve the conversation history from the context manager.

Returns:

A list of tuples, each containing a speaker (‘user’ or ‘ai’) and their message.

async process_message(message: str) ChatResponse[source]

Process a user message and generate an AI response.

Parameters:

message – The user’s input message.

Returns:

A ChatResponse object containing the AI’s response.