Skip to content

Feat: model list - #15774

Merged
wangq8 merged 13 commits into
infiniflow:mainfrom
Lynn-Inf:feat/model-list
Jun 8, 2026
Merged

wangq8 merged 13 commits into
infiniflow:mainfrom
Lynn-Inf:feat/model-list

Conversation

@Lynn-Inf

@Lynn-Inf Lynn-Inf commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Support model list for VolcEngine.

Type of change

  • New Feature (non-breaking change which adds functionality)

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 16c8cf26-470c-4bd0-bc4a-1dda7256ed54

📥 Commits

Reviewing files that changed from the base of the PR and between 5b451d7 and c936465.

📒 Files selected for processing (1)
  • rag/llm/model_meta.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • rag/llm/model_meta.py

📝 Walkthrough

Walkthrough

VolcEngine 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.

Changes

VolcEngine model-list implementation

Layer / File(s) Summary
VolcEngine factory configuration
conf/llm_factories.json
VolcEngine factory entry gains the Ark API v3 endpoint URL https://ark.cn-beijing.volces.com/api/v3 used for subsequent model-list requests.
VolcEngine API key, URL, and formatter
rag/llm/model_meta.py
Implements _get_api_key to extract ark_api_key from JSON-encoded API credentials with fallback to the raw value, _get_model_list_url to normalize base_url and target the /api/v3/models endpoint, and _format_model_list to filter active models and map provider response fields (modalities, token limits, capabilities) into standard model_types, features, max_tokens, and status fields.

Docstring punctuation fixes

Layer / File(s) Summary
Provider API service doc examples
api/apps/services/provider_api_service.py
Two docstring example model_info lines (in create_provider_instance and verify_api_key) were corrected to use an ASCII comma character; no runtime code changed.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

💞 feature

Suggested reviewers

  • Haruko386

Poem

🐰 I parsed a key tucked in JSON night,
found ark_api glowing small and bright.
Paths set to /api/v3/models’ door,
I hop — the model list grows more and more. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Feat: model list' directly aligns with the PR objective of adding model list support for VolcEngine, clearly summarizing the main feature being implemented.
Description check ✅ Passed The description addresses the required sections: it explains the problem (supporting model list for VolcEngine) and correctly identifies the change type (New Feature), though it lacks deeper implementation details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Lynn-Inf Lynn-Inf added the ci Continue Integration label Jun 8, 2026
@Lynn-Inf
Lynn-Inf marked this pull request as draft June 8, 2026 09:39
@Lynn-Inf
Lynn-Inf marked this pull request as ready for review June 8, 2026 09:39

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
rag/llm/model_meta.py (1)

64-113: ⚡ Quick win

Add 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

📥 Commits

Reviewing files that changed from the base of the PR and between 86b320e and f390083.

📒 Files selected for processing (3)
  • api/apps/services/provider_api_service.py
  • conf/llm_factories.json
  • rag/llm/model_meta.py

Comment thread rag/llm/model_meta.py
Comment on lines +64 to +69
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Comment thread rag/llm/model_meta.py Resolved
@codecov

codecov Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (e81bca7) to head (c936465).
⚠️ Report is 27 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8
wangq8 merged commit b9f06e6 into infiniflow:main Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants