Add Provider Abstraction Layer for AI Module
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- nodejs, typescript
Research direction
Start by locating the existing AI module and its OpenAI-compatible chat and tool-calling logic; the issue does not name files or tests. Compare that flow with the proposed AIProvider interface and identify the smallest agreed first step, since provider priorities and fallback behavior are still open questions. Done would require a tested provider abstraction and configuration-based selection, but the scope needs maintainer clarification.
Written by the indexing model from the issue text.
Description
Summary
- Add abstraction layer for AI providers to support multiple backends (OpenAI-compatible, Anthropic, local models)
- Enable easier provider switching without rewriting tool-calling logic
- Standardize provider capabilities detection (structured output, streaming, etc.)
Motivation
The current AI module design assumes OpenAI-compatible API format. Adding support for other providers (Anthropic, Ollama, LM Studio) would require duplicating tool-calling logic and handling provider-specific differences.
An abstraction layer would:
- Reduce code duplication when adding new providers
- Make provider switching configuration-based
- Allow graceful degradation based on provider capabilities
- Simplify testing with mock providers
Proposed Design
interface AIProvider {
// Core chat completion
chatCompletion(params: ChatParams): Promise<ChatResponse>;
// Capability detection
supportsStructuredOutput(): boolean;
supportsStreaming(): boolean;
supportsToolCalling(): boolean;
// Provider-specific formatting
formatTools(tools: Tool[]): any;
formatMessages(messages: Message[]): any;
}
interface ChatParams {
messages: Message[];
tools?: Tool[];
responseFormat?: 'text' | 'json';
stream?: boolean;
}
class OpenAICompatibleProvider implements AIProvider {
constructor(config: { baseUrl: string; apiKey: string; model: string }) {}
// OpenAI-specific implementation
}
class AnthropicProvider implements AIProvider {
constructor(config: { apiKey: string; model: string }) {}
// Anthropic-specific implementation
}
class LocalProvider implements AIProvider {
constructor(config: { baseUrl: string; model: string }) {}
// Local model server implementation
}
Implementation Plan
- Define
AIProviderinterface and related types - Implement
OpenAICompatibleProvider(refactor existing code) - Add provider factory based on configuration
- Update config to support provider type selection
- Add Anthropic provider (Phase 2B)
- Add local model provider support (Phase 2C)
Benefits
- Single place to handle provider-specific differences
- Easier to add new providers in the future
- Better testability with mock providers
- Cleaner separation of concerns
Drawbacks
- Additional abstraction layer
- May need to handle lowest-common-denominator capabilities
- Slightly more complex initial implementation
Open Questions
- Should we support multiple providers simultaneously (fallback chain)?
- How to handle provider-specific features that don't fit the abstraction?
- What's the priority order for provider implementation?
Generated with Devin
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- Avg merge
- 23h 35m
- Merged PRs (30d)
- 159
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Kuldeep2822k/cli
-
core priority: medium tests
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Kuldeep2822k/cli#484 ·
Maintainers usually reply within 1 day
-
bug core priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Kuldeep2822k/cli#343 · 1 comment ·
Maintainers usually reply within 1 day
-
bug core priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Kuldeep2822k/cli#342 · 1 comment ·
Maintainers usually reply within 1 day
-
bug core priority: medium tests
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Kuldeep2822k/cli#304 · 1 comment ·
Maintainers usually reply within 1 day
-
bug core tests
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Kuldeep2822k/cli#514 ·
Maintainers usually reply within 1 day
All issues in Kuldeep2822k/cli
Similar issues
-
area: repo priority: P2 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
appandflow/stim#4107 · 1 comment ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 1-3 hours Newbie friendliness 60/100
lingdojo/kana-dojo#32859 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
github/gh-aw-firewall#10364 ·
Maintainers usually reply within 1 day
-
Merge the duplicate kaffir_corn record into sorghumPossibly taken @Crypto-Shroom claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Crypto-Shroom/Bird-Feed-Calculator#322 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
drizzle-team/drizzle-orm#6552 ·
Maintainers usually reply within 2 days