forked from HAL9000/cleveragents-core
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
from typing import Any, Protocol
|
|
|
|
from langchain_core.embeddings import Embeddings
|
|
|
|
class _VectorDocument(Protocol):
|
|
metadata: dict[str, Any]
|
|
page_content: str
|
|
|
|
class FAISS:
|
|
"""Subset of the FAISS vector store methods used in CleverAgents."""
|
|
|
|
@classmethod
|
|
def from_texts(
|
|
cls,
|
|
texts: Sequence[str],
|
|
embedding: Embeddings,
|
|
metadatas: Sequence[dict[str, Any]] | None = ...,
|
|
ids: Sequence[str] | None = ...,
|
|
**kwargs: Any,
|
|
) -> FAISS: ...
|
|
def save_local(self, folder_path: str) -> None: ...
|
|
@classmethod
|
|
def load_local(
|
|
cls,
|
|
folder_path: str,
|
|
embeddings: Embeddings,
|
|
*,
|
|
allow_dangerous_deserialization: bool = ...,
|
|
**kwargs: Any,
|
|
) -> FAISS: ...
|
|
def similarity_search_with_score(
|
|
self,
|
|
query: str,
|
|
*,
|
|
k: int = ...,
|
|
filter: Any = ...,
|
|
fetch_k: int = ...,
|
|
**kwargs: Any,
|
|
) -> list[tuple[_VectorDocument, float]]: ...
|
|
|
|
__all__ = ["FAISS"]
|