-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
workflow api how to upload pdf? #9839
Comments
Hello, @llama-factory! I'm here to help you with any bugs, questions, or contributions you need assistance with. Let's work together to solve any issues you encounter. To upload a PDF file using the Dify workflow API in your backend service, you can follow these steps:
Here is a simplified code representation of the steps: # Assuming you have a workflow setup with nodes
# Step 1: Add file variable in the "Start" node
file_variable = add_file_variable(node="Start", type="Single File", name="pdf")
# Step 2: Add Document Extractor node
document_extractor_node = add_document_extractor(input_variable=file_variable)
# Step 3: Process the extracted content in LLM node
llm_node = add_llm_node(system_prompt=document_extractor_node.output_variable)
# Step 4: Configure the end node
end_node = configure_end_node(output_variable=llm_node.output_variable) This setup allows your backend service to handle PDF file uploads and process their content using the workflow API, enabling interactions such as ChatPDF [1]. Additionally, for the specific API endpoint to upload files, you can use the following:
This endpoint allows you to create a new document through a file based on existing Knowledge [2]. |
Do you mean that if the workflow API I want to access requires file upload, do I first need to use the interface https://api.dify.ai/v1/datasets to upload a PDF file? But I don't want to create datasets. I just want to upload a temporary file for this access only. |
To upload a temporary file in Dify without creating a dataset, you can use the file upload feature in the workflow. Here's how you can handle temporary file uploads:
These steps allow you to handle temporary file uploads without the need to create a dataset. This method is suitable for scenarios where you need to process files temporarily during a workflow execution [1]. |
Yes, I know. I have already built a workflow using this method. But what I don't know now is how to pass a PDF file when using the API of this workflow. |
To pass a PDF file when using the API of a workflow in Dify, follow these steps:
Here's an example of how to structure your API request using cURL: curl -X POST '${props.appDetail.api_base_url}/workflows/run' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"inputs": {},
"response_mode": "streaming",
"user": "abc-123",
"files": [
{
"type": "document",
"transfer_method": "local_file",
"upload_file_id": "your_upload_file_id"
}
]
}' Make sure to replace |
How can I obtain the upload_file_id? @dosu @crazywoola |
Self Checks
Provide a description of requested docs changes
After setting up a workflow that requires uploading a PDF file, I don't know how to use the API to transfer the PDF file. I want to use this workflow in my backend service. I have consulted documents including issues for a long time, but still haven't found out how to access this workflow using the API. Please help.
The text was updated successfully, but these errors were encountered: