Repository navigation
Feat: model list - #15774
Feat: model list#15774
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughVolcEngine now parses JSON-wrapped API keys, normalizes/builds the Ark v3 models URL, and formats provider model responses into standardized metadata. The PR also fixes two docstring example punctuation characters. ChangesVolcEngine model-list implementation
Docstring punctuation fixes
Sequence DiagramsequenceDiagram
participant Caller
participant VolcEngine
participant ArkAPI
Caller->>VolcEngine: get_model_list()
VolcEngine->>VolcEngine: _get_api_key(api_key)
VolcEngine->>VolcEngine: _get_model_list_url(base_url)
VolcEngine->>ArkAPI: GET /api/v3/models (using ark_api_key)
ArkAPI-->>VolcEngine: raw models response
VolcEngine->>VolcEngine: _format_model_list(raw response)
VolcEngine-->>Caller: standardized model list
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
rag/llm/model_meta.py (1)
64-113: ⚡ Quick winAdd logs for the new VolcEngine model-list flow
The new parsing/normalization/formatting path has silent fallbacks and drops, which will be hard to diagnose in production without minimal debug/warn logs.
As per coding guidelines, "Add logging for new flows".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rag/llm/model_meta.py` around lines 64 - 113, The new VolcEngine model-list path silently falls back and drops data; add minimal logging in _get_api_key (log JSON decode fallback with the raw api_key), in _get_model_list_url (log when default base_url is used), and throughout _format_model_list: log counts (raw_model_list data length, serving_model filtered count, final res count), log when a model is skipped because model_types is empty (include model id and its modalities), and log any detected features or unusual token limit values; use the instance logger (self.logger.debug/warning) or a module logger consistently and keep messages short and structured so these functions (_get_api_key, _get_model_list_url, _format_model_list) surface enough info for debugging without changing behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/llm/model_meta.py`:
- Around line 64-69: The _get_api_key method currently assumes
json.loads(self.api_key) returns a dict and calls .get, which raises
AttributeError for valid JSON that is not an object (e.g., string/array/number);
update _get_api_key to parse self.api_key inside the existing try/except, then
check isinstance(parsed, dict) before using parsed.get("ark_api_key", "") and
otherwise fall back to returning self.api_key (or an empty string if desired),
keeping the JSONDecodeError branch as-is so invalid JSON still falls back
cleanly.
- Around line 77-113: The _format_model_list function currently assumes
raw_model_list["data"] and model["id"] always exist; guard against missing or
malformed payloads by using safe lookups and defaults: retrieve the data list
with raw_model_list.get("data", []) and skip non-dict entries, use
model.get("id") and skip models without an id, and defensively access nested
keys (e.g., modalities = model.get("modalities", {}) and token_limits =
model.get("token_limits", {})) so the loops over serving_model and building res
never raise KeyError when the VolcEngine response schema drifts.
---
Nitpick comments:
In `@rag/llm/model_meta.py`:
- Around line 64-113: The new VolcEngine model-list path silently falls back and
drops data; add minimal logging in _get_api_key (log JSON decode fallback with
the raw api_key), in _get_model_list_url (log when default base_url is used),
and throughout _format_model_list: log counts (raw_model_list data length,
serving_model filtered count, final res count), log when a model is skipped
because model_types is empty (include model id and its modalities), and log any
detected features or unusual token limit values; use the instance logger
(self.logger.debug/warning) or a module logger consistently and keep messages
short and structured so these functions (_get_api_key, _get_model_list_url,
_format_model_list) surface enough info for debugging without changing behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0b99478b-1779-4e64-b1eb-464fa3b05c4b
📒 Files selected for processing (3)
api/apps/services/provider_api_service.pyconf/llm_factories.jsonrag/llm/model_meta.py
| def _get_api_key(self): | ||
| try: | ||
| api_key = json.loads(self.api_key).get("ark_api_key", "") | ||
| except JSONDecodeError: | ||
| api_key = self.api_key | ||
| return api_key |
There was a problem hiding this comment.
Guard _get_api_key against non-dict JSON payloads
Line 66 can raise AttributeError when self.api_key is valid JSON but not an object (e.g., JSON string/array/number). That crashes model listing instead of falling back cleanly.
Suggested fix
def _get_api_key(self):
try:
- api_key = json.loads(self.api_key).get("ark_api_key", "")
+ payload = json.loads(self.api_key)
+ if isinstance(payload, dict):
+ api_key = payload.get("ark_api_key") or payload.get("api_key") or self.api_key
+ else:
+ api_key = self.api_key
except JSONDecodeError:
api_key = self.api_key
return api_key🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/model_meta.py` around lines 64 - 69, The _get_api_key method
currently assumes json.loads(self.api_key) returns a dict and calls .get, which
raises AttributeError for valid JSON that is not an object (e.g.,
string/array/number); update _get_api_key to parse self.api_key inside the
existing try/except, then check isinstance(parsed, dict) before using
parsed.get("ark_api_key", "") and otherwise fall back to returning self.api_key
(or an empty string if desired), keeping the JSONDecodeError branch as-is so
invalid JSON still falls back cleanly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15774 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Support model list for VolcEngine.
Type of change