Skip to content

feat: add ModelMeta implementations for Xinference, LocalAI, BaiduYiyan, and Tencent Cloud - #15752

Merged
wangq8 merged 12 commits into
infiniflow:mainfrom
euvre:feat/model-meta-xinference-localai-baidu-tencent
Jun 8, 2026
Merged

wangq8 merged 12 commits into
infiniflow:mainfrom
euvre:feat/model-meta-xinference-localai-baidu-tencent

Conversation

@euvre

@euvre euvre commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

This PR adds ModelMeta implementations for four additional LLM/RAG ecosystem platforms, building on the ModelMeta infrastructure introduced in #15711.

Currently, only Ollama and VolcEngine have ModelMeta classes that enable remote model list fetching. This PR extends that support to four more platforms.

Changes

Added four new ModelMeta subclasses in rag/llm/model_meta.py:

Platform _FACTORY_NAME Has model list Has full model info Approach
Xinference "Xinference" ✅ ✅ Parses model_type and context_length from /v1/models response. Maps 6 model types (LLM/embedding/rerank/image/TTS/speech2text).
LocalAI "LocalAI" ✅ ✅ Uses Ollama-compatible GET /api/tags + POST /api/show endpoints. Returns capabilities (completion/embedding/vision/tools/thinking) and general.context_length.
BaiduYiyan "BaiduYiyan" ✅ ✅ Uses Qianfan SDK static model catalog + get_model_info() for max_input_tokens. Returns 60 models (56 chat + 4 embedding) with real context lengths.
Tencent Cloud "Tencent Cloud" ❌ ❌ NotImplementedError — uses SDK-based SID/SK HMAC signing, no model list REST API available.

All classes are automatically discovered and registered via the existing __init__.py mechanism — no additional configuration needed.

Type of change

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

…an, and Tencent Cloud

- Xinference: OpenAI-compatible /v1/models endpoint with model list formatting
- LocalAI: OpenAI-compatible /v1/models endpoint with model list formatting
- BaiduYiyan: NotImplementedError (Qianfan SDK AK/SK auth flow)
- Tencent Cloud: NotImplementedError (SDK SID/SK HMAC signing auth)
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Normalize Base provider URLs and refactor Ollama model listing; add Xinference and BaiduYiyan providers, refactor LocalAI, and add a TencentCloud placeholder.

Changes

Model Provider Infrastructure and New Implementations

Layer / File(s) Summary
Base and Ollama provider updates
rag/llm/model_meta.py
Base now normalizes base_url (strip trailing /v{n}) and adds helpers for consistent /v1/models endpoints. Ollama.get_model_list reworked to use normalized URLs, optional Bearer auth, fetch /api/tags then per-model /api/show, map capabilities to model_types/features, and compute max_tokens with an 8192 fallback.
Xinference provider
rag/llm/model_meta.py
Adds Xinference provider calling /v1/models, maps Xinference model_type→LLMType, skips entries missing id, sets features=None, and derives max_tokens from context_length (8192 fallback).
LocalAI endpoint docs & URL helpers
rag/llm/model_meta.py
Module-level LocalAI docs updated and LocalAI tag/detail URL helpers switched to use Base's normalized base URL.
LocalAI provider
rag/llm/model_meta.py
Refactors LocalAI.get_model_list to use explicit capability→LLMType and capability→feature mappings, POST /api/show per tag model, populate features, and compute max_tokens from general.context_length with 8192 fallback.
BaiduYiyan provider
rag/llm/model_meta.py
Implements BaiduYiyan.get_model_list using qianfan SDK to enumerate chat and embedding models; chat max_tokens best-effort per model (8192 fallback), embeddings set to 8192, and per-model/catalog lookup errors suppressed.
TencentCloud provider (placeholder)
rag/llm/model_meta.py
Adds TencentCloud.get_model_list that raises NotImplementedError.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • infiniflow/ragflow#15711: Integrates provider implementations from rag/llm/model_meta.py into provider_api_service.list_provider_models flow.

Suggested labels

🌈 python

Suggested reviewers

  • Haruko386
  • Lynn-Inf

Poem

