From bf019f3855ad982ad3d118dce72037ce7ac6bee3 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Fri, 27 Dec 2024 14:48:37 +0800 Subject: [PATCH] Fix Python SDK example error. --- docs/references/python_api_reference.md | 17 ++++++----------- sdk/python/ragflow_sdk/dataset.py | 21 --------------------- 2 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 sdk/python/ragflow_sdk/dataset.py diff --git a/docs/references/python_api_reference.md b/docs/references/python_api_reference.md index 075cd1a693d..281c7bcc24a 100644 --- a/docs/references/python_api_reference.md +++ b/docs/references/python_api_reference.md @@ -894,17 +894,12 @@ dataset = rag_object.list_datasets(name="ragflow") dataset = dataset[0] name = 'ragflow_test.txt' path = './test_data/ragflow_test.txt' -rag_object.create_document(dataset, name=name, blob=open(path, "rb").read()) -doc = dataset.list_documents(name=name) -doc = doc[0] -dataset.async_parse_documents([doc.id]) -for c in rag_object.retrieve(question="What's ragflow?", - dataset_ids=[dataset.id], document_ids=[doc.id], - page=1, page_size=30, similarity_threshold=0.2, - vector_similarity_weight=0.3, - top_k=1024 - ): - print(c) +documents =[{"displayed_name":"test_retrieve_chunks.txt","blob":open(path, "rb").read()}] +docs = dataset.upload_documents(documents) +doc = docs[0] +doc.add_chunk(content="This is a chunk addition test") +for c in rag_object.retrieve(dataset_ids=[dataset.id],document_ids=[doc.id]): + print(c) ``` --- diff --git a/sdk/python/ragflow_sdk/dataset.py b/sdk/python/ragflow_sdk/dataset.py deleted file mode 100644 index 5984aa62ffe..00000000000 --- a/sdk/python/ragflow_sdk/dataset.py +++ /dev/null @@ -1,21 +0,0 @@ -# -# Copyright 2024 The InfiniFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -class DataSet: - def __init__(self, user_key, dataset_url, uuid, name): - self.user_key = user_key - self.dataset_url = dataset_url - self.uuid = uuid - self.name = name