pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
34 lines (33 loc) • 1.31 kB
TypeScript
import OpenAI from 'openai';
import { LLMBase, LLMConfig } from './llm-base';
/**
* OpenAI Helper - Uses only OpenAI API and models
* Supports: GPT-4, GPT-3.5, etc.
*/
export default class OpenAIHelper extends LLMBase {
constructor(apiKey?: string, openaiInstance?: OpenAI, model?: string);
/**
* Create OpenAI helper with model from remote config
* Falls back to env vars and defaults if remote config fails
*/
static createWithRemoteConfig(apiKey?: string, openaiInstance?: OpenAI): Promise<OpenAIHelper>;
/**
* Update the model from remote config
* Useful for long-running instances that need to pick up config changes
*/
updateModelFromRemoteConfig(): Promise<void>;
protected createOpenAIInstance(config: LLMConfig): OpenAI;
protected getApiKey(): string;
protected getProviderName(): string;
getAvailableModels(): Promise<string[]>;
/**
* Generate embedding using OpenAI's text-embedding models
* This is used for vector search functionality
*/
generateEmbedding(text: string, model?: string): Promise<number[]>;
/**
* Generate embeddings for multiple texts in one request
* More efficient for batch processing
*/
generateEmbeddings(texts: string[], model?: string): Promise<number[][]>;
}