Repository navigation
fix: Method for obtaining workflow model ID #8237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,13 +102,13 @@ def execute(self): | |
| model_id_reference[1:], | ||
| ) | ||
| if reference_data and isinstance(reference_data, dict): | ||
| model_id = reference_data.get("model_id", model_id) | ||
| model_id = reference_data.get("model_id") | ||
| model_params_setting = reference_data.get("model_params_setting") | ||
|
|
||
| if model_id_type == "default": | ||
| default_model_setting = workflow_params.get("default_model_setting").get("TTI") or {} | ||
| if default_model_setting and isinstance(default_model_setting, dict): | ||
| model_id = default_model_setting.get("model_id", model_id) | ||
| model_id = default_model_setting.get("model_id") | ||
| model_params_setting = default_model_setting.get("model_params_setting") | ||
|
|
||
| if not model_id: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main issue: behavior change (likely bug)Changing: model_id = reference_data.get("model_id", model_id)to: model_id = reference_data.get("model_id")means that if The same issue applies to: model_id = default_model_setting.get("model_id")Impact:
If the intent is “only override when the key exists”, use: if "model_id" in reference_data:
model_id = reference_data["model_id"]or, to preserve the old behavior explicitly: model_id = reference_data.get("model_id", model_id)If the intent is “ignore explicit if reference_data.get("model_id") is not None:
model_id = reference_data["model_id"]Related issue:
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,14 +139,12 @@ def execute(self): | |
| reranker_model_id_reference[1:], | ||
| ) | ||
| if reference_data and isinstance(reference_data, dict): | ||
| reranker_model_id = reference_data.get( | ||
| "reranker_model_id", reference_data.get("model_id", reranker_model_id) | ||
| ) | ||
| reranker_model_id = reference_data.get("reranker_model_id", reference_data.get("model_id")) | ||
|
|
||
| if reranker_model_id_type == "default": | ||
| default_model_setting = workflow_params.get("default_model_setting").get("RERANKER") or {} | ||
| if default_model_setting and isinstance(default_model_setting, dict): | ||
| reranker_model_id = default_model_setting.get("model_id", reranker_model_id) | ||
| reranker_model_id = default_model_setting.get("model_id") | ||
|
|
||
| if not reranker_model_id: | ||
| raise Exception(_("Model is not allowed to be empty")) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here are the main points to consider: 1. Changed fallback semantics (potential bug)The diff removes the fallback to the existing # Before
reranker_model_id = reference_data.get(
"reranker_model_id", reference_data.get("model_id", reranker_model_id)
)
# After
reranker_model_id = reference_data.get("reranker_model_id", reference_data.get("model_id"))If # Before
reranker_model_id = default_model_setting.get("model_id", reranker_model_id)
# After
reranker_model_id = default_model_setting.get("model_id")This can introduce an unexpected reranker_model_id = reference_data.get("reranker_model_id", reference_data.get("model_id", reranker_model_id))2. Existing issue: unsafe
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review of the diff
1. Behavior change: silent loss of the fallback
model_id(main issue)dict.get(key)returnsNonewhen the key is absent, so the previous value ofmodel_id(presumably resolved frommodel_id_reference/ earlier logic) is now discarded. The same applies to thedefault_model_settingbranch.Consequences:
reference_dataexists but simply doesn't contain"model_id", you now wipe out a validmodel_idand fall intoif not model_id, which likely raises an error or falls back to a default unexpectedly.null", that should be documented; otherwise keep the, model_iddefault.If you do want to distinguish "key missing" from "key present but
None", be explicit:2.
model_params_settingis overwritten unconditionallyIf the key is absent, this sets
model_params_settingtoNone, potentially clobbering a previously configured value (same problem as above). Guard it:or only assign when truthy, depending on whether empty dict is meaningful.
3.
AttributeErrorrisk in thedefaultbranchIf
"default_model_setting"is missing or explicitlyNone,.get("LLM")raisesAttributeError. Use:Also
workflow_params.get("default_model_setting")is evaluated twice — minor, but you can factor it.4. Type safety
reference_data.get("model_id")/default_model_setting.get("model_id")are not validated. If these can be non-strings (int, dict, etc.),if not model_idwon't catch it and downstream code may break. Consider validating type/format here.5. Duplicated assignment logic
Both branches do the same "override
model_idandmodel_params_setting" pattern. Consider extracting a small helper to keep the semantics identical and avoid future divergence (as just happened with the two.get()calls being changed inconsistently relative to intent).6. Minor:
elifIf
model_id_typecannot be both"reference"-like and"default", usingelifwould signal exclusivity and avoid double work / double overrides.7. Minor: reference slicing
model_id_reference[1:]assumes the first character is always a prefix marker. Ifmodel_id_referencecan be empty or have a different format, add validation before slicing.Bottom line: The core change (dropping the
model_iddefault) is likely a bug unless intentionally allowingNoneto reset the value. Thedefault_model_settingline also has a latentAttributeError. Both should be fixed or at least clearly justified.