Skip to content

Message search tools

MESSAGE_SEARCH_DESCRIPTION = 'Search for related previous messages from the users conversation history.\nNote that all messages are filtered by user automatically (it is not possible to search for other users messages).\n' module-attribute

logger = logging.getLogger(__name__) module-attribute

MessageSearchArgs

Bases: BaseModel

conversations = Field(default='all', description=dedent(' (default "all"). Which conversations to limit search to. Use list of uids to search specific conversations.\n Only limit to "current" conversation if that is really necessary. Generally it\'s better to search all or specific\n conversations.\n ')) class-attribute instance-attribute

current_conv_id instance-attribute

embeddable_query_string = Field(description=dedent(' The string that will be embedded to generate a vector for similarity search. For example, key phrases from user\n input, or whole user input message, or description of topic or content to search for.'), min_length=5, max_length=500) class-attribute instance-attribute

max_message_age = Field(default='all', description=dedent(" (default 'all'). The maximum age of messages to search within.")) class-attribute instance-attribute

max_num_results = Field(default=5, description=dedent(' (default 5). The maximum number of results to return. E.g. if looking for favourite movie, 1 result is enough.\n If there is likely lots of previous conversation on topic, 25 might be helpful.')) class-attribute instance-attribute

message_types = Field(default=['all'], description=dedent(' (default ["all"]). The type of messages to search for. E.g. only user messages, only assistant messages, etc.')) class-attribute instance-attribute

result_index_offset = Field(default=0, description=dedent(' (default 0). The index of the first result to return. Useful if repeating a search to get additional results. Set\n this to skip the first N results previously obtained.')) class-attribute instance-attribute

user_id instance-attribute

MessageSearchTool

Bases: BaseTool

Tool wrapper around the search_messages service.

args_schema = MessageSearchArgs class-attribute instance-attribute

description = MESSAGE_SEARCH_DESCRIPTION class-attribute instance-attribute

message_search_uow instance-attribute

name = ToolNames.MESSAGE_SEARCH class-attribute instance-attribute

read_only_uow instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['message_search']) class-attribute instance-attribute