llmforge
Version:
One API, every AI model, instant switching. Change from GPT-4 to Gemini to local models with a single config update. LLMForge is the lightweight, TypeScript-first solution for multi-provider AI applications with zero vendor lock-in.
57 lines (56 loc) • 2.64 kB
TypeScript
import { Config, GenerateContentRequest, GenerateContentResponse, Tool, Content } from '../types';
import { OpenAIStreamProcessor, StreamOptions } from '../strategies/stream/openai.stream';
import { OpenAIRequest, OpenAIResponse } from '../types';
export declare class OpenAIClient {
private httpClient;
private retryHandler;
private streamProcessor;
constructor(config: Config);
private convertReadableToResponse;
private convertToOpenAIRequest;
private convertContentsToMessages;
private convertToolsToOpenAI;
private convertFromOpenAIResponse;
generateContent(request: GenerateContentRequest): Promise<GenerateContentResponse>;
generateContentStream(request: GenerateContentRequest, options?: StreamOptions): Promise<GenerateContentResponse>;
generateContentStreamAsync(request: GenerateContentRequest): AsyncGenerator<any>;
chat(message: string, options?: {
systemInstruction?: string;
generationConfig?: Config['GenerationConfig'];
tools?: Tool[];
sessionId?: string;
}): Promise<GenerateContentResponse>;
chatStream(message: string, options?: {
systemInstruction?: string;
generationConfig?: Config['GenerationConfig'];
tools?: Tool[];
sessionId?: string;
streamOptions?: StreamOptions;
}): Promise<GenerateContentResponse>;
continueConversation(contents: Content[], options?: {
generationConfig?: Config['GenerationConfig'];
tools?: Tool[];
}): Promise<GenerateContentResponse>;
analyzeImage(base64Image: string, mimeType: string, prompt: string, options?: {
generationConfig?: Config['GenerationConfig'];
}): Promise<GenerateContentResponse>;
analyzeDocument(base64Document: string, mimeType: string, prompt: string, options?: {
generationConfig?: Config['GenerationConfig'];
useCache?: boolean;
cacheTtl?: string;
}): Promise<GenerateContentResponse>;
callFunction(message: string, tools: Tool[], options?: {
generationConfig?: Config['GenerationConfig'];
systemInstruction?: string;
}): Promise<GenerateContentResponse>;
generateWithThinking(message: string, thinkingBudget?: number, options?: {
systemInstruction?: string;
onThinking?: (thinking: string) => void;
effort?: 'low' | 'medium' | 'high';
jsonSchema?: any;
}): Promise<GenerateContentResponse>;
handleOpenAIRequest(openAIRequest: OpenAIRequest): Promise<OpenAIResponse>;
get stream(): OpenAIStreamProcessor;
updateConfig(newConfig: Partial<Config>): void;
getConfig(): Config;
}