mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Complete DataSet SDK implementation (#2171)
### What problem does this PR solve? Complete DataSet SDK implementation #1102 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: Feiue <10215101452@stu.ecun.edu.cn>
This commit is contained in:
@ -24,14 +24,6 @@ class DataSet(Base):
|
||||
self.parse_method = "naive"
|
||||
self.parser_config = None
|
||||
for k in list(res_dict.keys()):
|
||||
if k == "embd_id":
|
||||
res_dict["embedding_model"] = res_dict[k]
|
||||
if k == "parser_id":
|
||||
res_dict['parse_method'] = res_dict[k]
|
||||
if k == "doc_num":
|
||||
res_dict["document_count"] = res_dict[k]
|
||||
if k == "chunk_num":
|
||||
res_dict["chunk_count"] = res_dict[k]
|
||||
if k not in self.__dict__:
|
||||
res_dict.pop(k)
|
||||
super().__init__(rag, res_dict)
|
||||
@ -39,9 +31,9 @@ class DataSet(Base):
|
||||
def save(self) -> bool:
|
||||
res = self.post('/dataset/save',
|
||||
{"id": self.id, "name": self.name, "avatar": self.avatar, "tenant_id": self.tenant_id,
|
||||
"description": self.description, "language": self.language, "embd_id": self.embedding_model,
|
||||
"description": self.description, "language": self.language, "embedding_model": self.embedding_model,
|
||||
"permission": self.permission,
|
||||
"doc_num": self.document_count, "chunk_num": self.chunk_count, "parser_id": self.parse_method,
|
||||
"document_count": self.document_count, "chunk_count": self.chunk_count, "parse_method": self.parse_method,
|
||||
"parser_config": self.parser_config.to_json()
|
||||
})
|
||||
res = res.json()
|
||||
|
||||
@ -52,7 +52,7 @@ class RAGFlow:
|
||||
res = self.post("/dataset/save",
|
||||
{"name": name, "avatar": avatar, "description": description, "language": language,
|
||||
"permission": permission,
|
||||
"doc_num": document_count, "chunk_num": chunk_count, "parser_id": parse_method,
|
||||
"document_count": document_count, "chunk_count": chunk_count, "parse_method": parse_method,
|
||||
"parser_config": parser_config
|
||||
}
|
||||
)
|
||||
@ -61,7 +61,7 @@ class RAGFlow:
|
||||
return DataSet(self, res["data"])
|
||||
raise Exception(res["retmsg"])
|
||||
|
||||
def list_datasets(self, page: int = 1, page_size: int = 150, orderby: str = "create_time", desc: bool = True) -> \
|
||||
def list_datasets(self, page: int = 1, page_size: int = 1024, orderby: str = "create_time", desc: bool = True) -> \
|
||||
List[DataSet]:
|
||||
res = self.get("/dataset/list", {"page": page, "page_size": page_size, "orderby": orderby, "desc": desc})
|
||||
res = res.json()
|
||||
|
||||
Reference in New Issue
Block a user