🐰 New providers hop into view,
Xinference and Baidu too,
LocalAI tidied, Ollama refined,
Tencent waits — one day aligned,
Metadata normalized, models anew.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 accurately summarizes the main change: adding ModelMeta implementations for four new LLM platforms (Xinference, LocalAI, BaiduYiyan, and Tencent Cloud).
Description check ✅ Passed The description includes all required template sections: problem statement referencing prior context, change summary with detailed platform breakdown, and type of change (New Feature) clearly marked.
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.

@euvre euvre added the ci Continue Integration label Jun 8, 2026

@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: 3

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

159-165: ⚡ Quick win

NotImplementedError will produce generic 500 error.

The get_model_list implementation raises NotImplementedError, which per the API route handler (context snippet 3) will be caught and returned as "Internal server error" to users. This doesn't clearly communicate that the provider doesn't support dynamic model listing.

Consider one of these approaches:

  1. Return an empty list [] with a logged warning that model listing is not supported
  2. Raise a custom exception that the API handler can catch and return a clearer message like "Provider does not support model listing"
🤖 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 159 - 165, The BaiduYiyan.get_model_list
currently raises NotImplementedError which becomes a generic 500; change it to
return an empty list and log a clear warning that dynamic model listing is not
supported by the BaiduYiyan provider (use process logger or the existing logger
in the Base class), or alternatively define and raise a specific exception
(e.g., ProviderNotSupportedError) that the API handler can detect; update
BaiduYiyan.get_model_list to implement one of these approaches and ensure any
new exception type is imported/handled by the API route that consumes
Base.get_model_list.

134-156: ⚡ Quick win

Code duplication with Xinference class.

The LocalAI implementation is nearly identical to Xinference (lines 109-131). The _format_model_list method is duplicated verbatim. Consider extracting a shared method or base class for OpenAI-compatible providers to follow DRY principles.

♻️ Proposed refactor to eliminate duplication
+class OpenAICompatible(Base):
+    """Base class for providers with OpenAI-compatible /v1/models endpoints."""
+    
+    def _get_model_list_url(self):
+        if not self.base_url:
+            return None
+        return self.base_url.rstrip("/") + "/v1/models"
+    
+    def _format_model_list(self, raw_model_list):
+        """Parse OpenAI-compatible /v1/models response."""
+        data = raw_model_list.get("data", [])
+        if not data:
+            return []
+        return [
+            {
+                "name": model.get("id", ""),
+                "model_types": [LLMType.CHAT.value],
+                "features": None,
+                "max_tokens": 8192,
+            }
+            for model in data
+            if model.get("id")
+        ]
+
-class Xinference(Base):
+class Xinference(OpenAICompatible):
     _FACTORY_NAME = "Xinference"
-    
-    def _get_model_list_url(self):
-        if not self.base_url:
-            return None
-        return self.base_url.rstrip("/") + "/v1/models"
-    
-    def _format_model_list(self, raw_model_list):
-        """Xinference exposes an OpenAI-compatible /v1/models endpoint."""
-        data = raw_model_list.get("data", [])
-        if not data:
-            return []
-        return [
-            {
-                "name": model.get("id", ""),
-                "model_types": [LLMType.CHAT.value],
-                "features": None,
-                "max_tokens": 8192,
-            }
-            for model in data
-            if model.get("id")
-        ]

-class LocalAI(Base):
+class LocalAI(OpenAICompatible):
     _FACTORY_NAME = "LocalAI"
