mirror of
https://github.com/langgenius/dify.git
synced 2026-05-07 02:46:32 +08:00
Co-authored-by: jyong <718720800@qq.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hj24 <mambahj24@gmail.com> Co-authored-by: hj24 <huangjian@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
18 lines
503 B
Python
18 lines
503 B
Python
from flask_restx import fields
|
|
|
|
from graphon.file import File
|
|
|
|
|
|
class FilesContainedField(fields.Raw):
|
|
def format(self, value):
|
|
return self._format_file_object(value)
|
|
|
|
def _format_file_object(self, v):
|
|
if isinstance(v, File):
|
|
return v.model_dump()
|
|
if isinstance(v, dict):
|
|
return {k: self._format_file_object(vv) for k, vv in v.items()}
|
|
if isinstance(v, list):
|
|
return [self._format_file_object(vv) for vv in v]
|
|
return v
|