thundra.core package¶
Submodules¶
thundra.core.graph module¶
- class thundra.core.graph.Graph[source]¶
Bases:
ABC
Abstract base class representing a graph with nodes and edges.
- classmethod combine_graph(*graphs)[source]¶
Combines multiple graph representations into a single graph.
- Parameters:
graphs (Graph) – Multiple graph objects to combine.
- Returns:
A string representation of the combined graph.
- Return type:
str
thundra.core.llm module¶
- class thundra.core.llm.LLM[source]¶
Bases:
object
A class to manage the lifecycle and availability of a language model (LLM) for chat.
- chat_models¶
The chat model to be used.
- Type:
BaseChatModel
- llm_available¶
An event to signal the availability of the LLM.
- Type:
Event
- property available: bool¶
Check if the language model is available.
- Returns:
True if the language model is available, False otherwise.
- Return type:
bool
-
chat_models:
BaseChatModel
¶
- property llm: BaseChatModel¶
Get the currently set language model. Waits if the model is not yet set.
- Returns:
The currently set language model.
- Return type:
BaseChatModel
thundra.core.memory module¶
- class thundra.core.memory.AIMemory(k=13)[source]¶
Bases:
object
Manages the memory for multiple users, each with their own conversation buffer.
- Parameters:
k (int, optional, default=13) – The default size of the conversation buffer.
- clear_history(id)[source]¶
Clears the chat history for a given user while retaining their initial system message.
- Parameters:
id (str) – The identifier for the user.
- class thundra.core.memory.UserMemory(system_message, k, memory)[source]¶
Bases:
object
Represents the memory for a user, including the system message and a conversation buffer.
- Parameters:
system_message (SystemMessage) – The initial system message.
k (int) – The size of the conversation buffer.
memory (ConversationBufferWindowMemory) – The conversation buffer memory.
- classmethod create_ai_instance(k)[source]¶
Creates an instance of UserMemory with the specified buffer size.
- Parameters:
k (int) – The size of the conversation buffer.
- Returns:
A new instance of UserMemory.
- Return type:
- get_memory()[source]¶
Retrieves the current conversation buffer memory, ensuring its size does not exceed 2*k messages.
- Returns:
The conversation buffer memory.
- Return type:
ConversationBufferWindowMemory
-
k:
int
¶
-
memory:
ConversationBufferWindowMemory
¶
-
system_message:
SystemMessage
¶
Module contents¶
- class thundra.core.Graph[source]¶
Bases:
ABC
Abstract base class representing a graph with nodes and edges.
- classmethod combine_graph(*graphs)[source]¶
Combines multiple graph representations into a single graph.
- Parameters:
graphs (Graph) – Multiple graph objects to combine.
- Returns:
A string representation of the combined graph.
- Return type:
str