pangukitsappdev.vectorstores package

Submodules

pangukitsappdev.vectorstores.adapter module

class pangukitsappdev.vectorstores.adapter.CSSVectorApi(vector_config: VectorStoreConfig)

基类:AbstractVectorApi

create_vector_store(vector_config: VectorStoreConfig) VectorStore

使用VectorStoreConfig里的配置构造VectorStore实现类

Args:

vector_config: 相关配置

Returns:

实现类VectorStore接口的对象

pangukitsappdev.vectorstores.bulk_data module

class pangukitsappdev.vectorstores.bulk_data.BulkData(*, id: str, data: Dict[str, Any] = {})

基类:BaseModel

ES Bulk消息 Attributes:

id: 索引ID data: 数据

data: Dict[str, Any]
id: str

pangukitsappdev.vectorstores.css_store module

Wrapper around CSS vector database.

class pangukitsappdev.vectorstores.css_store.CSSVectorSearch(elasticsearch_url: str, index_name: str, embedding: ~langchain_core.embeddings.embeddings.Embeddings, vector_fields: ~typing.List[str], source_fields: ~typing.List[str], text_key: str, mapping_func: ~typing.Callable[[int], ~typing.Dict] = <function _default_text_mapping>, script_query_func: ~typing.Callable[[~typing.List[float], str], dict] = <function _default_script_query>, get_doc_with_score_func: ~typing.Callable[[~typing.Dict, str], ~typing.Tuple[~pangukitsappdev.api.memory.vector.base.Document, float]] = <function _default_get_doc_with_score_func>, **kwargs)

基类:VectorStore, ABC

把CSS数据库包装成向量数据库,CSS是基于开源Elasticsearch开发的自研向量搜索数据库,连接不需要身份认证信息, 传入 URL 和 index 以及 embedding 进行构造. Args:

elasticsearch_url (str): The URL for the Elasticsearch instance. index_name (str): The name of the Elasticsearch index for the embeddings. embedding (Embeddings): An object that provides the ability to embed text.

It should be an instance of a class that subclasses the Embeddings abstract base class, such as OpenAIEmbeddings()

Raises:

ValueError: If the elasticsearch python package is not installed.

add_docs(bulk_data_list: List[BulkData], **kwargs)

写入文档统一接口 Args:

bulk_data_list: 批量添加的文档

add_docs_with_builtin_embedding(bulk_data_list: List[BulkData])
add_docs_with_external_embedding(bulk_data_list: List[BulkData], embedded: List[List[float]])
clear()

清空索引文档

delete(ids: Optional[List[str]] = None, **kwargs: Any)

Delete by vector ID or other criteria.

Args:

ids: List of ids to delete. **kwargs: Other keyword arguments that subclasses might use.

Returns:

Optional[bool]: True if deletion is successful, False otherwise, None if not implemented.

通过DSL查询 Args:

dsl: DSL

Returns:

原始返回结果

classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, elasticsearch_url: Optional[str] = None, index_name: Optional[str] = None, refresh_indices: bool = True, **kwargs: Any) CSSVectorSearch

Construct ElasticVectorSearch wrapper from raw documents.

This is a user-friendly interface that:
  1. Embeds documents.

  2. Creates a new index for the embeddings in the Elasticsearch instance.

  3. Adds the documents to the newly created Elasticsearch index.

This is intended to be a quick way to get started.

Example:
from langchain import ElasticVectorSearch
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
elastic_vector_search = ElasticVectorSearch.from_texts(
    texts,
    embeddings,
    elasticsearch_url="http://localhost:9200"
)
is_external_embedding() bool

返回和查询语句最相近的k条文本.

Args:

query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 5. score_threshold: 低于这个阈值分数的doc不会被检索出来

Returns:

List of Documents most similar to the query.

similarity_search_with_builtin_embedding(query, k, **kwargs) List[Tuple[Document, float]]

检索,不使用 :param query: query词 :param k: 检索结果数 :param kwargs: 扩展参数 :return: List[Document] 检索结果

similarity_search_with_external_embedding(embedding, k, **kwargs) List[Tuple[Document, float]]
similarity_search_with_relevance_scores(query: str, k: int = 5, score_threshold: float = -1.0, **kwargs: Any) List[Tuple[Document, float]]

Return docs and relevance scores in the range [0, 1].

0 is dissimilar, 1 is most similar.

Args:

query: input text k: Number of Documents to return. Defaults to 4. **kwargs: kwargs to be passed to similarity search. Should include:

score_threshold: Optional, a floating point value between 0 to 1 to

filter the resulting set of retrieved docs

Returns:

List of Tuples of (doc, similarity_score)

similarity_search_with_score(query: str, k: int = 5, score_threshold: float = -1.0, **kwargs: Any) List[Tuple[Document, float]]

Return docs most similar to query. Args:

query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 5. score_threshold: (Optional)低于这个阈值分数的doc不会被检索出来

Returns:

List of Documents most similar to the query.

pangukitsappdev.vectorstores.proxy_http_requests module

class pangukitsappdev.vectorstores.proxy_http_requests.ProxyRequestsHttpConnection(proxies=None, **kwargs)

基类:RequestsHttpConnection

Module contents