byterover-cli
byterover-cli copied to clipboard
Add LLM Providers
LLM Provider Support
Overview: Add support for additional LLM providers to expand Cipher's model compatibility and reduce vendor lock-in.
Provider Implementations
1. Deepseek Provider
Technical Requirements:
- Create
src/core/brain/llm/services/deepseek.ts - Install Deepseek API client or implement HTTP client
2. Groq Provider
Technical Requirements:
- Create
src/core/brain/llm/services/groq.ts - Install Groq SDK (
npm install groq-sdk)
3. vLLM Provider
Technical Requirements:
- Create
src/core/brain/llm/services/vllm.ts - Support OpenAI-compatible API endpoints
4. xAI Provider
Technical Requirements:
- Create
src/core/brain/llm/services/xai.ts - Implement xAI API integration
- Support Grok model family
- Add proper authentication and API key management
Common Implementation Pattern
All providers should follow the existing service pattern at src/core/brain/llm/services/:
- Extend base LLM service interface
- Implement standardized response formatting
- Add comprehensive error handling
- Support streaming and non-streaming modes
- Include usage tracking and monitoring
- Add proper TypeScript types and validation
Implementation Template
import { BaseLLMService } from './base.js';
import type { LLMConfig, LLMResponse } from './types.js';
export class ProviderService extends BaseLLMService {
constructor(config: LLMConfig) {
super(config);
}
async generateCompletion(prompt: string): Promise<LLMResponse> {
// Implementation
}
async generateStreamingCompletion(prompt: string): AsyncIterable<LLMResponse> {
// Implementation
}
}
Configuration Structure
interface ProviderConfig {
apiKey: string;
baseUrl?: string;
model: string;
maxTokens?: number;
temperature?: number;
timeout?: number;
}
Testing Requirements
- Unit tests for each provider
- Integration tests with mock responses
- Load testing for performance validation
- Error scenario testing
- Cost monitoring validation
Integration Steps
- Create service class in
src/core/brain/llm/services/ - Add provider to factory pattern in
factory.ts - Update service exports in
index.ts - Add configuration schema
- Create comprehensive tests
- Update documentation
Success Criteria
- All providers follow existing architectural patterns
- Streaming and non-streaming support
- Proper error handling and retry logic
- Cost and usage tracking
- Comprehensive test coverage
- Performance benchmarks
have you think about using langchain for this instead of multiple separate LLM client
https://js.langchain.com/docs/introduction/
@RyanNg1403 can you clarify what closing this issue means?
Right now I don't see src/core/brain/llm/services/xai.ts. Does this mean X.ai is:
- Won't implement?
- Currently supported, but some other way?
- PR welcome?