update_point 用于更新知识库下的切片内容
参数 | 类型 | 必选 | 默认值 | 备注 |
|---|---|---|---|---|
collection_name | string | 否 | -- | 知识库名称 |
project_name | string | 否 | default | 知识库所属项目,获取方式参见文档API 接入与技术支持 |
resource_id | string | 否 | -- | 知识库唯一 id |
point_id | string | 是 | -- | 要更新的切片 id |
chunk_title | string | 否 | -- | 切片标题 |
content | string | 二者只传一个 | -- | 要更新的非结构化文档的切片内容
|
fields | list | -- | 要更新的结构化文档的切片内容 | |
question | string | 否 | -- | 要更新的非结构化 faq 文档切片的问题字段 |
字段 | 类型 | 备注 |
|---|---|---|
code | Optional[int] | 状态码 |
message | Optional[str] | 返回信息 |
request_id | Optional[str] | 标识每个请求的唯一标识符 |
data | Optional[Any] | 返回数据(通常为空) |
code | message | 备注 | http status_code |
|---|---|---|---|
0 | success | 成功 | 200 |
1000001 | unauthorized | 缺乏鉴权信息 | 401 |
1000002 | no permission | 权限不足 | 403 |
1000003 | invalid request:%s | 非法参数 | 400 |
1000005 | collection not exist | collection不存在 | 400 |
首次使用知识库 SDK ,可参考 使用说明
本示例演示了知识库 Python SDK 中 UpdatePoint 函数的基础使用方法,通过指定知识库名称和切片 ID 修改切片内容,使用前需配置 AK/SK 鉴权参数。
import os from vikingdb.knowledge import VikingKnowledge from vikingdb.auth import IAM from vikingdb.knowledge.models.point import UpdatePointRequest def main(): access_key = os.getenv("VIKINGDB_AK") secret_key = os.getenv("VIKINGDB_SK") endpoint = "api-knowledgebase.mlp.cn-beijing.volces.com" region = "cn-beijing" client = VikingKnowledge( host=endpoint, region=region, auth=IAM(ak=access_key, sk=secret_key), scheme="https" ) collection = client.collection( collection_name="Your collection name", project_name="default", ) point_id = "your_point_id" try: collection.update_point(point_id=point_id, update=UpdatePointRequest( content="updated content" )) print("UpdatePoint success") except Exception as e: print(f"UpdatePoint failed, err: {e}") if __name__ == "__main__": main()