Context Manager
- class app.utils.context_manager.ContextManager(max_context_length: int = 10)[source]
Bases:
object
Manages conversation context using a fixed-size circular buffer.
This class provides methods to add, retrieve, and manipulate the conversation context.
- add_to_context(message: str) None [source]
Add a message to the context.
- Parameters:
message – The message to add to the context.
- get_context() List[str] [source]
Retrieve the current context as a list of messages.
- Returns:
The current context messages.
- get_context_length() int [source]
Get the current number of messages in the context.
- Returns:
The number of messages in the context.
- get_context_string(separator: str = '\n') str [source]
Retrieve the current context as a single string.
- Parameters:
separator – The string to use for joining context messages.
- Returns:
The current context as a single string.