@posthog/ai
Version:
PostHog Node.js AI integrations
46 lines (42 loc) • 1.68 kB
TypeScript
import { GoogleGenAI, GenerateContentParameters, GenerateContentResponse, GoogleGenAIOptions } from '@google/genai';
import { PostHog } from 'posthog-node';
interface MonitoringEventPropertiesWithDefaults {
distinctId?: string;
traceId: string;
properties?: Record<string, any>;
privacyMode: boolean;
groups?: Record<string, any>;
modelOverride?: string;
providerOverride?: string;
costOverride?: CostOverride;
captureImmediate?: boolean;
}
type MonitoringEventProperties = Partial<MonitoringEventPropertiesWithDefaults>;
type MonitoringParams = {
[K in keyof MonitoringEventProperties as `posthog${Capitalize<string & K>}`]: MonitoringEventProperties[K];
};
interface CostOverride {
inputCost: number;
outputCost: number;
}
interface MonitoringGeminiConfig extends GoogleGenAIOptions {
posthog: PostHog;
}
declare class PostHogGoogleGenAI {
private readonly phClient;
private readonly client;
models: WrappedModels;
constructor(config: MonitoringGeminiConfig);
}
declare class WrappedModels {
private readonly phClient;
private readonly client;
constructor(client: GoogleGenAI, phClient: PostHog);
generateContent(params: GenerateContentParameters & MonitoringParams): Promise<GenerateContentResponse>;
generateContentStream(params: GenerateContentParameters & MonitoringParams): AsyncGenerator<GenerateContentResponse, void, unknown>;
private formatPartsAsContentBlocks;
private formatInput;
private extractSystemInstruction;
private formatInputForPostHog;
}
export { PostHogGoogleGenAI as Gemini, PostHogGoogleGenAI, WrappedModels, PostHogGoogleGenAI as default };