Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(llm-observability): OpenAI TypeScript SDK #343

Merged
merged 20 commits into from
Jan 20, 2025

Conversation

k11kirky
Copy link
Contributor

@k11kirky k11kirky commented Jan 17, 2025

Initial Typescript SDK for LLM Observability

// before

import { OpenAI } from 'openai';

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY || '',
});

client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello, world!' }],
});

// after

import { OpenAI } from 'posthog-node-ai'

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY || '',
  posthog: phClient,
});

client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello, world!' }],
  posthog_distinct_id: 'test-user-id',
  posthog_properties: {
    test_property: 'test_value'
  }
});

Copy link

github-actions bot commented Jan 17, 2025

Size Change: 0 B

Total Size: 109 kB

ℹ️ View Unchanged
Filename Size
posthog-node/lib/index.cjs.js 20.8 kB
posthog-node/lib/index.esm.js 20.7 kB
posthog-react-native/lib/posthog-core/src/eventemitter.js 1.08 kB
posthog-react-native/lib/posthog-core/src/index.js 10 kB
posthog-react-native/lib/posthog-core/src/lz-string.js 1.42 kB
posthog-react-native/lib/posthog-core/src/types.js 420 B
posthog-react-native/lib/posthog-core/src/utils.js 870 B
posthog-react-native/lib/posthog-core/src/vendor/uuidv7.js 2.04 kB
posthog-react-native/lib/posthog-react-native/index.js 485 B
posthog-react-native/lib/posthog-react-native/src/autocapture.js 1.8 kB
posthog-react-native/lib/posthog-react-native/src/frameworks/wix-navigation.js 651 B
posthog-react-native/lib/posthog-react-native/src/hooks/useFeatureFlag.js 437 B
posthog-react-native/lib/posthog-react-native/src/hooks/useFeatureFlags.js 362 B
posthog-react-native/lib/posthog-react-native/src/hooks/useLifecycleTracker.js 416 B
posthog-react-native/lib/posthog-react-native/src/hooks/useNavigationTracker.js 628 B
posthog-react-native/lib/posthog-react-native/src/hooks/usePostHog.js 249 B
posthog-react-native/lib/posthog-react-native/src/legacy.js 810 B
posthog-react-native/lib/posthog-react-native/src/native-deps.js 1.2 kB
posthog-react-native/lib/posthog-react-native/src/optional/OptionalAsyncStorage.js 183 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoApplication.js 215 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoDevice.js 211 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoFileSystem.js 224 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoLocalization.js 216 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalReactNativeDeviceInfo.js 220 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalReactNativeNavigation.js 218 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalReactNativeNavigationWix.js 222 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalSessionReplay.js 231 B
posthog-react-native/lib/posthog-react-native/src/posthog-rn.js 4.42 kB
posthog-react-native/lib/posthog-react-native/src/PostHogContext.js 210 B
posthog-react-native/lib/posthog-react-native/src/PostHogProvider.js 1.57 kB
posthog-react-native/lib/posthog-react-native/src/storage.js 1.09 kB
posthog-react-native/lib/posthog-react-native/src/types.js 90 B
posthog-react-native/lib/posthog-react-native/src/version.js 123 B
posthog-web/lib/index.cjs.js 17.8 kB
posthog-web/lib/index.esm.js 17.8 kB

compressed-size-action

@k11kirky k11kirky changed the title WIP feat: POC for Open AI typescript SDK Feat(LLM-Observability): Open AI typescript SDK Jan 20, 2025
@k11kirky k11kirky marked this pull request as ready for review January 20, 2025 08:16
@k11kirky k11kirky requested review from timgl, Twixes and skoob13 January 20, 2025 08:31
posthog-node-ai/package.json Outdated Show resolved Hide resolved
posthog-node-ai/package.json Outdated Show resolved Hide resolved
posthog-node-ai/utils.ts Outdated Show resolved Hide resolved
posthog-ai/package.json Outdated Show resolved Hide resolved
@k11kirky k11kirky requested a review from Twixes January 20, 2025 18:25
@Twixes Twixes changed the title Feat(LLM-Observability): Open AI typescript SDK feat(llm-observability): OpenAI TypeScript SDK Jan 20, 2025
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go

@k11kirky k11kirky merged commit c60f8a2 into main Jan 20, 2025
4 checks passed
@k11kirky k11kirky deleted the feat/ai-llm-observability branch January 20, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants