[OpenAI-API-compatible Plugin] Adjustment Needed for rerank Field Transmission #411

Closed
opened 2026-02-16 10:19:20 -05:00 by yindo · 1 comment
Owner

Originally created by @acshmily on GitHub (Jun 30, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, 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.

Dify version

1.3.0

Plugin version

0.0.16

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Here is the translated version of your issue report for GitHub:

Title

[OpenAI-API-compatible Plugin] Adjust docs Field to documents for Rerank Endpoint Compatibility

Description

Problem Summary

When integrating an external rerank model using the OpenAI-API-compatible Plugin, I encountered a field mismatch error:

Traceback (most recent call last):
  File "/app/api/controllers/console/workspace/models.py", line 154, in post
    model_provider_service.save_model_credentials(
  File "/app/api/services/model_provider_service.py", line 237, in save_model_credentials
    provider_configuration.add_or_update_custom_model_credentials(
  File "/app/api/core/entities/provider_configuration.py", line 422, in add_or_update_custom_model_credentials
    provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/core/entities/provider_configuration.py", line 402, in custom_model_credentials_validate
    credentials = model_provider_factory.model_credentials_validate(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 191, in model_credentials_validate
    self.plugin_model_manager.validate_model_credentials(
  File "/app/api/core/plugin/manager/model.py", line 137, in validate_model_credentials
    for resp in response:
                ^^^^^^^^
  File "/app/api/core/plugin/manager/base.py", line 191, in _request_with_plugin_daemon_response_stream
    self._handle_plugin_daemon_error(error.error_type, error.message)
  File "/app/api/core/plugin/manager/base.py", line 221, in _handle_plugin_daemon_error
    raise CredentialsValidateFailedError(error_object.get("message"))
core.model_runtime.errors.validate.CredentialsValidateFailedError: 400 Client Error:  for url: https://wishub-x1.ctyun.cn/v1/rerank

API Documentation Analysis

The target rerank API (https://wishub-x1.ctyun.cn/v1/rerank) expects the input field documents:

curl --location 'https://wishub-x1.ctyun.cn/v1/rerank' \
--header 'Authorization: Bearer ${APP_KEY}' \
--header 'Content-Type: application/json' \
--data '{
  "model": "${MODEL_ID}",
  "query": "人工智能的发展趋势",
  "documents": [
    "人工智能正在快速发展。",
    "机器学习是AI的核心技术。",
    "大语言模型改变了AI领域。",
    "自然语言是AI领域的里程碑"
  ],
  "top_n": 2,
  "return_documents": true
}'

However, the plugin uses the field docs instead, as defined in:
models/openai_api_compatible/models/rerank/rerank.py

Reference to Standard API

The official VLLM OpenAI-compatible server (https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html#extra-parameters_8) also uses documents:

curl -X 'POST' \
  'http://127.0.0.1:8000/v1/rerank' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "BAAI/bge-reranker-base",
  "query": "What is the capital of France?",
  "documents": [
    "The capital of Brazil is Brasilia.",
    "The capital of France is Paris.",
    "Horses and cows are both animals"
  ]
}'

Proposed Solution

Update the plugin's rerank implementation to use the documents field instead of docs to align with standard OpenAI-compatible APIs and third-party services.

This change should be made in:
models/openai_api_compatible/models/rerank/rerank.py

Let me know if you need further information or testing assistance!

Key Points

  1. Field Mismatch: Plugin uses docs, but external APIs require documents.
  2. Standard Compliance: Align with VLLM's OpenAI-compatible API specification.
  3. Location: Modify the field name in the rerank model implementation file.

Let me know if you need further adjustments!

Image
Image

✔️ Error log

No response

Originally created by @acshmily on GitHub (Jun 30, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.3.0 ### Plugin version 0.0.16 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Here is the translated version of your issue report for GitHub: ### **Title** **[OpenAI-API-compatible Plugin] Adjust `docs` Field to `documents` for Rerank Endpoint Compatibility** ### **Description** #### **Problem Summary** When integrating an external rerank model using the OpenAI-API-compatible Plugin, I encountered a field mismatch error: ```python Traceback (most recent call last): File "/app/api/controllers/console/workspace/models.py", line 154, in post model_provider_service.save_model_credentials( File "/app/api/services/model_provider_service.py", line 237, in save_model_credentials provider_configuration.add_or_update_custom_model_credentials( File "/app/api/core/entities/provider_configuration.py", line 422, in add_or_update_custom_model_credentials provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/entities/provider_configuration.py", line 402, in custom_model_credentials_validate credentials = model_provider_factory.model_credentials_validate( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 191, in model_credentials_validate self.plugin_model_manager.validate_model_credentials( File "/app/api/core/plugin/manager/model.py", line 137, in validate_model_credentials for resp in response: ^^^^^^^^ File "/app/api/core/plugin/manager/base.py", line 191, in _request_with_plugin_daemon_response_stream self._handle_plugin_daemon_error(error.error_type, error.message) File "/app/api/core/plugin/manager/base.py", line 221, in _handle_plugin_daemon_error raise CredentialsValidateFailedError(error_object.get("message")) core.model_runtime.errors.validate.CredentialsValidateFailedError: 400 Client Error: for url: https://wishub-x1.ctyun.cn/v1/rerank ``` #### **API Documentation Analysis** The target rerank API (https://wishub-x1.ctyun.cn/v1/rerank) expects the input field `documents`: ```bash curl --location 'https://wishub-x1.ctyun.cn/v1/rerank' \ --header 'Authorization: Bearer ${APP_KEY}' \ --header 'Content-Type: application/json' \ --data '{ "model": "${MODEL_ID}", "query": "人工智能的发展趋势", "documents": [ "人工智能正在快速发展。", "机器学习是AI的核心技术。", "大语言模型改变了AI领域。", "自然语言是AI领域的里程碑" ], "top_n": 2, "return_documents": true }' ``` However, the plugin uses the field `docs` instead, as defined in: `models/openai_api_compatible/models/rerank/rerank.py` #### **Reference to Standard API** The official VLLM OpenAI-compatible server (https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html#extra-parameters_8) also uses `documents`: ```bash curl -X 'POST' \ 'http://127.0.0.1:8000/v1/rerank' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "model": "BAAI/bge-reranker-base", "query": "What is the capital of France?", "documents": [ "The capital of Brazil is Brasilia.", "The capital of France is Paris.", "Horses and cows are both animals" ] }' ``` ### **Proposed Solution** Update the plugin's rerank implementation to use the `documents` field instead of `docs` to align with standard OpenAI-compatible APIs and third-party services. This change should be made in: `models/openai_api_compatible/models/rerank/rerank.py` Let me know if you need further information or testing assistance! ### **Key Points** 1. **Field Mismatch**: Plugin uses `docs`, but external APIs require `documents`. 2. **Standard Compliance**: Align with VLLM's OpenAI-compatible API specification. 3. **Location**: Modify the field name in the rerank model implementation file. Let me know if you need further adjustments! ![Image](https://github.com/user-attachments/assets/dd02f086-3980-4e27-a652-72d55936d603) ![Image](https://github.com/user-attachments/assets/46216af4-dc7d-4278-9e4a-0279682ac972) ### ✔️ Error log _No response_
yindo added the bug label 2026-02-16 10:19:20 -05:00
yindo closed this issue 2026-02-16 10:19:20 -05:00
Author
Owner

@hjlarry commented on GitHub (Jul 2, 2025):

I believe there might be another reason causing your error.

The docs field is an internal attribute of the plugin. When the plugin sends a request to the model provider, it utilizes the documents field, as you can observe here. https://github.com/langgenius/dify-plugin-sdks/blob/c1e36d653c2dca771649981792c64ceb2e4e8476/python/dify_plugin/interfaces/model/openai_compatible/rerank.py#L68

@hjlarry commented on GitHub (Jul 2, 2025): I believe there might be another reason causing your error. The `docs` field is an internal attribute of the plugin. When the plugin sends a request to the model provider, it utilizes the `documents` field, as you can observe here. https://github.com/langgenius/dify-plugin-sdks/blob/c1e36d653c2dca771649981792c64ceb2e4e8476/python/dify_plugin/interfaces/model/openai_compatible/rerank.py#L68
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#411