[llm] customize provider URL#29
Conversation
🤖 Pull request artifacts
|
|
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)
WalkthroughThe LLM plugin adds a configurable ChangesLLM base URL configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Plugin
participant LLMConfig
participant OpenRouter
Plugin->>LLMConfig: Read BaseURL
LLMConfig-->>Plugin: Configured or default URL
Plugin->>OpenRouter: NewClientWithConfig(ClientConfig)
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 (1)
internal/censor/plugins/llm/llm.go (1)
52-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
DefaultBaseURLinstead of hardcoding the URL.The fallback URL duplicates the
DefaultBaseURLconstant defined inconfig.go. If the default ever changes, this hardcoded string will silently diverge.♻️ Proposed fix
- baseURL := "https://openrouter.ai/api/v1" + baseURL := DefaultBaseURL if config.BaseURL != "" { baseURL = config.BaseURL }🤖 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 `@internal/censor/plugins/llm/llm.go` around lines 52 - 55, Update the baseURL initialization in the LLM plugin to use the existing DefaultBaseURL constant from config.go instead of duplicating the OpenRouter URL literal, while preserving the config.BaseURL override behavior.
🤖 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 `@internal/censor/plugins/llm/llm.go`:
- Around line 57-65: Update the OpenRouter client initialization around the
clientConfig construction to use openrouter.NewClient with config.APIKey and
provide a real http.Client instead of leaving HTTPClient nil; ensure the
resulting client preserves the existing BaseURL, HttpReferer, XTitle, and other
configuration values so authenticated requests execute without panicking.
---
Nitpick comments:
In `@internal/censor/plugins/llm/llm.go`:
- Around line 52-55: Update the baseURL initialization in the LLM plugin to use
the existing DefaultBaseURL constant from config.go instead of duplicating the
OpenRouter URL literal, while preserving the config.BaseURL override 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: 951b93a3-da57-408a-89e1-30351e9256e5
📒 Files selected for processing (3)
README.mdinternal/censor/plugins/llm/config.gointernal/censor/plugins/llm/llm.go
284af0e to
1dea5d7
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/censor/plugins/llm/config_test.go (1)
42-51: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdd coverage for a custom
base_url.This test currently validates only the default URL, so a regression in
NewConfig’s custombase_urlparsing would pass unnoticed. Includebase_urlin the input and assert the same custom value in the expected config.Proposed test update
config: map[string]any{ "api_key": "test-key", "model": "gpt-4", + "base_url": "https://custom.example/v1", "confidence_threshold": 0.9, "timeout": "45s", "prompt": "Custom prompt", "temperature": 0.7, }, want: llm.Config{ - BaseURL: llm.DefaultBaseURL, + BaseURL: "https://custom.example/v1",🤖 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 `@internal/censor/plugins/llm/config_test.go` around lines 42 - 51, Add custom base_url coverage to the NewConfig test by including a non-default base_url in the input config map and asserting that exact value in the expected llm.Config.BaseURL field, while preserving the existing assertions for other fields.
🤖 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 `@internal/censor/plugins/llm/config_test.go`:
- Around line 42-51: Add custom base_url coverage to the NewConfig test by
including a non-default base_url in the input config map and asserting that
exact value in the expected llm.Config.BaseURL field, while preserving the
existing assertions for other fields.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a049ee4e-a24f-4f9c-8aa9-9e3f672eae7a
📒 Files selected for processing (4)
README.mdinternal/censor/plugins/llm/config.gointernal/censor/plugins/llm/config_test.gointernal/censor/plugins/llm/llm.go
🚧 Files skipped from review as they are similar to previous changes (3)
- README.md
- internal/censor/plugins/llm/llm.go
- internal/censor/plugins/llm/config.go
Summary by CodeRabbit
base_urlnow respected when creating the LLM client.base_urloption in the LLM YAML example.base_urlvalues.