How to Call Dify Workflows Through Tools
Dify is a powerful workflow automation tool that can be used to create various automated tasks. ConsoleX supports calling Dify workflows through tools to extend the capabilities of large models, enabling them to complete more complex tasks. Dify workflows can be created and used through the official website or self-hosted methods.
Basic Steps
- Create a workflow in Dify and publish it. All workflows on Dify use the same API server URL address, which will be used as the tool's function interface URL in the future. Then click to create an API key for the workflow for verification. The variables output in the workflow's end node will be used as the tool's return result.
- In ConsoleX AI, click Tools and then click Add Tool. In the JSON Schema description of the tool definition, enter the JSON Schema description corresponding to the input parameters in the Dify workflow. The description format is consistent with the OpenAI standard tool description format. You can refer to examples or use AI assistance to generate.
- Next, click to select initiate tool calling and choose either GET or POST method, then select Dify for the tool function interface type, and fill the API server URL from the first step into the tool function interface URL. Enter the API key created in the first step into the URL Key in the tool configuration. Select one of the return content processing methods according to the situation, then click Save. The tool corresponding to the Dify workflow is created.
- Finally, add this tool to the conversation as needed. The large model will automatically call the Dify workflow based on the tool's description and input parameters, just like other tools, and return the results.
Example Workflow
The following is a Dify example workflow for weather forecasting. You can right-click to save it locally and then import it into Dify's workspace.
Notes
- The tool's JSON Schema description needs to correspond to the input parameters in the Dify workflow, otherwise the large model cannot correctly call the Dify workflow. You can view the debugging information of workflow calls in Dify's run history.
- Workflows in Dify need to be published before they can be called. They cannot be called in an unpublished state.