mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-04-22 22:20:07 +08:00

### What problem does this PR solve? Close #3873 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
29 lines
800 B
Python
29 lines
800 B
Python
from .base import Base
|
|
|
|
|
|
class Chunk(Base):
|
|
def __init__(self, rag, res_dict):
|
|
self.id = ""
|
|
self.content = ""
|
|
self.important_keywords = []
|
|
self.questions = []
|
|
self.create_time = ""
|
|
self.create_timestamp = 0.0
|
|
self.dataset_id = None
|
|
self.document_name = ""
|
|
self.document_id = ""
|
|
self.available = True
|
|
for k in list(res_dict.keys()):
|
|
if k not in self.__dict__:
|
|
res_dict.pop(k)
|
|
super().__init__(rag, res_dict)
|
|
|
|
|
|
def update(self,update_message:dict):
|
|
res = self.put(f"/datasets/{self.dataset_id}/documents/{self.document_id}/chunks/{self.id}",update_message)
|
|
res = res.json()
|
|
if res.get("code") != 0 :
|
|
raise Exception(res["message"])
|
|
|
|
|