-
Notifications
You must be signed in to change notification settings - Fork 19
Add unified LLM provider interface and refactor CLI integration #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughReplaces per-provider commit message generation with a unified llm.Provider interface and factory. CLI now creates providers via llm.NewProvider and calls provider.Generate with context. Adds standardized credential handling with ErrMissingCredential and provider-specific hints. Introduces provider registry and concrete implementations plus unit tests for factory, env fallback, overrides, and defaults. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as CLI (createMsg)
participant LLM as llm.NewProvider
participant Prov as Provider
participant Backend as LLM Backend
User->>CLI: request commit message
CLI->>LLM: NewProvider(name, options)
LLM-->>CLI: Provider instance or error
alt Provider created
CLI->>Prov: Generate(ctx, changes, opts)
Prov->>Backend: GenerateCommitMessage(...)
Backend-->>Prov: message or error
Prov-->>CLI: message or error
alt Success
CLI-->>User: display message
else Error
CLI->>CLI: displayProviderError(...)
CLI-->>User: error + hint
end
else Missing credential
CLI->>CLI: displayMissingCredentialHint(name)
CLI-->>User: credential guidance
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code graph analysis (3)internal/llm/provider.go (2)
internal/llm/provider_test.go (2)
cmd/cli/createMsg.go (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Comment |
DFanso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
Description
This PR introduces a reusable LLM provider interface with factory-based construction and refactors the commit message workflow to depend on it. It consolidates provider-specific logic, standardizes credential handling, and improves error messages so new providers can be added with minimal wiring.
Type of Change
Related Issue
Fixes #9
Changes Made
internal/llmwith a provider interface, factory registry, and concrete adapters for each existing LLM backend.CreateCommitMsgto instantiate providers through the new abstraction, reuse them across regenerations, and surface clearer credential guidance.Testing
Checklist
Screenshots (if applicable)
N/A
Additional Notes
llm.RegisterFactory, enabling easy experimentation with new backends without modifying the CLI.For Hacktoberfest Participants
Summary by CodeRabbit
New Features
Refactor