mirror of https://github.com/langgenius/dify.git
fix: fix import errors caused by dify_graph.
This commit is contained in:
parent
a0d5d83787
commit
680d230d27
|
|
@ -7,7 +7,6 @@ from enum import StrEnum
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import yaml # type: ignore
|
import yaml # type: ignore
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
|
||||||
from packaging import version
|
from packaging import version
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
@ -15,7 +14,8 @@ from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from core.helper import ssrf_proxy
|
from core.helper import ssrf_proxy
|
||||||
from core.plugin.entities.plugin import PluginDependency
|
from core.plugin.entities.plugin import PluginDependency
|
||||||
from dify_graph.enums import NodeType
|
from dify_graph.enums import BuiltinNodeTypes
|
||||||
|
from dify_graph.model_runtime.utils.encoders import jsonable_encoder
|
||||||
from extensions.ext_redis import redis_client
|
from extensions.ext_redis import redis_client
|
||||||
from factories import variable_factory
|
from factories import variable_factory
|
||||||
from models import Account
|
from models import Account
|
||||||
|
|
@ -34,8 +34,8 @@ CURRENT_DSL_VERSION = "0.1.0"
|
||||||
|
|
||||||
# List of node types that are not allowed in snippets
|
# List of node types that are not allowed in snippets
|
||||||
FORBIDDEN_NODE_TYPES = [
|
FORBIDDEN_NODE_TYPES = [
|
||||||
NodeType.START.value, # "start"
|
BuiltinNodeTypes.START,
|
||||||
NodeType.HUMAN_INPUT.value, # "human-input"
|
BuiltinNodeTypes.HUMAN_INPUT,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -499,17 +499,17 @@ class SnippetDslService:
|
||||||
if not node_data:
|
if not node_data:
|
||||||
continue
|
continue
|
||||||
data_type = node_data.get("type", "")
|
data_type = node_data.get("type", "")
|
||||||
if data_type == NodeType.KNOWLEDGE_RETRIEVAL:
|
if data_type == BuiltinNodeTypes.KNOWLEDGE_RETRIEVAL:
|
||||||
dataset_ids = node_data.get("dataset_ids", [])
|
dataset_ids = node_data.get("dataset_ids", [])
|
||||||
node["data"]["dataset_ids"] = [
|
node["data"]["dataset_ids"] = [
|
||||||
self._encrypt_dataset_id(dataset_id=dataset_id, tenant_id=snippet.tenant_id)
|
self._encrypt_dataset_id(dataset_id=dataset_id, tenant_id=snippet.tenant_id)
|
||||||
for dataset_id in dataset_ids
|
for dataset_id in dataset_ids
|
||||||
]
|
]
|
||||||
# filter credential id from tool node
|
# filter credential id from tool node
|
||||||
if not include_secret and data_type == NodeType.TOOL:
|
if not include_secret and data_type == BuiltinNodeTypes.TOOL:
|
||||||
node_data.pop("credential_id", None)
|
node_data.pop("credential_id", None)
|
||||||
# filter credential id from agent node
|
# filter credential id from agent node
|
||||||
if not include_secret and data_type == NodeType.AGENT:
|
if not include_secret and data_type == BuiltinNodeTypes.AGENT:
|
||||||
for tool in node_data.get("agent_parameters", {}).get("tools", {}).get("value", []):
|
for tool in node_data.get("agent_parameters", {}).get("tools", {}).get("value", []):
|
||||||
tool.pop("credential_id", None)
|
tool.pop("credential_id", None)
|
||||||
|
|
||||||
|
|
@ -552,13 +552,13 @@ class SnippetDslService:
|
||||||
if not node_data:
|
if not node_data:
|
||||||
continue
|
continue
|
||||||
data_type = node_data.get("type", "")
|
data_type = node_data.get("type", "")
|
||||||
if data_type == NodeType.TOOL:
|
if data_type == BuiltinNodeTypes.TOOL:
|
||||||
tool_config = node_data.get("tool_configurations", {})
|
tool_config = node_data.get("tool_configurations", {})
|
||||||
provider_type = tool_config.get("provider_type")
|
provider_type = tool_config.get("provider_type")
|
||||||
provider_name = tool_config.get("provider")
|
provider_name = tool_config.get("provider")
|
||||||
if provider_type and provider_name:
|
if provider_type and provider_name:
|
||||||
dependencies.append(f"{provider_name}/{provider_name}")
|
dependencies.append(f"{provider_name}/{provider_name}")
|
||||||
elif data_type == NodeType.AGENT:
|
elif data_type == BuiltinNodeTypes.AGENT:
|
||||||
agent_parameters = node_data.get("agent_parameters", {})
|
agent_parameters = node_data.get("agent_parameters", {})
|
||||||
tools = agent_parameters.get("tools", {}).get("value", [])
|
tools = agent_parameters.get("tools", {}).get("value", [])
|
||||||
for tool in tools:
|
for tool in tools:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue