Repository navigation
Conversation
|
Could a maintainer add the |
|
Could a maintainer add the |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughTenant model config resolution now falls back to factory ChangesTenant model max_tokens resolution
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 1
🧹 Nitpick comments (2)
test/unit_test/api/db/joint_services/test_tenant_model_service_max_tokens.py (1)
25-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a regression test for explicit-but-falsy
max_tokensinmodel.extra.Current tests won’t catch the fallback bug when
max_tokensis present but falsy. Add one case to verify key-presence precedence behavior explicitly.🤖 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 `@test/unit_test/api/db/joint_services/test_tenant_model_service_max_tokens.py` around lines 25 - 123, Add a regression test around get_model_config_from_provider_instance to cover explicit-but-falsy max_tokens in model.extra. The current TenantModelService tests only validate empty extra and a truthy override, so add a case where model.extra contains max_tokens with a falsy value (such as 0 or null) and assert the config preserves that explicit value instead of falling back to settings.FACTORY_LLM_INFOS; keep the setup aligned with the existing provider/instance/model monkeypatch pattern in test_max_tokens_falls_back_to_factory_when_model_extra_empty and test_max_tokens_prefers_model_extra_over_factory.api/db/joint_services/tenant_model_service.py (1)
37-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd observability for the new factory/max_tokens fallback flow.
This new path silently falls back when factory/model values are absent; add debug/warn logs around lookup miss and fallback selection to make production diagnosis possible.
As per coding guidelines,
**/*.py: “Add logging for new flows”.Also applies to: 234-243
🤖 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 `@api/db/joint_services/tenant_model_service.py` around lines 37 - 47, The new fallback path in _lookup_factory_llm_info currently returns None or selects a fallback silently, so add observability for both the lookup miss and the fallback choice. Update this helper to emit debug/warn logs when provider_name/pure_model_name cannot be matched in settings.FACTORY_LLM_INFOS and when the special siliconflow intl target_factory_name is selected, so production issues can be diagnosed from logs.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 `@api/db/joint_services/tenant_model_service.py`:
- Line 235: The max_tokens fallback logic in tenant_model_service should
preserve explicitly configured falsy values instead of treating them as missing.
Update the max_tokens assignment to check key presence on model_extra and
llm_info rather than using truthy or chaining, so an explicit value is used
whenever the key exists. Use the max_tokens handling in the tenant_model_service
flow to locate and adjust this logic.
---
Nitpick comments:
In `@api/db/joint_services/tenant_model_service.py`:
- Around line 37-47: The new fallback path in _lookup_factory_llm_info currently
returns None or selects a fallback silently, so add observability for both the
lookup miss and the fallback choice. Update this helper to emit debug/warn logs
when provider_name/pure_model_name cannot be matched in
settings.FACTORY_LLM_INFOS and when the special siliconflow intl
target_factory_name is selected, so production issues can be diagnosed from
logs.
In
`@test/unit_test/api/db/joint_services/test_tenant_model_service_max_tokens.py`:
- Around line 25-123: Add a regression test around
get_model_config_from_provider_instance to cover explicit-but-falsy max_tokens
in model.extra. The current TenantModelService tests only validate empty extra
and a truthy override, so add a case where model.extra contains max_tokens with
a falsy value (such as 0 or null) and assert the config preserves that explicit
value instead of falling back to settings.FACTORY_LLM_INFOS; keep the setup
aligned with the existing provider/instance/model monkeypatch pattern in
test_max_tokens_falls_back_to_factory_when_model_extra_empty and
test_max_tokens_prefers_model_extra_over_factory.
🪄 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: f7fbe974-3298-47ed-b0db-78c4d9a76dbc
📒 Files selected for processing (2)
api/db/joint_services/tenant_model_service.pytest/unit_test/api/db/joint_services/test_tenant_model_service_max_tokens.py
|
Hi maintainers, this branch is current and CodeRabbit is passing. Could you add the |
1 similar comment
|
Hi maintainers, this branch is current and CodeRabbit is passing. Could you add the |
78db4e9 to
f86a0e7
Compare
397a0ea to
b5e59cf
Compare
b5e59cf to
132300d
Compare
|
Synced with latest main. Could a maintainer add the ci label so workflows can run? Okay, please review it. |
2e73788 to
4e8e20e
Compare
a11945c to
390e871
Compare
|
Follow-up: tried syncing with latest |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16364 +/- ##
=======================================
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:
|
Summary
When a
tenant_modelrow exists butextrais empty,get_model_config_from_provider_instancedefaultedmax_tokensto 8192. That silently truncates retrieved knowledge in chat completions even when the factory config defines a much larger context window (e.g. 128000).Fall back to the factory model definition when
tenant_model.extrahas nomax_tokens.Fixes #16362
Test plan
test_max_tokens_falls_back_to_factory_when_model_extra_emptytest_max_tokens_prefers_model_extra_over_factory