-    
-    def _get_model_list_url(self):
-        if not self.base_url:
-            return None
-        return self.base_url.rstrip("/") + "/v1/models"
-    
-    def _format_model_list(self, raw_model_list):
-        """LocalAI exposes an OpenAI-compatible /v1/models endpoint."""
-        data = raw_model_list.get("data", [])
-        if not data:
-            return []
-        return [
-            {
-                "name": model.get("id", ""),
-                "model_types": [LLMType.CHAT.value],
-                "features": None,
-                "max_tokens": 8192,
-            }
-            for model in data
-            if model.get("id")
-        ]
🤖 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 134 - 156, LocalAI and Xinference both
duplicate the OpenAI-compatible model-list formatting logic in their
_format_model_list methods; extract that logic into a single shared helper
(e.g., a module-level function format_openai_model_list) or an intermediate base
class (e.g., OpenAICompatibleProvider with _format_model_list) and have both
LocalAI and Xinference call the shared implementation instead of duplicating
code, leaving each class-specific _get_model_list_url/_FACTORY_NAME intact and
returning the same list structure (keys: name, model_types, features,
max_tokens) as before.
🤖 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 109-131: Add logging to the Xinference provider flow: inside the
Xinference class use the existing logger (or import module logger) to log when
_get_model_list_url computes/returns a URL (or None), log before attempting to
fetch models using that URL, log a warning/error inside _format_model_list when
raw_model_list lacks expected "data" or parsing yields no models, and log an
info/debug message when returning the formatted model list from
_format_model_list; reference the Xinference class and its methods
_get_model_list_url and _format_model_list so logs clearly identify this
provider and include relevant values (computed URL, raw_model_list summary, and
result count).
- Around line 134-156: The LocalAI provider lacks logging around its model-list
retrieval and formatting; add informative logs in LocalAI::_get_model_list_url
and LocalAI::_format_model_list to record when a request URL is absent, when the
constructed URL is used, when raw_model_list is empty, and when models are
successfully parsed (include model ids/count). Ensure logs use the module/class
logger (or existing logger used by other providers) and include contextual data
(base_url, final URL, raw_model_list keys or counts) to aid debugging.

---

Nitpick comments:
In `@rag/llm/model_meta.py`:
- Around line 159-165: The BaiduYiyan.get_model_list currently raises
NotImplementedError which becomes a generic 500; change it to return an empty
list and log a clear warning that dynamic model listing is not supported by the
BaiduYiyan provider (use process logger or the existing logger in the Base
class), or alternatively define and raise a specific exception (e.g.,
ProviderNotSupportedError) that the API handler can detect; update
BaiduYiyan.get_model_list to implement one of these approaches and ensure any
new exception type is imported/handled by the API route that consumes
Base.get_model_list.
- Around line 134-156: LocalAI and Xinference both duplicate the
OpenAI-compatible model-list formatting logic in their _format_model_list
methods; extract that logic into a single shared helper (e.g., a module-level
function format_openai_model_list) or an intermediate base class (e.g.,
OpenAICompatibleProvider with _format_model_list) and have both LocalAI and
Xinference call the shared implementation instead of duplicating code, leaving
each class-specific _get_model_list_url/_FACTORY_NAME intact and returning the
same list structure (keys: name, model_types, features, max_tokens) as before.
🪄 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: 838c0876-b8e4-41c9-a3ab-f511c0f42ea0

📥 Commits

Reviewing files that changed from the base of the PR and between b1a2210 and 168ec13.

📒 Files selected for processing (1)
  • rag/llm/model_meta.py

Comment thread rag/llm/model_meta.py Resolved
Comment thread rag/llm/model_meta.py Resolved
Comment thread rag/llm/model_meta.py Resolved
…sting

- Xinference: parse model_type and context_length from API response
  for accurate model_types and max_tokens
- BaiduYiyan: use Qianfan SDK static model catalog (ChatCompletion.models()
  and Embedding.models()) to list all available models without auth
- Tencent Cloud: keep NotImplementedError (SDK-only, no model list API)
- LocalAI: keep basic /v1/models listing (no extra metadata available)
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 8, 2026
Use ChatCompletion._real_base('1').get_model_info() to retrieve
max_input_tokens for each model, providing accurate context length
instead of hardcoded 8192 default.

@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: 1

♻️ Duplicate comments (2)
rag/llm/model_meta.py (2)

155-177: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Missing logging for new provider flow.

The LocalAI provider implementation does not include logging for the model list retrieval flow. As per coding guidelines, logging should be added for new flows.

Consider adding logging at key points (e.g., when fetching models, when parsing fails, when returning results).

🤖 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 155 - 177, Add logging around the LocalAI
model-list flow in class LocalAI: instrument _get_model_list_url to log when no
base_url is configured and when it builds the URL, and instrument the model
retrieval/parsing in _format_model_list to log the raw response receipt, any
parsing anomalies (e.g., missing or empty "data"), and the final formatted
result count; use the existing logger pattern in the module (same logger
instance used elsewhere) and include context like self._FACTORY_NAME and the
URL/model ids in the messages for easier debugging.

