diff --git a/python/dify_plugin/interfaces/model/openai_compatible/rerank.py b/python/dify_plugin/interfaces/model/openai_compatible/rerank.py index 91b783f7..a31baa03 100644 --- a/python/dify_plugin/interfaces/model/openai_compatible/rerank.py +++ b/python/dify_plugin/interfaces/model/openai_compatible/rerank.py @@ -79,6 +79,9 @@ def _invoke( scores = [result["relevance_score"] for result in results["results"]] # Min-Max Normalization: Normalize scores to 0 ~ 1.0 range + if len(scores) == 1: + scores.append(0) + min_score = min(scores) max_score = max(scores) score_range = max_score - min_score if max_score != min_score else 1.0 # Avoid division by zero