All files / src/ai/providers base.ts

100% Statements 30/30
100% Branches 3/3
100% Functions 3/3
100% Lines 30/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 312x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 21x 21x 21x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 8x 8x 8x 2x  
export interface ChatOptions {
  model: string;
  temperature: number;
  maxTokens: number;
  timeoutMs: number;
  seed?: number;
}
 
export abstract class AIProvider {
  abstract id: string;
  abstract name: string;
 
  constructor(
    protected apiKey: string,
    protected baseUrl: string
  ) {}
 
  abstract chat(
    systemPrompt: string,
    userPrompt: string,
    options: ChatOptions
  ): Promise<string>;
}
 
export class EmptyContentError extends Error {
  constructor(detail: string) {
    super(detail);
    this.name = 'EmptyContentError';
  }
}