Source: Coding guidelines


117-152: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Missing logging for new provider flow.

The Xinference provider implementation does not include logging for the model list retrieval flow. As per coding guidelines, logging should be added for new flows.

Consider adding logging at key points (e.g., when fetching models, when parsing fails, when returning results).

🤖 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 117 - 152, Add logging to the Xinference
model-list flow: in _format_model_list and optionally in
_xinference_model_type_to_llm_type use the instance logger (e.g., self.logger)
to log entry into _format_model_list with a short summary of raw_model_list, log
when data is empty and you return [], log a warning when you skip a model
because model.get("id") is missing, log when you fall back to default model_type
or default max_tokens (context_length) for a model, and log the final number of
models returned; wrap the model-processing loop in a try/except to log parsing
exceptions with exception info so failures are visible during the new provider
flow.

Source: Coding guidelines

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

203-215: ⚡ Quick win

Consider more specific exception handling or logging for embedding models.

The broad except Exception: pass at line 214 silently swallows all errors when fetching embedding models. This could hide API changes, network errors, or SDK issues.

Consider either:

  1. Catching specific exceptions (e.g., ImportError, AttributeError) if certain errors are expected
  2. Adding logging to record that embedding retrieval was attempted but failed
♻️ Suggested improvement
 try:
     embed_models = qianfan.Embedding.models()
     for name in embed_models:
         res.append(
             {
                 "name": name,
                 "model_types": [LLMType.EMBEDDING.value],
                 "features": None,
                 "max_tokens": 8192,
             }
         )
-except Exception:
-    pass
+except Exception as e:
+    # Log warning: embeddings are optional but errors should be visible
+    # logger.warning(f"Failed to retrieve BaiduYiyan embedding models: {e}")
+    pass
🤖 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 203 - 215, The try/except around
qianfan.Embedding.models() silently swallows all errors; update the block around
qianfan.Embedding.models() to catch specific expected exceptions (e.g.,
ImportError, AttributeError, network-related exceptions from the qianfan SDK)
and/or log failures instead of using a bare except. Ensure the handler logs a
clear message including the exception and context (mentioning
qianfan.Embedding.models and LLMType.EMBEDDING) and only suppresses errors you
explicitly expect; re-raise or propagate unexpected exceptions so res population
issues are visible.
🤖 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 183-217: Add structured logging to the get_model_list async
method: use the module logger (e.g., logger) to log when chat models are
successfully retrieved after calling qianfan.ChatCompletion.models(), log a
debug/info message before attempting qianfan.Embedding.models(), log an error
(including exception details) inside the except block when embedding retrieval
fails, and log a final trace/info message returning the assembled res list
(including count or names). Ensure you import or use the existing module-level
logger and avoid changing the method signature; reference get_model_list,
qianfan.ChatCompletion.models(), qianfan.Embedding.models(), and the res list
for placement.

---

Duplicate comments:
In `@rag/llm/model_meta.py`:
- Around line 155-177: Add logging around the LocalAI model-list flow in class
LocalAI: instrument _get_model_list_url to log when no base_url is configured
and when it builds the URL, and instrument the model retrieval/parsing in
_format_model_list to log the raw response receipt, any parsing anomalies (e.g.,
missing or empty "data"), and the final formatted result count; use the existing
logger pattern in the module (same logger instance used elsewhere) and include
context like self._FACTORY_NAME and the URL/model ids in the messages for easier
debugging.
- Around line 117-152: Add logging to the Xinference model-list flow: in
_format_model_list and optionally in _xinference_model_type_to_llm_type use the
instance logger (e.g., self.logger) to log entry into _format_model_list with a
short summary of raw_model_list, log when data is empty and you return [], log a
warning when you skip a model because model.get("id") is missing, log when you
fall back to default model_type or default max_tokens (context_length) for a
model, and log the final number of models returned; wrap the model-processing
loop in a try/except to log parsing exceptions with exception info so failures
are visible during the new provider flow.

---

