mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 12:59:18 +08:00
fix: update core.file imports to core.workflow.file after merge
The File class and related modules were moved from core.file to core.workflow.file in the sandboxed-agent branch. This commit updates all remaining references including test mock/patch paths, Switch component defaultValue→value changes, and account setting tab constant updates. Made-with: Cursor
This commit is contained in:
parent
89b76d6c33
commit
a883b74272
35
MERGE_LOG.md
Normal file
35
MERGE_LOG.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Merge Log: sandboxed-agent-rebase ← main
|
||||
|
||||
## Overview
|
||||
|
||||
| Segment | Target Commit | Commits | Description | Status |
|
||||
|---------|--------------|---------|-------------|--------|
|
||||
| 1 | `657eeb65` | 50 | Early changes: deps, Switch组件, 基础重构 | ⏳ |
|
||||
| 2 | `9c339239` | 129 | Mid refactors: model_runtime 等 | ⬚ |
|
||||
| 3 | `92bde350` | 56 | dify_graph 大迁移 | ⬚ |
|
||||
| 4 | `fb41b215` | 165 | Post-backend refactors | ⬚ |
|
||||
| 5 | `main HEAD` | 103 | Final changes | ⬚ |
|
||||
|
||||
- **Base commit**: `98466e2d`
|
||||
- **Branch**: `sandboxed-agent-rebase`
|
||||
- **Total main commits**: 503
|
||||
|
||||
---
|
||||
|
||||
## Segment 1: Early Changes (50 commits → `657eeb65`)
|
||||
|
||||
**Started**: <!-- will fill -->
|
||||
|
||||
### Merge Command
|
||||
```bash
|
||||
git merge 657eeb65
|
||||
```
|
||||
|
||||
### Conflicts
|
||||
<!-- will fill after merge attempt -->
|
||||
|
||||
### Resolution
|
||||
<!-- will fill -->
|
||||
|
||||
### Test Results
|
||||
<!-- will fill after tests -->
|
||||
@ -7,7 +7,7 @@ from controllers.cli_api.dify_cli.wraps import get_cli_user_tenant, plugin_data
|
||||
from controllers.cli_api.wraps import cli_api_only
|
||||
from controllers.console.wraps import setup_required
|
||||
from core.app.entities.app_invoke_entities import InvokeFrom
|
||||
from core.file.helpers import get_signed_file_url_for_plugin
|
||||
from core.workflow.file.helpers import get_signed_file_url_for_plugin
|
||||
from core.plugin.backwards_invocation.app import PluginAppBackwardsInvocation
|
||||
from core.plugin.backwards_invocation.base import BaseBackwardsInvocationResponse
|
||||
from core.plugin.backwards_invocation.model import PluginModelBackwardsInvocation
|
||||
|
||||
@ -37,7 +37,7 @@ from controllers.console.wraps import (
|
||||
only_edition_cloud,
|
||||
setup_required,
|
||||
)
|
||||
from core.file import helpers as file_helpers
|
||||
from core.workflow.file import helpers as file_helpers
|
||||
from extensions.ext_database import db
|
||||
from fields.member_fields import Account as AccountResponse
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
|
||||
@ -8,7 +8,7 @@ from core.agent.entities import AgentEntity, AgentLog, AgentResult
|
||||
from core.agent.patterns.strategy_factory import StrategyFactory
|
||||
from core.app.apps.base_app_queue_manager import PublishFrom
|
||||
from core.app.entities.queue_entities import QueueAgentThoughtEvent, QueueMessageEndEvent, QueueMessageFileEvent
|
||||
from core.file import file_manager
|
||||
from core.workflow.file import file_manager
|
||||
from core.model_runtime.entities import (
|
||||
AssistantPromptMessage,
|
||||
LLMResult,
|
||||
|
||||
@ -10,7 +10,7 @@ from collections.abc import Callable, Generator
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from core.agent.entities import AgentLog, AgentResult, ExecutionContext
|
||||
from core.file import File
|
||||
from core.workflow.file import File
|
||||
from core.model_manager import ModelInstance
|
||||
from core.model_runtime.entities import (
|
||||
AssistantPromptMessage,
|
||||
|
||||
@ -12,7 +12,7 @@ from collections.abc import Generator
|
||||
from typing import Any, Union
|
||||
|
||||
from core.agent.entities import AgentLog, AgentResult
|
||||
from core.file import File
|
||||
from core.workflow.file import File
|
||||
from core.model_runtime.entities import (
|
||||
AssistantPromptMessage,
|
||||
LLMResult,
|
||||
|
||||
@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any, Union
|
||||
|
||||
from core.agent.entities import AgentLog, AgentResult, AgentScratchpadUnit, ExecutionContext
|
||||
from core.agent.output_parser.cot_output_parser import CotAgentOutputParser
|
||||
from core.file import File
|
||||
from core.workflow.file import File
|
||||
from core.model_manager import ModelInstance
|
||||
from core.model_runtime.entities import (
|
||||
AssistantPromptMessage,
|
||||
|
||||
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from core.agent.entities import AgentEntity, ExecutionContext
|
||||
from core.file.models import File
|
||||
from core.workflow.file.models import File
|
||||
from core.model_manager import ModelInstance
|
||||
from core.model_runtime.entities.model_entities import ModelFeature
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ This module provides utilities to:
|
||||
from collections.abc import Callable, Mapping, Sequence
|
||||
from typing import Any, cast
|
||||
|
||||
from core.file import File
|
||||
from core.workflow.file import File
|
||||
from core.variables.segments import ArrayFileSegment, FileSegment
|
||||
|
||||
FILE_PATH_FORMAT = "file-path"
|
||||
|
||||
@ -20,7 +20,7 @@ from typing import cast
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from core.file import file_manager
|
||||
from core.workflow.file import file_manager
|
||||
from core.memory.base import BaseMemory
|
||||
from core.model_manager import ModelInstance
|
||||
from core.model_runtime.entities import (
|
||||
|
||||
@ -7,7 +7,7 @@ import os
|
||||
import shlex
|
||||
from types import TracebackType
|
||||
|
||||
from core.file import File, FileTransferMethod, FileType
|
||||
from core.workflow.file import File, FileTransferMethod, FileType
|
||||
from core.sandbox.sandbox import Sandbox
|
||||
from core.session.cli_api import CliApiSession, CliApiSessionManager, CliContext
|
||||
from core.skill.entities import ToolAccessPolicy
|
||||
|
||||
@ -3,7 +3,7 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from core.file import File
|
||||
from core.workflow.file import File
|
||||
|
||||
|
||||
class ToolResultStatus(StrEnum):
|
||||
|
||||
@ -5,7 +5,7 @@ from collections.abc import Mapping, Sequence
|
||||
from pathlib import PurePosixPath
|
||||
from typing import Any, cast
|
||||
|
||||
from core.file import File, FileTransferMethod
|
||||
from core.workflow.file import File, FileTransferMethod
|
||||
from core.sandbox.bash.session import SANDBOX_READY_TIMEOUT
|
||||
from core.variables import ArrayFileSegment
|
||||
from core.variables.segments import ArrayStringSegment, FileSegment
|
||||
|
||||
@ -5,7 +5,7 @@ from typing import Annotated, Any, Literal, TypeAlias
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
|
||||
|
||||
from core.agent.entities import AgentLog, AgentResult
|
||||
from core.file import File
|
||||
from core.workflow.file import File
|
||||
from core.model_runtime.entities import ImagePromptMessageContent, LLMMode
|
||||
from core.model_runtime.entities.llm_entities import LLMUsage
|
||||
from core.prompt.entities.advanced_prompt_entities import ChatModelMessage, CompletionModelPromptTemplate, MemoryConfig
|
||||
|
||||
@ -388,7 +388,7 @@ def restore_multimodal_content_in_messages(messages: Sequence[PromptMessage]) ->
|
||||
Returns:
|
||||
List of PromptMessages with restored multimodal content
|
||||
"""
|
||||
from core.file import file_manager
|
||||
from core.workflow.file import file_manager
|
||||
|
||||
return [_restore_message_content(msg, file_manager) for msg in messages]
|
||||
|
||||
|
||||
@ -365,7 +365,7 @@ class TestOrganizeUserQuery:
|
||||
|
||||
def test_query_with_files(self, mock_runner):
|
||||
"""Test organizing a query with files."""
|
||||
from core.file.models import File
|
||||
from core.workflow.file.models import File
|
||||
|
||||
mock_file = MagicMock(spec=File)
|
||||
mock_runner.files = [mock_file]
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from core.file import File, FileTransferMethod, FileType
|
||||
from core.file.file_manager import (
|
||||
from core.workflow.file import File, FileTransferMethod, FileType
|
||||
from core.workflow.file.file_manager import (
|
||||
_encode_file_ref,
|
||||
restore_multimodal_content,
|
||||
to_prompt_message_content,
|
||||
@ -51,8 +51,8 @@ class TestEncodeFileRef:
|
||||
class TestToPromptMessageContent:
|
||||
"""Tests for to_prompt_message_content function with file_ref field."""
|
||||
|
||||
@patch("core.file.file_manager.dify_config")
|
||||
@patch("core.file.file_manager._get_encoded_string")
|
||||
@patch("core.workflow.file.file_manager.dify_config")
|
||||
@patch("core.workflow.file.file_manager._get_encoded_string")
|
||||
def test_includes_file_ref(self, mock_get_encoded, mock_config):
|
||||
"""Generated content should include file_ref field."""
|
||||
mock_config.MULTIMODAL_SEND_FORMAT = "base64"
|
||||
@ -120,9 +120,9 @@ class TestRestoreMultimodalContent:
|
||||
|
||||
assert result.url == "https://example.com/image.png"
|
||||
|
||||
@patch("core.file.file_manager.dify_config")
|
||||
@patch("core.file.file_manager._build_file_from_ref")
|
||||
@patch("core.file.file_manager._to_url")
|
||||
@patch("core.workflow.file.file_manager.dify_config")
|
||||
@patch("core.workflow.file.file_manager._build_file_from_ref")
|
||||
@patch("core.workflow.file.file_manager._to_url")
|
||||
def test_restores_url_from_file_ref(self, mock_to_url, mock_build_file, mock_config):
|
||||
"""Content should be restored from file_ref when url is empty (url mode)."""
|
||||
mock_config.MULTIMODAL_SEND_FORMAT = "url"
|
||||
@ -143,9 +143,9 @@ class TestRestoreMultimodalContent:
|
||||
assert result.url == "https://restored-url.com/image.png"
|
||||
mock_build_file.assert_called_once()
|
||||
|
||||
@patch("core.file.file_manager.dify_config")
|
||||
@patch("core.file.file_manager._build_file_from_ref")
|
||||
@patch("core.file.file_manager._get_encoded_string")
|
||||
@patch("core.workflow.file.file_manager.dify_config")
|
||||
@patch("core.workflow.file.file_manager._build_file_from_ref")
|
||||
@patch("core.workflow.file.file_manager._get_encoded_string")
|
||||
def test_restores_base64_from_file_ref(self, mock_get_encoded, mock_build_file, mock_config):
|
||||
"""Content should be restored as base64 when in base64 mode."""
|
||||
mock_config.MULTIMODAL_SEND_FORMAT = "base64"
|
||||
|
||||
@ -4,7 +4,7 @@ Unit tests for sandbox file path detection and conversion.
|
||||
|
||||
import pytest
|
||||
|
||||
from core.file import File, FileTransferMethod, FileType
|
||||
from core.workflow.file import File, FileTransferMethod, FileType
|
||||
from core.llm_generator.output_parser.file_ref import (
|
||||
FILE_PATH_DESCRIPTION_SUFFIX,
|
||||
FILE_PATH_FORMAT,
|
||||
|
||||
@ -318,7 +318,7 @@ class TestBuildContext:
|
||||
class TestRestoreMultimodalContentInMessages:
|
||||
"""Tests for restore_multimodal_content_in_messages function."""
|
||||
|
||||
@patch("core.file.file_manager.restore_multimodal_content")
|
||||
@patch("core.workflow.file.file_manager.restore_multimodal_content")
|
||||
def test_restores_multimodal_content(self, mock_restore):
|
||||
"""Should restore multimodal content in messages."""
|
||||
# Setup mock
|
||||
|
||||
@ -109,9 +109,9 @@ def test_stream_llm_events_no_reasoning_results_in_empty_sequence():
|
||||
|
||||
|
||||
def test_serialize_tool_call_strips_files_to_ids():
|
||||
file_cls = pytest.importorskip("core.file").File
|
||||
file_type = pytest.importorskip("core.file.enums").FileType
|
||||
transfer_method = pytest.importorskip("core.file.enums").FileTransferMethod
|
||||
file_cls = pytest.importorskip("core.workflow.file").File
|
||||
file_type = pytest.importorskip("core.workflow.file.enums").FileType
|
||||
transfer_method = pytest.importorskip("core.workflow.file.enums").FileTransferMethod
|
||||
|
||||
file_with_id = file_cls(
|
||||
id="f1",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user