pyrit.analytics.ConversationAnalytics#
- class ConversationAnalytics(*, memory_interface: MemoryInterface)[source]#
Bases:
object
Handles analytics operations on conversation data, such as finding similar chat messages based on conversation history or embedding similarity.
- __init__(*, memory_interface: MemoryInterface)[source]#
Initializes the ConversationAnalytics with a memory interface for data access.
- Parameters:
memory_interface (MemoryInterface) – An instance of MemoryInterface for accessing conversation data.
Methods
__init__
(*, memory_interface)Initializes the ConversationAnalytics with a memory interface for data access.
Retrieves chat messages that have the same converted content
Retrieves chat messages that are similar to the given embedding based on cosine similarity.
- get_prompt_entries_with_same_converted_content(*, chat_message_content: str) list[ConversationMessageWithSimilarity] [source]#
Retrieves chat messages that have the same converted content
- get_similar_chat_messages_by_embedding(*, chat_message_embedding: list[float], threshold: float = 0.8) list[EmbeddingMessageWithSimilarity] [source]#
Retrieves chat messages that are similar to the given embedding based on cosine similarity.
- Parameters:
- Returns:
A list of ConversationMessageWithSimilarity objects representing the similar chat messages based on embedding similarity.
- Return type:
List[ConversationMessageWithSimilarity]