pangukitsappdev.api.memory.vector package¶
Submodules¶
pangukitsappdev.api.memory.vector.base module¶
- class pangukitsappdev.api.memory.vector.base.AbstractVectorApi(vector_config: VectorStoreConfig)¶
基类:
VectorApi
,ABC
VectorApi接口的基类 封装了一个langchain.vectorstores.VectorStore的实现类,用来适配VectorApi接口。 子类需要实现create_vector_store,用来构造一个langchain.vectorstores.VectorStore的实现类 Attributes:
vector_config: VectorStoreConfig类型,封装了用来构造VectorStore的一些参数 vector_store: langchain.vectorstores.VectorStore的实现类,通过create_vector_store方法构造
- clear()¶
清空索引文档
- abstract create_vector_store(vector_config: VectorStoreConfig) VectorStore ¶
使用VectorStoreConfig里的配置构造VectorStore实现类
- Args:
vector_config: 相关配置
- Returns:
实现类VectorStore接口的对象
- remove(ids: List[str])¶
删除文档 Args:
ids: 需要删除的文档ID
- search(dsl: dict) dict ¶
通过DSL查询 Args:
dsl: 查询语句
- Returns:
原始返回结果
- class pangukitsappdev.api.memory.vector.base.Document(page_content: str, *, metadata: dict = None, type: Literal['Document'] = 'Document', score: float = 0.0, id: str = '')¶
基类:
Document
增加了打分字段 Attributes:
score: 文档的相似度打分 id: 文档id
- id: str¶
- score: float¶
- class pangukitsappdev.api.memory.vector.base.VectorApi¶
基类:
ABC
Interface for vector store
- abstract clear()¶
清空索引文档
- abstract remove(ids: List[str])¶
删除文档 Args:
ids: 需要删除的文档ID
- abstract search(dsl: str) dict ¶
通过DSL查询 Args:
dsl: 查询语句
- Returns:
原始返回结果
- class pangukitsappdev.api.memory.vector.base.VectorStore¶
基类:
VectorStore
,ABC
- add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) List[str] ¶
Run more texts through the embeddings and add to the vectorstore.
- Args:
texts: Iterable of strings to add to the vectorstore. metadatas: Optional list of metadatas associated with the texts. kwargs: vectorstore specific parameters
- Returns:
List of ids from adding the texts into the vectorstore.
- abstract clear()¶
清空索引文档
- abstract dsl_search(dsl: dict) dict ¶
通过DSL查询 Args:
dsl: DSL
- Returns:
原始返回结果
pangukitsappdev.api.memory.vector.factory module¶
- class pangukitsappdev.api.memory.vector.factory.Vectors¶
基类:
object
- classmethod of(vector_name: str = '', vector_config: Optional[VectorStoreConfig] = None) VectorApi ¶
根据名字创建一个VectorApi的实现类 vector_name和vector_config.store_name不可同时为空 Args:
vector_name: (Optional)vector的名字,唯一标识一个VectorApi的实现类 vector_config: (Optional)VectorApi的相关配置,如果不传递则从默认配置文件中或者环境变量中获取
- Returns:
一个VectorApi的实现类
pangukitsappdev.api.memory.vector.vector_config module¶
- class pangukitsappdev.api.memory.vector.vector_config.ServerInfoCss(_env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]] = '<object object>', _env_file_encoding: Optional[str] = None, _env_nested_delimiter: Optional[str] = None, _secrets_dir: Optional[Union[str, PathLike]] = None, *, url: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None)¶
基类:
ServerInfo
- get_urls() [<class 'str'>] ¶
- password: Optional[str]¶
- url: Optional[str]¶
- user: Optional[str]¶
- class pangukitsappdev.api.memory.vector.vector_config.VectorStoreConfig(_env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]] = '<object object>', _env_file_encoding: Optional[str] = None, _env_nested_delimiter: Optional[str] = None, _secrets_dir: Optional[Union[str, PathLike]] = None, *, store_name: Optional[str] = None, server_info: ServerInfo = None, index_name: Optional[str] = None, embedding: Optional[EmbeddingApi] = None, distance_strategy: str = 'inner_product', text_key: str = 'text', metadata_key: str = 'metadata', bulk_size: int = 50, vector_fields: List[str] = [], source_fields: List[str] = [], ttl: Optional[int] = None, verify_certs: bool = True, http_config: HttpConfig = None)¶
-
向量库相关配置 Attributes:
store_name: 存储名称 server_info: ServerInfoCss,存储服务器链接相关信息,默认使用sdk.store.css前缀的配置 index_name: 索引名称 embedding: embedding库 distance_strategy: 检索模式,默认使用内积inner_product text_key: 文本内容字段名 metadata_key: 扩展元数据字段名 bulk_size: 文本入库时, 每批次记录数; 默认50, 受向量库及模型能力影响 vector_fields: CSS向量数据中,如果启用了embedding插件,用来指定那些字段做向量化查询 source_fields: 指定那些字段作为source字段返回(ES),不配置默认全部取回 ttl: 老化时间,单位 秒;向量存储场景,默认不设置TTL verify_certs: 是否校验https的证书。默认是True http_config: http代理配置
- bulk_size: int¶
- distance_strategy: str¶
- embedding: Optional[EmbeddingApi]¶
- http_config: HttpConfig¶
- index_name: Optional[str]¶
- metadata_key: str¶
- server_info: ServerInfo¶
- source_fields: List[str]¶
- store_name: Optional[str]¶
- text_key: str¶
- ttl: Optional[int]¶
- vector_fields: List[str]¶
- verify_certs: bool¶