Source code for langchain_community.retrievers.zep
from __future__ import annotations
from enum import Enum
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from langchain_core.callbacks import (
    AsyncCallbackManagerForRetrieverRun,
    CallbackManagerForRetrieverRun,
)
from langchain_core.documents import Document
from langchain_core.pydantic_v1 import root_validator
from langchain_core.retrievers import BaseRetriever
if TYPE_CHECKING:
    from zep_python.memory import MemorySearchResult
[docs]class SearchScope(str, Enum):
    """Which documents to search. Messages or Summaries?"""
    messages = "messages"
    """Search chat history messages."""
    summary = "summary"
    """Search chat history summaries."""
[docs]class SearchType(str, Enum):
    """Enumerator of the types of search to perform."""
    similarity = "similarity"
    """Similarity search."""
    mmr = "mmr"
    """Maximal Marginal Relevance reranking of similarity search."""
[docs]class ZepRetriever(BaseRetriever):
    """`Zep` MemoryStore Retriever.
    Search your user's long-term chat history with Zep.
    Zep offers both simple semantic search and Maximal Marginal Relevance (MMR)
    reranking of search results.
    Note: You will need to provide the user's `session_id` to use this retriever.
    Args:
        url: URL of your Zep server (required)
        api_key: Your Zep API key (optional)
        session_id: Identifies your user or a user's session (required)
        top_k: Number of documents to return (default: 3, optional)