Skip to content

[llm] customize provider URL#29

Open
capcom6 wants to merge 2 commits into
masterfrom
llm/customize-llm-provider-url
Open

[llm] customize provider URL#29
capcom6 wants to merge 2 commits into
masterfrom
llm/customize-llm-provider-url

Conversation

@capcom6

@capcom6 capcom6 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added support for configuring a custom LLM API base URL.
    • The default API endpoint remains OpenRouter, with custom base_url now respected when creating the LLM client.
  • Documentation
    • Updated setup documentation to include the new base_url option in the LLM YAML example.
  • Tests
    • Updated configuration tests to cover the default and custom base_url values.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 censor-tg-bot_Darwin_arm64.tar.gz
🍎 Darwin x86_64 censor-tg-bot_Darwin_x86_64.tar.gz
🐧 Linux arm64 censor-tg-bot_Linux_arm64.tar.gz
🐧 Linux i386 censor-tg-bot_Linux_i386.tar.gz
🐧 Linux x86_64 censor-tg-bot_Linux_x86_64.tar.gz
🪟 Windows arm64 censor-tg-bot_Windows_arm64.zip
🪟 Windows i386 censor-tg-bot_Windows_i386.zip
🪟 Windows x86_64 censor-tg-bot_Windows_x86_64.zip

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

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: 32d1511a-4018-4d51-8c9b-ebfb5a9e3eea

📥 Commits

Reviewing files that changed from the base of the PR and between 1dea5d7 and df5fdb9.

📒 Files selected for processing (1)
  • internal/censor/plugins/llm/config_test.go

Walkthrough

The LLM plugin adds a configurable base_url, defaults it to the OpenRouter API endpoint, documents the setting, tests the parsed configuration, and uses it when constructing the OpenRouter client with explicit metadata.

Changes

LLM base URL configuration

Layer / File(s) Summary
Base URL configuration contract
internal/censor/plugins/llm/config.go, internal/censor/plugins/llm/config_test.go, README.md
Adds the exported default URL, Config.BaseURL, parsing and default initialization, matching configuration tests, and the README example.
Config-driven client initialization
internal/censor/plugins/llm/llm.go
Builds the OpenRouter client from the configured or default base URL using openrouter.ClientConfig and fixed metadata settings.

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)
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding configurable provider base URL support for the LLM plugin.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch llm/customize-llm-provider-url

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/censor/plugins/llm/llm.go (1)

52-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use DefaultBaseURL instead of hardcoding the URL.

The fallback URL duplicates the DefaultBaseURL constant defined in config.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

📥 Commits

Reviewing files that changed from the base of the PR and between 39c066f and ad44be1.

📒 Files selected for processing (3)
  • README.md
  • internal/censor/plugins/llm/config.go
  • internal/censor/plugins/llm/llm.go

Comment thread internal/censor/plugins/llm/llm.go Outdated
@capcom6
capcom6 force-pushed the llm/customize-llm-provider-url branch from 284af0e to 1dea5d7 Compare July 14, 2026 01:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
internal/censor/plugins/llm/config_test.go (1)

42-51: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add coverage for a custom base_url.

This test currently validates only the default URL, so a regression in NewConfig’s custom base_url parsing would pass unnoticed. Include base_url in 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

📥 Commits

Reviewing files that changed from the base of the PR and between 284af0e and 1dea5d7.

📒 Files selected for processing (4)
  • README.md
  • internal/censor/plugins/llm/config.go
  • internal/censor/plugins/llm/config_test.go
  • internal/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant