mirror of
https://github.com/langgenius/dify.git
synced 2026-10-29 18:07:39 +08:00
refactor(api): type indexing result with IndexingResultDict TypedDict (#34672)
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, Protocol
|
||||
from typing import Any, Protocol, TypedDict
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class IndexingResultDict(TypedDict):
|
||||
dataset_id: str
|
||||
dataset_name: str
|
||||
batch: Any
|
||||
document_id: str
|
||||
document_name: str
|
||||
created_at: float
|
||||
display_status: str
|
||||
|
||||
|
||||
class PreviewItem(BaseModel):
|
||||
content: str | None = Field(default=None)
|
||||
child_chunks: list[str] | None = Field(default=None)
|
||||
@@ -34,7 +44,7 @@ class IndexProcessorProtocol(Protocol):
|
||||
chunks: Mapping[str, Any],
|
||||
batch: Any,
|
||||
summary_index_setting: dict | None = None,
|
||||
) -> dict[str, Any]: ...
|
||||
) -> IndexingResultDict: ...
|
||||
|
||||
def get_preview_output(
|
||||
self, chunks: Any, dataset_id: str, document_id: str, chunk_structure: str, summary_index_setting: dict | None
|
||||
|
||||
Reference in New Issue
Block a user