byterover-cli icon indicating copy to clipboard operation
byterover-cli copied to clipboard

Add LLM Providers

Open RyanNg1403 opened this issue 1 year ago • 2 comments

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

  1. Create service class in src/core/brain/llm/services/
  2. Add provider to factory pattern in factory.ts
  3. Update service exports in index.ts
  4. Add configuration schema
  5. Create comprehensive tests
  6. 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

RyanNg1403 avatar Aug 08 '25 18:08 RyanNg1403

have you think about using langchain for this instead of multiple separate LLM client

https://js.langchain.com/docs/introduction/

phamleduy04 avatar Aug 12 '25 05:08 phamleduy04

@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?

taqtiqa-mark avatar Oct 25 '25 23:10 taqtiqa-mark