mirror of
https://github.com/langgenius/dify.git
synced 2026-02-19 07:01:42 -05:00
Implement phase 1 of the file module migration by moving workflow-facing file primitives to core.workflow.file while keeping core.file as a temporary compatibility layer. What this commit changes - Add core.workflow.file package (constants/enums/models/helpers/file_manager/tool_file_parser). - Add protocol-based runtime binding in core.workflow.file.runtime and core.workflow.file.protocols. - Add application adapter core.app.workflow.file_runtime and bind runtime in extensions.ext_storage.init_app. - Bind runtime in tests via tests/conftest.py. - Migrate workflow-only imports from core.file.* to core.workflow.file.* across workflow runtime/nodes/entry/encoder and workflow node factory. - Update workflow unit tests to patch/import the new workflow file namespace. - Remove workflow-external-imports ignore_imports entries related to core.file from .importlinter. Compatibility guarantee for phase split - Keep core.file import path available in this phase by replacing core/file/*.py with forwarding bridge modules that re-export core.workflow.file symbols. - Preserve runtime behavior and isinstance(File) identity consistency while non-workflow modules are still on legacy import paths. Notes - This commit intentionally does not remove core.file. Full repository replacement and bridge removal are handled in phase 2.
58 lines
1.3 KiB
Python
58 lines
1.3 KiB
Python
from enum import StrEnum
|
|
|
|
|
|
class FileType(StrEnum):
|
|
IMAGE = "image"
|
|
DOCUMENT = "document"
|
|
AUDIO = "audio"
|
|
VIDEO = "video"
|
|
CUSTOM = "custom"
|
|
|
|
@staticmethod
|
|
def value_of(value):
|
|
for member in FileType:
|
|
if member.value == value:
|
|
return member
|
|
raise ValueError(f"No matching enum found for value '{value}'")
|
|
|
|
|
|
class FileTransferMethod(StrEnum):
|
|
REMOTE_URL = "remote_url"
|
|
LOCAL_FILE = "local_file"
|
|
TOOL_FILE = "tool_file"
|
|
DATASOURCE_FILE = "datasource_file"
|
|
|
|
@staticmethod
|
|
def value_of(value):
|
|
for member in FileTransferMethod:
|
|
if member.value == value:
|
|
return member
|
|
raise ValueError(f"No matching enum found for value '{value}'")
|
|
|
|
|
|
class FileBelongsTo(StrEnum):
|
|
USER = "user"
|
|
ASSISTANT = "assistant"
|
|
|
|
@staticmethod
|
|
def value_of(value):
|
|
for member in FileBelongsTo:
|
|
if member.value == value:
|
|
return member
|
|
raise ValueError(f"No matching enum found for value '{value}'")
|
|
|
|
|
|
class FileAttribute(StrEnum):
|
|
TYPE = "type"
|
|
SIZE = "size"
|
|
NAME = "name"
|
|
MIME_TYPE = "mime_type"
|
|
TRANSFER_METHOD = "transfer_method"
|
|
URL = "url"
|
|
EXTENSION = "extension"
|
|
RELATED_ID = "related_id"
|
|
|
|
|
|
class ArrayFileAttribute(StrEnum):
|
|
LENGTH = "length"
|