Kevin Hu commited on
Commit
826a9e4
·
1 Parent(s): c9b5e68

Fix Python SDK example error. (#4263)

Browse files

### What problem does this PR solve?

#4253
### Type of change

- [x] Documentation Update

docs/references/python_api_reference.md CHANGED
@@ -894,17 +894,12 @@ dataset = rag_object.list_datasets(name="ragflow")
894
  dataset = dataset[0]
895
  name = 'ragflow_test.txt'
896
  path = './test_data/ragflow_test.txt'
897
- rag_object.create_document(dataset, name=name, blob=open(path, "rb").read())
898
- doc = dataset.list_documents(name=name)
899
- doc = doc[0]
900
- dataset.async_parse_documents([doc.id])
901
- for c in rag_object.retrieve(question="What's ragflow?",
902
- dataset_ids=[dataset.id], document_ids=[doc.id],
903
- page=1, page_size=30, similarity_threshold=0.2,
904
- vector_similarity_weight=0.3,
905
- top_k=1024
906
- ):
907
- print(c)
908
  ```
909
 
910
  ---
 
894
  dataset = dataset[0]
895
  name = 'ragflow_test.txt'
896
  path = './test_data/ragflow_test.txt'
897
+ documents =[{"displayed_name":"test_retrieve_chunks.txt","blob":open(path, "rb").read()}]
898
+ docs = dataset.upload_documents(documents)
899
+ doc = docs[0]
900
+ doc.add_chunk(content="This is a chunk addition test")
901
+ for c in rag_object.retrieve(dataset_ids=[dataset.id],document_ids=[doc.id]):
902
+ print(c)
 
 
 
 
 
903
  ```
904
 
905
  ---
sdk/python/ragflow_sdk/dataset.py DELETED
@@ -1,21 +0,0 @@
1
- #
2
- # Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- class DataSet:
17
- def __init__(self, user_key, dataset_url, uuid, name):
18
- self.user_key = user_key
19
- self.dataset_url = dataset_url
20
- self.uuid = uuid
21
- self.name = name