pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
62 lines (61 loc) • 2.36 kB
TypeScript
import OpenAI from 'openai';
import { LLMBase, LLMConfig } from './llm-base';
import QueryCache from './query-cache';
export declare class PerplexityHelper extends LLMBase {
private static readonly BASE_URL;
static readonly MODELS: {
readonly SONAR_SMALL: "llama-3.1-sonar-small-128k-online";
readonly SONAR_LARGE: "llama-3.1-sonar-large-128k-online";
readonly SONAR_HUGE: "llama-3.1-sonar-huge-128k-online";
readonly CHAT_SMALL: "llama-3.1-sonar-small-128k-chat";
readonly CHAT_LARGE: "llama-3.1-sonar-large-128k-chat";
readonly LEGACY_7B: "pplx-7b-online";
readonly LEGACY_70B: "pplx-70b-online";
};
constructor(apiKey?: string, openaiInstance?: OpenAI, model?: string, cache?: QueryCache);
protected createOpenAIInstance(config: LLMConfig): OpenAI;
protected getApiKey(): string;
protected getProviderName(): string;
/**
* Create a PerplexityHelper instance with Firebase Remote Config
*/
static createWithRemoteConfig(modelOverride?: string): Promise<PerplexityHelper>;
/**
* Get list of available Perplexity models
*/
static getAvailableModels(): string[];
/**
* Check if a model supports web search
*/
static isOnlineModel(model: string): boolean;
/**
* Override generateEmbedding - Perplexity doesn't support embeddings
* This will throw an error if called
*/
generateEmbedding(text: string): Promise<number[]>;
/**
* Override fetchStructuredDataFromWeb to use Perplexity's native web search
* Note: Perplexity models with 'online' suffix have built-in web search
*/
fetchStructuredDataFromWeb<T extends import('zod').ZodTypeAny>(params: {
model?: string;
prompt: string;
recommendedSources?: string[];
zodSchema: T;
userLocation: any;
locationGranularity: string;
systemPrompt?: string;
timeline?: string;
responseFormatName?: string;
customFormat?: (schema: import('zod').ZodTypeAny, name: string) => any;
options?: Record<string, any>;
}): Promise<import('zod').z.infer<T>>;
/**
* Get rate limit information from response headers
*/
getRateLimitInfo(response: any): {
remaining: number;
reset: Date;
limit: number;
} | null;
}