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

Example Response of External Knowledge API #312

Open
zolgear opened this issue Oct 9, 2024 · 1 comment · May be fixed by #319
Open

Example Response of External Knowledge API #312

zolgear opened this issue Oct 9, 2024 · 1 comment · May be fixed by #319
Labels
bug Something isn't working

Comments

@zolgear
Copy link

zolgear commented Oct 9, 2024

https://docs.dify.ai/guides/knowledge-base/external-knowledge-api-documentation

en\guides\knowledge-base\external-knowledge-api-documentation.md


There is an issue with the JSON response generated by Swagger.

{
  "records": {
    "content": "text",
    "score": 0,
    "title": "text",
    "metadata": "text"
  }
}

The records should be an array, but it is represented with { }. If implemented as is, it will result in a "500 Internal Server Error: 'str' object has no attribute 'get'" during the hit test in /app/api/controllers/console/datasets/external.py.

Fix:

{
  "records": [
    {
      "content": "text",
      "score": 0,
      "title": "text",
      "metadata": "text"
    }
  ]
}

Can you modify en\.gitbook\assets\Dify-test.openapi.json to fix it?

@dosubot dosubot bot added the bug Something isn't working label Oct 9, 2024
Copy link

dosubot bot commented Oct 9, 2024

To fix the issue with the records field in the Dify-test.openapi.json file, you need to modify the schema to ensure records is an array. Here's how you can update it:

Change the records field definition from an object to an array of objects:

"records": {
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "content": {
        "type": "string",
        "description": "Contains a chunk of text from a data source in the knowledge base."
      },
      "score": {
        "type": "number",
        "format": "float",
        "description": "The score of relevance of the result to the query, scope: 0~1"
      },
      "title": {
        "type": "string",
        "description": "Document title"
      },
      "metadata": {
        "type": "string",
        "description": "Contains metadata attributes and their values for the document in the data source."
      }
    },
    "required": ["content", "score", "title"]
  },
  "title": "A list of records from querying the knowledge base."
}

This change will ensure that the records field is correctly formatted as an array, preventing the "500 Internal Server Error" [1].

To continue talking to Dosu, mention @dosu.

@Howe829 Howe829 linked a pull request Oct 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant