From b68ca06302fc6eb269120d6f0bd6a69baeb622c3 Mon Sep 17 00:00:00 2001 From: MrChengmo Date: Tue, 19 Mar 2024 19:43:31 +0800 Subject: [PATCH] update reame --- .../components/retriever/baidu_vdb/README.md | 18 +++++++++++++++--- .../retriever/baidu_vdb/baiduvdb_retriever.py | 17 +++++++++++++++++ cookbooks/vdb_retriever.ipynb | 1 - 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/appbuilder/core/components/retriever/baidu_vdb/README.md b/appbuilder/core/components/retriever/baidu_vdb/README.md index 013c48a40..de91b7d73 100644 --- a/appbuilder/core/components/retriever/baidu_vdb/README.md +++ b/appbuilder/core/components/retriever/baidu_vdb/README.md @@ -30,7 +30,6 @@ import appbuilder # 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 os.environ["APPBUILDER_TOKEN"] = '...' -embedding = appbuilder.Embedding() segments = appbuilder.Message(["文心一言大模型", "百度在线科技有限公司"]) # 初始化构建索引 vector_index = appbuilder.BaiduVDBVectorStoreIndex.from_params( @@ -56,14 +55,27 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" ``` ### 初始化参数说明: +`BaiduVDBVectorStoreIndex()` 实例化参数说明: +- instance_id(str,必填):百度向量数据库的实例id,创建实例时获取 +- api_key (str,必填):连接向量数据库所需的密码,创建实例时获取 +- account (str,非必填):连接向量数据库所需的用户名,默认root +- database_name (str,非必填) :向量数据库的名称,默认为AppBuilderDatabase +- table_params (TableParams,非必填) :VectorDB table参数,参考链接[VectorDB table params](https://cloud.baidu.com/doc/VDB/s/mlrsob0p6) +- embedding (Embedding,非必填) :appbuilder.Embedding类型,若有构造好的Embedding,可以增量插入,否则默认新建embedding -- segments (Message[List[str]],必填):需要入库的文本段落 +------- + +`BaiduVDBVectorStoreIndex().from_params()` 构造函数参数说明: - instance_id(str,必填):百度向量数据库的实例id,创建实例时获取 - api_key (str,必填):连接向量数据库所需的密码,创建实例时获取 - account (str,非必填):连接向量数据库所需的用户名,默认root -- embedding (obj,非必填):用于将文本转为向量的模型,默认为Embedding +- database_name (str,非必填) :向量数据库的名称,默认为AppBuilderDatabase +- table_name (str,非必填) :向量数据库的表名,默认为AppBuilderTable - drop_exists (bool, 非必填) :是否清空数据库历史记录,默认为False +------- + + ### 调用参数: | 参数名称 | 参数类型 |是否必须 | 描述 | 示例值 | |---------|--------|--------|------------------|---------------| diff --git a/appbuilder/core/components/retriever/baidu_vdb/baiduvdb_retriever.py b/appbuilder/core/components/retriever/baidu_vdb/baiduvdb_retriever.py index 3ca4b062d..16828e36e 100644 --- a/appbuilder/core/components/retriever/baidu_vdb/baiduvdb_retriever.py +++ b/appbuilder/core/components/retriever/baidu_vdb/baiduvdb_retriever.py @@ -357,6 +357,23 @@ def from_params( drop_exists: bool = False, **kwargs, ): + """ + 从参数中实例化类。 + + Args: + cls: 类对象,即当前函数所属的类。 + instance_id: str,实例ID。 + api_key: str,API密钥。 + account: str,账户名,默认为root。 + database_name: str,数据库名,默认为AppBuilderDatabase。 + table_name: str,表名,默认为AppBuilderTable。 + drop_exists: bool,是否删除已存在的表,默认为False。 + **kwargs: 其他参数,可选的维度参数dimension默认为384。 + + Returns: + 类实例,包含实例ID、账户名、API密钥、数据库名、表参数等属性。 + + """ _try_import() dimension = kwargs.get("dimension", 384) table_params = TableParams( diff --git a/cookbooks/vdb_retriever.ipynb b/cookbooks/vdb_retriever.ipynb index 44ada66c9..215d89c1e 100644 --- a/cookbooks/vdb_retriever.ipynb +++ b/cookbooks/vdb_retriever.ipynb @@ -91,7 +91,6 @@ "metadata": {}, "outputs": [], "source": [ - "embedding = appbuilder.Embedding()\n", "segments = appbuilder.Message([\"文心一言大模型\", \"百度在线科技有限公司\"])\n", "# 初始化构建索引\n", "vector_index = appbuilder.BaiduVDBVectorStoreIndex.from_params(\n",