-
Notifications
You must be signed in to change notification settings - Fork 8.2k
fix: preserve user-selected model when updating available options #9495
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 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -145,8 +145,9 @@ def update_build_config(self, build_config: dotdict, field_value: Any, field_nam | |||||||||||||||||||
| except (ImportError, ValueError, requests.exceptions.RequestException) as e: | ||||||||||||||||||||
| logger.exception(f"Error getting model names: {e}") | ||||||||||||||||||||
| ids = GOOGLE_GENERATIVE_AI_MODELS | ||||||||||||||||||||
| build_config.setdefault("model_name", {}) | ||||||||||||||||||||
| build_config["model_name"]["options"] = ids | ||||||||||||||||||||
| build_config["model_name"]["value"] = ids[0] | ||||||||||||||||||||
| build_config["model_name"].setdefault("value", ids[0]) | ||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||
|
Comment on lines
+148
to
151
Contributor
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. Avoid IndexError when ids is empty ids[0] will throw if the list is empty (e.g., transient API issues or filtering). Add a guard. Apply this diff: - build_config.setdefault("model_name", {})
- build_config["model_name"]["options"] = ids
- build_config["model_name"].setdefault("value", ids[0])
+ model_cfg = build_config.setdefault("model_name", {})
+ model_cfg["options"] = ids
+ if ids:
+ model_cfg.setdefault("value", ids[0])📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| msg = f"Error getting model names: {e}" | ||||||||||||||||||||
| raise ValueError(msg) from e | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -114,8 +114,9 @@ def update_build_config(self, build_config: dict, field_value: str, field_name: | |||||||||||||||||||||
| except (ImportError, ValueError, requests.exceptions.RequestException) as e: | ||||||||||||||||||||||
| logger.exception(f"Error getting model names: {e}") | ||||||||||||||||||||||
| ids = GROQ_MODELS | ||||||||||||||||||||||
| build_config.setdefault("model_name", {}) | ||||||||||||||||||||||
| build_config["model_name"]["options"] = ids | ||||||||||||||||||||||
| build_config["model_name"]["value"] = ids[0] | ||||||||||||||||||||||
| build_config["model_name"].setdefault("value", ids[0]) | ||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||
|
Comment on lines
+117
to
120
Contributor
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. Guard against empty ids to avoid IndexError ids can be empty (e.g., transient API failure or aggressive filtering when tool_model_enabled is True). Accessing ids[0] will raise IndexError even inside setdefault. Add a simple guard. Apply this diff: - build_config.setdefault("model_name", {})
- build_config["model_name"]["options"] = ids
- build_config["model_name"].setdefault("value", ids[0])
+ model_cfg = build_config.setdefault("model_name", {})
+ model_cfg["options"] = ids
+ if ids:
+ model_cfg.setdefault("value", ids[0])📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| msg = f"Error getting model names: {e}" | ||||||||||||||||||||||
| raise ValueError(msg) from e | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
Prevent IndexError when no models are returned
ids can be empty after filtering tool-capable models or due to API/listing issues. Accessing ids[0] will raise IndexError. Guard it.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents