Skip to content

Commit

Permalink
feat: node sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
k11kirky committed Jan 20, 2025
1 parent 7b4af21 commit f394f7d
Showing 1 changed file with 0 additions and 65 deletions.
65 changes: 0 additions & 65 deletions posthog-node-ai/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,69 +167,4 @@ export class WrappedCompletions extends OpenAIOrignal.Chat.Completions {
}
}

// export class WrappedEmbeddings {
// private readonly baseEmbeddings: Embedding;
// private readonly phClient: PostHog;
// private readonly parentClient: OpenAI;

// constructor(parentClient: OpenAI, phClient: PostHog) {
// this.baseEmbeddings = parentClient.embeddings;
// this.phClient = phClient;
// this.parentClient = parentClient;
// }

// public create = async (
// params: CreateEmbeddingRequest & {
// posthog_distinct_id?: string;
// posthog_trace_id?: string;
// posthog_properties?: Record<string, any>;
// posthog_privacy_mode?: boolean;
// posthog_groups?: Record<string, any>;
// }
// ) => {
// const {
// posthog_distinct_id,
// posthog_trace_id,
// posthog_properties,
// posthog_privacy_mode,
// posthog_groups,
// ...openAIParams
// } = params;

// const traceId = posthog_trace_id ?? uuidv4();
// const startTime = Date.now();

// let response: any;
// let error: any;

// try {
// response = await this.baseEmbeddings.create(openAIParams);
// } catch (err) {
// error = err;
// throw err;
// } finally {
// const latency = (Date.now() - startTime) / 1000.0;

// // Example usage data from response. The openai Node library may differ slightly:
// const usage_stats = response?.usage ?? {};
// const { prompt_tokens } = usage_stats;

// this.phClient.capture({
// distinctId: posthog_distinct_id ?? traceId,
// event: '$ai_embedding',
// groups: posthog_groups,
// properties: {
// $ai_provider: 'openai',
// $ai_model: openAIParams.model,
// $ai_http_status: error ? 500 : 200,
// $ai_latency: latency,
// $ai_trace_id: traceId,
// $ai_input_tokens: prompt_tokens ?? 0,
// ...posthog_properties,
// },
// });
// }

// return response;

export default PostHogOpenAI;

0 comments on commit f394f7d

Please sign in to comment.