mirror of
https://github.com/langgenius/dify.git
synced 2026-04-15 18:06:36 +08:00
33 lines
800 B
Python
33 lines
800 B
Python
"""
|
|
Serialization helpers for Service API knowledge pipeline endpoints.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, TypedDict
|
|
|
|
if TYPE_CHECKING:
|
|
from models.model import UploadFile
|
|
|
|
|
|
class UploadFileDict(TypedDict):
|
|
id: str
|
|
name: str
|
|
size: int
|
|
extension: str
|
|
mime_type: str | None
|
|
created_by: str
|
|
created_at: str | None
|
|
|
|
|
|
def serialize_upload_file(upload_file: UploadFile) -> UploadFileDict:
|
|
return {
|
|
"id": upload_file.id,
|
|
"name": upload_file.name,
|
|
"size": upload_file.size,
|
|
"extension": upload_file.extension,
|
|
"mime_type": upload_file.mime_type,
|
|
"created_by": upload_file.created_by,
|
|
"created_at": upload_file.created_at.isoformat() if upload_file.created_at else None,
|
|
}
|