Skip to content

[DOCS]: Error in API reference for "Retrieve Chunks from a Knowledge Base / Test Retrieval" #644

@yangzq50

Description

@yangzq50

Type of Documentation Change

Error/Typo fix

Documentation Page URL or Path

https://docs.dify.ai/api-reference/datasets/retrieve-chunks-from-a-knowledge-base-test-retrieval

Current Content

In the code block "Retrieve Chunks from a Knowledge Base / Test Retrieval", I see the following usage:

import requests

url = "https://api.dify.ai/v1/datasets/{dataset_id}/retrieve"

payload = {
    "query": "<string>",
    "retrieval_model": {
        "search_method": "hybrid_search",
        "reranking_enable": True,
        "reranking_mode": {
            "reranking_provider_name": "<string>",
            "reranking_model_name": "<string>"
        },
        "top_k": 123,
        "score_threshold_enabled": True,
        "score_threshold": 123,
        "weights": 123,
        "metadata_filtering_conditions": {
            "logical_operator": "and",
            "conditions": [
                {
                    "name": "<string>",
                    "comparison_operator": "<string>",
                    "value": "<string>"
                }
            ]
        }
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

The "reranking_mode" part is probably wrong.

The error also exists in:

"reranking_mode": {
"type": "object",
"description": "Configuration for the reranking model.",
"properties": {
"reranking_provider_name": {
"type": "string",
"description": "The provider of the rerank model."
},
"reranking_model_name": {
"type": "string",
"description": "The name of the rerank model."
}
},

Suggested Changes

I see another doc for 3.0.x, which can be used to access cloud.dify.ai service:

#### Retrieve Chunks from a Knowledge Base
Request example:
```bash
curl --location --request POST 'https://api.dify.ai/v1/datasets/{dataset_id}/retrieve' \
--header 'Authorization: Bearer {api_key}'\
--header 'Content-Type: application/json'\
--data-raw '{
"query": "test",
"retrieval_model": {
"search_method": "keyword_search",
"reranking_enable": false,
"reranking_mode": null,
"reranking_model": {
"reranking_provider_name": "",
"reranking_model_name": ""
},
"weights": null,
"top_k": 1,
"score_threshold_enabled": false,
"score_threshold": null
}
}'
```

Reason for Change

According to Dify source code, "reranking_mode" value can choose from "reranking_model" and "weighted_score".

https://github.com/langgenius/dify/blob/d01f2f7436eaa636b5cf5bfaf66bb0dbcb880e4d/api/core/rag/rerank/rerank_type.py#L1-L6

from enum import StrEnum


class RerankMode(StrEnum):
    RERANKING_MODEL = "reranking_model"
    WEIGHTED_SCORE = "weighted_score"

Code of Conduct

  • I agree to follow Dify's documentation contribution guidelines
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationstaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions