mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-06-04 11:14:10 +08:00
fix: fix file number limit error (#17848)
This commit is contained in:
parent
f04d52c044
commit
cc08451eb8
@ -3,6 +3,8 @@ from configs import dify_config
|
|||||||
HIDDEN_VALUE = "[__HIDDEN__]"
|
HIDDEN_VALUE = "[__HIDDEN__]"
|
||||||
UUID_NIL = "00000000-0000-0000-0000-000000000000"
|
UUID_NIL = "00000000-0000-0000-0000-000000000000"
|
||||||
|
|
||||||
|
DEFAULT_FILE_NUMBER_LIMITS = 3
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "webp", "gif", "svg"]
|
IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "webp", "gif", "svg"]
|
||||||
IMAGE_EXTENSIONS.extend([ext.upper() for ext in IMAGE_EXTENSIONS])
|
IMAGE_EXTENSIONS.extend([ext.upper() for ext in IMAGE_EXTENSIONS])
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ from uuid import uuid4
|
|||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
|
from constants import DEFAULT_FILE_NUMBER_LIMITS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import magic
|
import magic
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -108,7 +110,7 @@ def get_parameters_from_feature_dict(*, features_dict: Mapping[str, Any], user_i
|
|||||||
{
|
{
|
||||||
"image": {
|
"image": {
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
"number_limits": 3,
|
"number_limits": DEFAULT_FILE_NUMBER_LIMITS,
|
||||||
"detail": "high",
|
"detail": "high",
|
||||||
"transfer_methods": ["remote_url", "local_file"],
|
"transfer_methods": ["remote_url", "local_file"],
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from constants import DEFAULT_FILE_NUMBER_LIMITS
|
||||||
from core.file import FileUploadConfig
|
from core.file import FileUploadConfig
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ class FileUploadConfigManager:
|
|||||||
if file_upload_dict.get("enabled"):
|
if file_upload_dict.get("enabled"):
|
||||||
transform_methods = file_upload_dict.get("allowed_file_upload_methods", [])
|
transform_methods = file_upload_dict.get("allowed_file_upload_methods", [])
|
||||||
file_upload_dict["image_config"] = {
|
file_upload_dict["image_config"] = {
|
||||||
"number_limits": file_upload_dict.get("number_limits", 1),
|
"number_limits": file_upload_dict.get("number_limits", DEFAULT_FILE_NUMBER_LIMITS),
|
||||||
"transfer_methods": transform_methods,
|
"transfer_methods": transform_methods,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ from sqlalchemy import Float, Index, PrimaryKeyConstraint, func, text
|
|||||||
from sqlalchemy.orm import Mapped, Session, mapped_column
|
from sqlalchemy.orm import Mapped, Session, mapped_column
|
||||||
|
|
||||||
from configs import dify_config
|
from configs import dify_config
|
||||||
|
from constants import DEFAULT_FILE_NUMBER_LIMITS
|
||||||
from core.file import FILE_MODEL_IDENTITY, File, FileTransferMethod, FileType
|
from core.file import FILE_MODEL_IDENTITY, File, FileTransferMethod, FileType
|
||||||
from core.file import helpers as file_helpers
|
from core.file import helpers as file_helpers
|
||||||
from core.file.tool_file_parser import ToolFileParser
|
from core.file.tool_file_parser import ToolFileParser
|
||||||
@ -442,7 +443,7 @@ class AppModelConfig(Base):
|
|||||||
else {
|
else {
|
||||||
"image": {
|
"image": {
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
"number_limits": 3,
|
"number_limits": DEFAULT_FILE_NUMBER_LIMITS,
|
||||||
"detail": "high",
|
"detail": "high",
|
||||||
"transfer_methods": ["remote_url", "local_file"],
|
"transfer_methods": ["remote_url", "local_file"],
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ from sqlalchemy import Index, PrimaryKeyConstraint, func
|
|||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
import contexts
|
import contexts
|
||||||
from constants import HIDDEN_VALUE
|
from constants import DEFAULT_FILE_NUMBER_LIMITS, HIDDEN_VALUE
|
||||||
from core.helper import encrypter
|
from core.helper import encrypter
|
||||||
from core.variables import SecretVariable, Variable
|
from core.variables import SecretVariable, Variable
|
||||||
from factories import variable_factory
|
from factories import variable_factory
|
||||||
@ -186,7 +186,7 @@ class Workflow(Base):
|
|||||||
features = json.loads(self._features)
|
features = json.loads(self._features)
|
||||||
if features.get("file_upload", {}).get("image", {}).get("enabled", False):
|
if features.get("file_upload", {}).get("image", {}).get("enabled", False):
|
||||||
image_enabled = True
|
image_enabled = True
|
||||||
image_number_limits = int(features["file_upload"]["image"].get("number_limits", 1))
|
image_number_limits = int(features["file_upload"]["image"].get("number_limits", DEFAULT_FILE_NUMBER_LIMITS))
|
||||||
image_transfer_methods = features["file_upload"]["image"].get(
|
image_transfer_methods = features["file_upload"]["image"].get(
|
||||||
"transfer_methods", ["remote_url", "local_file"]
|
"transfer_methods", ["remote_url", "local_file"]
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user