refactor(api): consolidate duplicate RerankingModelConfig and WeightedScoreConfig definitions#34747
Merged
asukaminato0721 merged 4 commits intolanggenius:mainfrom Apr 13, 2026
Conversation
…eConfig Eliminate duplicate Pydantic model definitions that had diverged across modules, causing field incompatibilities and maintenance burden. RerankingModelConfig: - Canonical definition now in core/rag/entities/retrieval_settings.py - Supports both naming conventions via validation_alias (provider/model and reranking_provider_name/reranking_model_name) - Fields are optional with coercion validators (None -> "") - Backward-compatible .provider/.model properties for existing consumers - Removed duplicate definitions from knowledge_index, knowledge_retrieval, and rag_pipeline_entities modules - RerankingModel alias preserved in knowledge_entities.py WeightedScoreConfig: - Made vector_setting/keyword_setting optional (None default) in the canonical core definition to match the services layer superset - Removed duplicate definition from rag_pipeline_entities.py fix
Contributor
Author
|
Resolved conflict. thanks |
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-09 00:15:55.798712548 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-09 00:15:46.865627553 +0000
@@ -297,6 +297,14 @@
--> core/tools/workflow_as_tool/provider.py:237:26
ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
--> core/workflow/human_input_compat.py:183:16
+ERROR Object of class `NoneType` has no attribute `vector_weight` [missing-attribute]
+ --> core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py:227:46
+ERROR Object of class `NoneType` has no attribute `embedding_provider_name` [missing-attribute]
+ --> core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py:228:56
+ERROR Object of class `NoneType` has no attribute `embedding_model_name` [missing-attribute]
+ --> core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py:229:53
+ERROR Object of class `NoneType` has no attribute `keyword_weight` [missing-attribute]
+ --> core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py:232:47
ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
--> extensions/ext_redis.py:244:38
ERROR Cannot index into `Literal['']` [bad-index]
@@ -309,6 +317,8 @@
--> schedule/queue_monitor_task.py:14:21
ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
--> services/account_service.py:1153:13
+ERROR Object of class `NoneType` has no attribute `embedding_provider_name` [missing-attribute]
+ --> services/app_dsl_service.py:731:49
ERROR Runtime checkable protocol `Generator` has an unsafe overlap with type `Iterable[bytes]` [unsafe-overlap]
--> services/audio_service.py:143:41
ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -345,6 +355,8 @@
--> services/hit_testing_service.py:94:21
ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
--> services/plugin/plugin_migration.py:91:34
+ERROR Object of class `NoneType` has no attribute `embedding_provider_name` [missing-attribute]
+ --> services/rag_pipeline/rag_pipeline_dsl_service.py:807:49
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
|
Contributor
Pyrefly DiffNo changes detected. |
Contributor
Pyrefly DiffNo changes detected. |
Contributor
Author
|
@asukaminato0721 Resolved conflicts on this PR. would you review again? Thanks. |
74f7f0c to
6e5c0b4
Compare
Contributor
Pyrefly DiffNo changes detected. |
6e5c0b4 to
1ec478c
Compare
Contributor
Pyrefly DiffNo changes detected. |
fix fix fix
1ec478c to
80119a9
Compare
Contributor
Pyrefly DiffNo changes detected. |
9dda453 to
b7d3348
Compare
Contributor
Pyrefly DiffNo changes detected. |
b7d3348 to
188dfa2
Compare
Contributor
Pyrefly DiffNo changes detected. |
188dfa2 to
80119a9
Compare
Contributor
Pyrefly DiffNo changes detected. |
asukaminato0721
approved these changes
Apr 13, 2026
Contributor
Pyrefly DiffNo changes detected. |
HanqingZ
pushed a commit
to HanqingZ/dify
that referenced
this pull request
Apr 23, 2026
…dScoreConfig definitions (langgenius#34747) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #32385
Summary
RerankingModelConfigincore/rag/entities/retrieval_settings.pywith optional fields,validation_aliasforprovider/model, and backward-compatible propertiesRerankingModelConfigfromknowledge_index/entities.py,knowledge_retrieval/entities.py, andrag_pipeline_entities.pyRerankingModelclass inknowledge_entities.pywith alias to canonicalRerankingModelConfigWeightedScoreConfig.vector_settingandkeyword_settingoptional (Nonedefault) to match services-layer usageWeightedScoreConfigfromrag_pipeline_entities.pyWhy this change
RerankingModelConfighad 3 conflicting definitions with incompatible field names (provider/modelvsreranking_provider_name/reranking_model_name) and different optionality (required vs optional). A 4th variantRerankingModeladded naming confusion. The canonical definition now accepts both conventions and coercesNoneto"".WeightedScoreConfighad 2 definitions — core required both fields while services allowedNone. The core version now matches the superset.Changes
core/rag/entities/retrieval_settings.py: Add canonicalRerankingModelConfigwith validators, aliases, compat properties; makeWeightedScoreConfigfields optionalcore/rag/entities/__init__.py: ExportRerankingModelConfigcore/workflow/nodes/knowledge_index/entities.py: Remove localRerankingModelConfig, import from corecore/workflow/nodes/knowledge_retrieval/entities.py: Remove localRerankingModelConfig, import from coreservices/entities/knowledge_entities/rag_pipeline_entities.py: Remove localRerankingModelConfigandWeightedScoreConfig, import from coreservices/entities/knowledge_entities/knowledge_entities.py: ReplaceRerankingModelclass withRerankingModel = RerankingModelConfigaliasTest plan
api/tests/unit_tests/services/)provider/modelalias support)RerankingModelConfig(provider=..., model=...)andRerankingModelConfig(reranking_provider_name=..., reranking_model_name=...)