How to add score_threshold and top_n in endpoint of rerank model #550

Closed
opened 2026-02-16 10:19:43 -05:00 by yindo · 2 comments
Owner

Originally created by @mopemope-LeaF on GitHub (Aug 12, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • 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.
  • 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 wrote a new plugin to expose model api by endpoint. The group yaml like this:

settings:
  - name: api_key
    type: secret-input
    required: true
    label:
      en_US: API key
      zh_Hans: API key
      pt_BR: API key
    placeholder:
      en_US: Please input your API key
      pt_BR: Please input your API key
  - name: llm
    type: model-selector
    scope: llm
    required: false
    label:
      en_US: LLM
      zh_Hans: LLM
      pt_BR: LLM
    placeholder:
      en_US: Please select a LLM
      pt_BR: Please select a LLM
  - name: text_embedding
    type: model-selector
    scope: text-embedding
    required: false
    label:
      en_US: Text Embedding
      pt_BR: Text Embedding
    placeholder:
      en_US: Please select a Text Embedding Model
      pt_BR: Please select a Text Embedding Model
  - name: rerank
    type: model-selector
    scope: rerank
    required: false
    label:
      en_US: Rerank
    placeholder:
      en_US: Please select a Rerank Model
      pt_BR: Please select a Rerank Model
    variable: top_n

endpoints:
  - endpoints/llm.yaml
  - endpoints/text_embedding.yaml
  - endpoints/rerank.yaml

when selected rerank model in endpoin and save, the request is

{
  "api_key": "sk***********************************************QZ",
  "rerank": {
    "provider": "xxxxxx",
    "model": "bge-reranker-v2-m3",
    "model_type": "rerank",
    "type": "model-selector"
  }
}

to http://localhost/console/api/workspaces/current/endpoints/update and it failed without score_threshold and top_n.

I notice plugin-daemon will validate config, the codes like this:

case string(MODEL_CONFIG_SCOPE_RERANK):
	// score_threshold, top_n
	if _, ok := m["score_threshold"]; !ok {
		return errors.New("setting " + config_name + " is missing score_threshold")
	}
	if _, ok := m["top_n"]; !ok {
		return errors.New("setting " + config_name + " is missing top_n")
	}

there are 2 questions:

  1. how can I add score_threshold and top_n in yaml;
  2. If I correctly add these two variables, will the frontend's request to the update interface pass validation and make the plugin functional?

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @mopemope-LeaF on GitHub (Aug 12, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 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 wrote a new plugin to expose model api by endpoint. The group yaml like this: ```yaml settings: - name: api_key type: secret-input required: true label: en_US: API key zh_Hans: API key pt_BR: API key placeholder: en_US: Please input your API key pt_BR: Please input your API key - name: llm type: model-selector scope: llm required: false label: en_US: LLM zh_Hans: LLM pt_BR: LLM placeholder: en_US: Please select a LLM pt_BR: Please select a LLM - name: text_embedding type: model-selector scope: text-embedding required: false label: en_US: Text Embedding pt_BR: Text Embedding placeholder: en_US: Please select a Text Embedding Model pt_BR: Please select a Text Embedding Model - name: rerank type: model-selector scope: rerank required: false label: en_US: Rerank placeholder: en_US: Please select a Rerank Model pt_BR: Please select a Rerank Model variable: top_n endpoints: - endpoints/llm.yaml - endpoints/text_embedding.yaml - endpoints/rerank.yaml ``` when selected rerank model in endpoin and save, the request is ```json { "api_key": "sk***********************************************QZ", "rerank": { "provider": "xxxxxx", "model": "bge-reranker-v2-m3", "model_type": "rerank", "type": "model-selector" } } ``` to `http://localhost/console/api/workspaces/current/endpoints/update` and it failed without score_threshold and top_n. I notice plugin-daemon will validate config, the codes like this: ```go case string(MODEL_CONFIG_SCOPE_RERANK): // score_threshold, top_n if _, ok := m["score_threshold"]; !ok { return errors.New("setting " + config_name + " is missing score_threshold") } if _, ok := m["top_n"]; !ok { return errors.New("setting " + config_name + " is missing top_n") } ``` there are 2 questions: 1. how can I add score_threshold and top_n in yaml; 2. If I correctly add these two variables, will the frontend's request to the update interface pass validation and make the plugin functional? ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the enhancement label 2026-02-16 10:19:43 -05:00
yindo closed this issue 2026-02-16 10:19:43 -05:00
Author
Owner
@crazywoola commented on GitHub (Aug 13, 2025): You can refer https://github.com/langgenius/dify-official-plugins/commit/5f316efcf6fce3d74c5effdb2f1515891d121ba4 https://github.com/langgenius/dify-official-plugins/blob/b93aa1f214276a77e07c3b37f7d42038e4d3e7b4/models/openai_api_compatible/models/rerank/rerank.py#L35 Some of them are hard coded.
Author
Owner

@dosubot[bot] commented on GitHub (Aug 30, 2025):

Hi, @mopemope-LeaF. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You created a new plugin to expose a model API and shared your YAML config.
  • You asked how to add parameters like score_threshold and top_n to the rerank model endpoint.
  • A contributor pointed you to relevant code and a commit, mentioning some parameters are hardcoded.
  • You are seeking guidance on properly incorporating these parameters into the rerank endpoint configuration.
  • The issue remains unresolved with no recent updates.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of the dify-official-plugins repository by commenting here.
  • If I don’t hear back within 5 days, I will automatically close this issue.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 30, 2025): Hi, @mopemope-LeaF. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You created a new plugin to expose a model API and shared your YAML config. - You asked how to add parameters like `score_threshold` and `top_n` to the rerank model endpoint. - A contributor pointed you to relevant code and a commit, mentioning some parameters are hardcoded. - You are seeking guidance on properly incorporating these parameters into the rerank endpoint configuration. - The issue remains unresolved with no recent updates. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of the dify-official-plugins repository by commenting here. - If I don’t hear back within 5 days, I will automatically close this issue. Thanks for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#550