LangChain SearchScope for Searching Messages and Summaries
Posted: Nov 24, 2024.
SearchScope is a LangChain enum class used to specify which documents to search in chat history - either individual messages or generated summaries. It's particularly useful when working with chat history retrievers like ZepRetriever to control the scope of your semantic searches.
What is SearchScope?
SearchScope is an enumeration class that defines two possible search scopes when querying chat history:
- Searching through individual chat messages
- Searching through generated summaries of conversations
This allows you to control whether you want to search through granular message-level content or higher-level summaries that capture the key points of conversations.
Reference
The SearchScope enum has two values:
Value | Description |
---|---|
messages | Search through individual chat history messages |
summary | Search through generated summaries of chat conversations |
How to Use SearchScope
Here are examples of how to use SearchScope with a chat history retriever:
Searching Through Messages
To search through individual chat messages:
Searching Through Summaries
To search through conversation summaries instead:
Benefits of Using Summaries
Searching through summaries can be advantageous when you want to:
- Get a high-level overview of conversations
- Search through condensed versions of long chat histories
- Find key points without getting lost in conversation details
- Reduce the number of search results to process
Example combining with other retriever options:
By choosing the appropriate SearchScope, you can optimize your chat history searches based on whether you need detailed message-level information or high-level conversation summaries.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.
LangChain DocsJoin 10,000+ subscribers
Every 2 weeks, latest model releases and industry news.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.