Nitpick comments:
In `@rag/llm/model_meta.py`:
- Around line 203-215: The try/except around qianfan.Embedding.models() silently
swallows all errors; update the block around qianfan.Embedding.models() to catch
specific expected exceptions (e.g., ImportError, AttributeError, network-related
exceptions from the qianfan SDK) and/or log failures instead of using a bare
except. Ensure the handler logs a clear message including the exception and
context (mentioning qianfan.Embedding.models and LLMType.EMBEDDING) and only
suppresses errors you explicitly expect; re-raise or propagate unexpected
exceptions so res population issues are visible.
🪄 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: af2e31f7-9982-4b69-81db-074fdd71fd54

📥 Commits

Reviewing files that changed from the base of the PR and between 168ec13 and ed91d51.

📒 Files selected for processing (1)
  • rag/llm/model_meta.py

Comment thread rag/llm/model_meta.py
Comment on lines +183 to +217
async def get_model_list(self):
"""BaiduYiyan uses the Qianfan SDK which provides static model catalogs.

The ``models()`` class method returns all supported model names
without requiring AK/SK credentials.
"""
import qianfan

res = []
chat_models = qianfan.ChatCompletion.models()
for name in chat_models:
res.append(
{
"name": name,
"model_types": [LLMType.CHAT.value],
"features": None,
"max_tokens": 8192,
}
)

try:
embed_models = qianfan.Embedding.models()
for name in embed_models:
res.append(
{
"name": name,
"model_types": [LLMType.EMBEDDING.value],
"features": None,
"max_tokens": 8192,
}
)
except Exception:
pass

return res

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.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Missing logging for new provider flow.

The BaiduYiyan provider implementation does not include logging for the model list retrieval flow. As per coding guidelines, logging should be added for new flows.

Consider adding logging at key points:

  • When successfully retrieving chat models
  • When attempting to retrieve embedding models
  • When embedding retrieval fails (currently silent due to broad exception handling)
  • When returning the final model list
🤖 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 183 - 217, Add structured logging to the
get_model_list async method: use the module logger (e.g., logger) to log when
chat models are successfully retrieved after calling
qianfan.ChatCompletion.models(), log a debug/info message before attempting
qianfan.Embedding.models(), log an error (including exception details) inside
the except block when embedding retrieval fails, and log a final trace/info
message returning the assembled res list (including count or names). Ensure you
import or use the existing module-level logger and avoid changing the method
signature; reference get_model_list, qianfan.ChatCompletion.models(),
qianfan.Embedding.models(), and the res list for placement.

Source: Coding guidelines

LocalAI supports Ollama-compatible API endpoints that return full model info:
- GET /api/tags returns model list with capabilities
- POST /api/show returns model_info with general.context_length

This provides model types (chat/embedding/image2text), features
(thinking/tools), and real context_length instead of hardcoded 8192.

@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: 1

🤖 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`:
- Line 204: The code that sets context_length uses model_info.get("model_info",
{}).get(...), which will raise AttributeError if model_info["model_info"] is
explicitly null; update the expression to defensively handle null by replacing
model_info.get("model_info", {}) with (model_info.get("model_info") or {}) so
the line becomes something like context_length = (model_info.get("model_info")
or {}).get("general.context_length", 8192); this change in model_meta.py (around
the context_length assignment) ensures safe access when model_info["model_info"]
is None.
🪄 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: 6ecc1985-16c2-43dd-b675-b15737e7f720

📥 Commits

Reviewing files that changed from the base of the PR and between df7ac3d and f5af496.

📒 Files selected for processing (1)
  • rag/llm/model_meta.py

Comment thread rag/llm/model_meta.py
"features": [capability_to_feature_mapping[c] for c in model_info.get("capabilities", []) if c in capability_to_feature_mapping],
"max_tokens": model_info["model_info"].get(max_tokens_key, 8192)
})
context_length = model_info.get("model_info", {}).get("general.context_length", 8192)

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 | 🟡 Minor | ⚡ Quick win

Potential AttributeError if model_info["model_info"] is explicitly null.

If the API returns {"model_info": null}, .get("model_info", {}) returns None (not {}), and the subsequent .get() call raises AttributeError.

🛡️ Proposed defensive fix
-                    context_length = model_info.get("model_info", {}).get("general.context_length", 8192)
+                    context_length = (model_info.get("model_info") or {}).get("general.context_length", 8192)
🤖 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` at line 204, The code that sets context_length uses
model_info.get("model_info", {}).get(...), which will raise AttributeError if
model_info["model_info"] is explicitly null; update the expression to
defensively handle null by replacing model_info.get("model_info", {}) with
(model_info.get("model_info") or {}) so the line becomes something like
context_length = (model_info.get("model_info") or
{}).get("general.context_length", 8192); this change in model_meta.py (around
the context_length assignment) ensures safe access when model_info["model_info"]
is None.

