mirror of
https://github.com/langgenius/dify.git
synced 2025-12-25 01:00:42 -05:00
fix: allow optional config parameter and conditionally include message file ID (#26960)
This commit is contained in:
@@ -21,7 +21,7 @@ def build_from_message_files(
|
||||
*,
|
||||
message_files: Sequence["MessageFile"],
|
||||
tenant_id: str,
|
||||
config: FileUploadConfig,
|
||||
config: FileUploadConfig | None = None,
|
||||
) -> Sequence[File]:
|
||||
results = [
|
||||
build_from_message_file(message_file=file, tenant_id=tenant_id, config=config)
|
||||
@@ -35,15 +35,18 @@ def build_from_message_file(
|
||||
*,
|
||||
message_file: "MessageFile",
|
||||
tenant_id: str,
|
||||
config: FileUploadConfig,
|
||||
config: FileUploadConfig | None,
|
||||
):
|
||||
mapping = {
|
||||
"transfer_method": message_file.transfer_method,
|
||||
"url": message_file.url,
|
||||
"id": message_file.id,
|
||||
"type": message_file.type,
|
||||
}
|
||||
|
||||
# Only include id if it exists (message_file has been committed to DB)
|
||||
if message_file.id:
|
||||
mapping["id"] = message_file.id
|
||||
|
||||
# Set the correct ID field based on transfer method
|
||||
if message_file.transfer_method == FileTransferMethod.TOOL_FILE:
|
||||
mapping["tool_file_id"] = message_file.upload_file_id
|
||||
|
||||
Reference in New Issue
Block a user