init
__all__ = ['MessageMetadata', 'MessageSearchResult', 'MessageSearchResults', 'MessageSearchUnitOfWork', 'add_all_user_messages', 'add_messages', 'delete_all_user_messages', 'search_messages', 'stored_message_stats']
module-attribute
MessageMetadata
Bases: AbstractQdrantMetadata
conversation_uid
instance-attribute
embed_type = MessageEmbeddingType.FULL_MESSAGE
class-attribute
instance-attribute
message_creation_time
instance-attribute
message_type
instance-attribute
message_uid
instance-attribute
model_config = ConfigDict(extra='ignore')
class-attribute
instance-attribute
pk_id
instance-attribute
snippet_index = None
class-attribute
instance-attribute
thread_uid
instance-attribute
tool_call_ids
instance-attribute
tool_names
instance-attribute
user_clerk_id
instance-attribute
as_content()
from_message(message, user_id, conversation_uid, thread_uid)
classmethod
from_messages(messages, user_id, conversation_uid, thread_uid)
classmethod
MessageSearchResult
dataclass
content
instance-attribute
metadata
instance-attribute
qdrant_id
instance-attribute
score
instance-attribute
__init__(qdrant_id, content, metadata, score)
as_artifact()
as_content()
MessageSearchResults
dataclass
results
instance-attribute
__init__(results)
__post_init__()
as_artifact()
as_content()
MessageSearchUnitOfWork
collection_name = COLLECTION_NAME
class-attribute
qdrant = qdrant
instance-attribute
read_only_uow
property
__init__(qdrant, read_only_uow)
add_all_user_messages(uow, user_id, wait=False, updatable=None)
async
Add users messages to qdrant (loading from db).
| RETURNS | DESCRIPTION |
|---|---|
int
|
Number of messages added. |
add_messages(uow, messages, user_id, conversation_uid, thread_uid, wait=False, text_splitter=None)
async
Add new messages to the vectorstore.
| PARAMETER | DESCRIPTION |
|---|---|
uow
|
The unit of work for the message search service.
TYPE:
|
messages
|
The messages to add.
TYPE:
|
user_id
|
The user the message belongs to.
TYPE:
|
conversation_uid
|
The conversation the message belongs to.
TYPE:
|
thread_uid
|
The thread that the message belongs to.
TYPE:
|
wait
|
Whether to wait for the operation to complete (defaults to False).
TYPE:
|
text_splitter
|
The text splitter to use for splitting long messages into snippets.
TYPE:
|
delete_all_user_messages(uow, user_id, wait=True)
async
Delete all messages for a user from the vectorstore.
search_messages(uow, query_text, user_id, conversation_uid=None, thread_uid=None, embed_type=None, max_results=None, max_message_age=None, message_types=None, result_index_offset=None, include_long_content=False)
async
Search for message contents/snippets in the vectorstore.
Optionally, filter or customize the search.
| PARAMETER | DESCRIPTION |
|---|---|
uow
|
Search unit of work.
TYPE:
|
query_text
|
Text to search for (by embedding and doing similarity search).
TYPE:
|
user_id
|
User id to filter by.
TYPE:
|
conversation_uid
|
Conversation uid to filter by.
TYPE:
|
thread_uid
|
Thread uid to filter by. (Assistant run)
TYPE:
|
embed_type
|
Type of embedding to search for (default None means all types).
TYPE:
|
max_results
|
Max number of results to return.
TYPE:
|
max_message_age
|
Maximum age of messages to search.
TYPE:
|
message_types
|
Types of messages to search.
TYPE:
|
result_index_offset
|
Offset of the first result to return.
TYPE:
|
include_long_content
|
Whether to also search messages with long content (EmbeddedContentLocation).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MessageSearchResults
|
MessageSearchResults (has list of MessageSearchResult with methods to transform) |
stored_message_stats(uow, user_id, conversation_uid=None, thread_uid=None)
async
Get the number of messages stored for a user.