Skip to content
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

Custom API tool: OpenAPI specification to support file uploads, and it can be used in workflow #9605

Open
4 of 5 tasks
Sakura4036 opened this issue Oct 22, 2024 · 2 comments
Labels
🔨 feat:tools Tools for agent, function call related stuff.

Comments

@Sakura4036
Copy link
Contributor

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

I developed a pdf file parsing service with marker. The service accepts a file or files as a parameter. When publishing this as a custom tool, does it support file uploads in Dify v0.10.0? If it does support file uploads, how should I write the OpenAPI specification and enables the tool to use customized files variables as parameters in the workflow?

2. Additional context or comments

my tool schema now

...
  "paths": {
    "/batch_convert": {
      "post": {
        "summary": "批量转换PDF文件为Markdown",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "description": "PDF文件列表"
                  }
                }
              }
            }
          }
...

dify workflow

However, in the workflow, the files parameter only accepts String, causing it to not use the sys.files or files variables

image

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
@WQL782795
Copy link

I encountered the same issue: The problem can be simply described as follows: when creating a custom tool using OpenAI-swagger, specifying type: array does not actually take effect, and it still behaves as string.

Here is the swagger content. Some information has been redacted and will need to be replaced for verification.

openapi: "3.1.0"
info:
  title: "OTMS接口示例"
  description: "用于查询割接方案的简单示例"
  version: "v1.0.0"
servers:
  - url: "http://xxxx:xxxxx/api"
    description: "OTMS接口地址"
paths:
  /otms-proxy/serviceAgent/rest/service-zhwg-cutover-stat/foreign/cnsiPublish/cnsi/changePlan:
    post:
      tags:
        - "otms接口"
      summary: "查询割接方案接口"
      operationId: "changePlanUsingPOST"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                cutoverNoList:
                  type: "array"
                  items:
                    type: "string"
                  description: "割接编号列表,数组形式,例如 ['110303', '110305']"
                traceId:
                  type: "string"
                  description: "随机跟踪ID"
              required:
                - cutoverNoList
                - traceId
      responses:
        200:
          description: "请求成功"
        201:
          description: "资源已创建"
        401:
          description: "未授权"
        403:
          description: "禁止访问"
        404:
          description: "未找到资源"
image

@zolgear
Copy link

zolgear commented Nov 22, 2024

Duplicated #9322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 feat:tools Tools for agent, function call related stuff.
Projects
None yet
Development

No branches or pull requests

3 participants