euvre added 2 commits June 8, 2026 13:54
…uction

Without this fix, base_url like 'http://localhost:9997/v1' would produce
doubled paths like '/v1/v1/models' or '/v1/api/tags'.

Added _normalize_base_url() to Base class that strips trailing /v1,
used by all subclasses (Ollama, Xinference, LocalAI).
Previously hardcoded /v1 check. Now handles /v1, /v2, /v3, /v10 etc.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rag/llm/model_meta.py (1)

119-119: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

KeyError if API response lacks "model_info" key.

Direct dictionary access model_info["model_info"] will raise KeyError if the Ollama /api/show response doesn't include the "model_info" key. This is inconsistent with the defensive .get() pattern used on line 113.

🛡️ Proposed fix
                     res.append(
                         {
                             "name": model["name"],
                             "model_types": [capability_to_model_type_mapping[c] for c in model_info.get("capabilities", []) if c in capability_to_model_type_mapping],
                             "features": [capability_to_feature_mapping[c] for c in model_info.get("capabilities", []) if c in capability_to_feature_mapping],
-                            "max_tokens": model_info["model_info"].get(max_tokens_key, 8192),
+                            "max_tokens": model_info.get("model_info", {}).get(max_tokens_key, 8192),
                         }
                     )
🤖 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` at line 119, The line accessing
model_info["model_info"].get(max_tokens_key, 8192) can raise a KeyError if the
Ollama /api/show response lacks "model_info"; change it to safely fall back to
an empty dict (e.g., use model_info.get("model_info", {}) and then
.get(max_tokens_key, 8192)) so the default 8192 is used when "model_info" is
missing—update the expression in rag/llm/model_meta.py where model_info and
max_tokens_key are referenced.
🤖 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.

Outside diff comments:
In `@rag/llm/model_meta.py`:
- Line 119: The line accessing model_info["model_info"].get(max_tokens_key,
8192) can raise a KeyError if the Ollama /api/show response lacks "model_info";
change it to safely fall back to an empty dict (e.g., use
model_info.get("model_info", {}) and then .get(max_tokens_key, 8192)) so the
default 8192 is used when "model_info" is missing—update the expression in
rag/llm/model_meta.py where model_info and max_tokens_key are referenced.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f0238f5-982a-4f1b-a57d-f392e560870f

📥 Commits

Reviewing files that changed from the base of the PR and between f5af496 and d87cd01.

📒 Files selected for processing (1)
  • rag/llm/model_meta.py

…ngth

Xinference's to_description() uses different field names per model type:
- LLM: context_length
- Embedding: max_tokens
- Rerank: neither (default to 8192)

Updated to check both context_length and max_tokens fields.
@euvre
euvre force-pushed the feat/model-meta-xinference-localai-baidu-tencent branch from aada351 to 34689aa Compare June 8, 2026 06:25
@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 (53fd0ad).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15752   +/-   ##
=======================================
  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.

euvre added 3 commits June 8, 2026 16:50
Tencent Hunyuan provides an OpenAI-compatible API. GET /v1/models returns
standard model list. Tencent Cloud (ASR-only) remains NotImplementedError.
…cent

Resolved conflicts: kept all classes from both branches:
- Our classes: Xinference, LocalAI, BaiduYiyan, TencentHunyuan, TencentCloud
- Main's classes: FishAudio, MinerU, OpenRouter, OpenAIAPICompatible, VLLM, LMStudio
Tencent Hunyuan uses standard OpenAI-compatible API, no dedicated class needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants