move file chunk size check ahead

This commit is contained in:
Bowen Liang 2025-08-10 14:02:00 +08:00
parent e115340e83
commit 7f2e18be0c
1 changed files with 5 additions and 5 deletions

View File

@ -150,6 +150,11 @@ class PluginToolManager(BasePluginClient):
meta=resp.meta,
)
else:
# Check if single chunk is too large (8KB limit)
if len(blob_data) > 8192:
# Skip yielding this message
raise ValueError("File chunk is too large which reached the limit of 8KB")
# Check if file is too large
if files[chunk_id].bytes_written + len(blob_data) > dify_config.TOOL_FILE_MAX_SIZE:
# Delete the file if it's too large
@ -157,11 +162,6 @@ class PluginToolManager(BasePluginClient):
# Skip yielding this message
raise ValueError("File is too large which reached the limit of 30MB")
# Check if single chunk is too large (8KB limit)
if len(blob_data) > 8192:
# Skip yielding this message
raise ValueError("File chunk is too large which reached the limit of 8KB")
# Append the blob data to the buffer
files[chunk_id].data[
files[chunk_id].bytes_written : files[chunk_id].bytes_written + len(blob_data)