refactor: simplify document, segment, and child chunk retrieval in DatasetChildChunkApi for improved clarity
This commit is contained in:
parent
e146f1a08d
commit
3bfc24860a
@ -360,14 +360,12 @@ class DatasetChildChunkApi(DatasetApiResource):
|
|||||||
if not dataset:
|
if not dataset:
|
||||||
raise NotFound("Dataset not found.")
|
raise NotFound("Dataset not found.")
|
||||||
|
|
||||||
# check document
|
# get document
|
||||||
document_id = str(document_id)
|
document = DocumentService.get_document(dataset_id, document_id)
|
||||||
document = DocumentService.get_document(dataset.id, document_id)
|
|
||||||
if not document:
|
if not document:
|
||||||
raise NotFound("Document not found.")
|
raise NotFound("Document not found.")
|
||||||
|
|
||||||
# check segment
|
# get segment
|
||||||
segment_id = str(segment_id)
|
|
||||||
segment = SegmentService.get_segment_by_id(
|
segment = SegmentService.get_segment_by_id(
|
||||||
segment_id=segment_id,
|
segment_id=segment_id,
|
||||||
tenant_id=current_user.current_tenant_id
|
tenant_id=current_user.current_tenant_id
|
||||||
@ -375,8 +373,7 @@ class DatasetChildChunkApi(DatasetApiResource):
|
|||||||
if not segment:
|
if not segment:
|
||||||
raise NotFound("Segment not found.")
|
raise NotFound("Segment not found.")
|
||||||
|
|
||||||
# check child chunk
|
# get child chunk
|
||||||
child_chunk_id = str(child_chunk_id)
|
|
||||||
child_chunk = SegmentService.get_child_chunk_by_id(
|
child_chunk = SegmentService.get_child_chunk_by_id(
|
||||||
child_chunk_id=child_chunk_id,
|
child_chunk_id=child_chunk_id,
|
||||||
tenant_id=current_user.current_tenant_id
|
tenant_id=current_user.current_tenant_id
|
||||||
@ -391,12 +388,9 @@ class DatasetChildChunkApi(DatasetApiResource):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
child_chunk = SegmentService.update_child_chunk(
|
child_chunk = SegmentService.update_child_chunk(
|
||||||
ChildChunkUpdateArgs(content=args["content"]),
|
args.get("content"), child_chunk, segment, document, dataset
|
||||||
child_chunk,
|
|
||||||
segment,
|
|
||||||
document,
|
|
||||||
dataset
|
|
||||||
)
|
)
|
||||||
|
|
||||||
except ChildChunkIndexingServiceError as e:
|
except ChildChunkIndexingServiceError as e:
|
||||||
raise ChildChunkIndexingError(str(e))
|
raise ChildChunkIndexingError(str(e))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user