-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Add support for TrackedChats in the AI SDK #939
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
base: main
Are you sure you want to change the base?
Conversation
@launchdarkly/browser size report |
@launchdarkly/js-sdk-common size report |
@launchdarkly/js-client-sdk size report |
@launchdarkly/js-client-sdk-common size report |
// Try specific implementations for the provider | ||
switch (providerName) { | ||
case 'openai': | ||
trackedChat = undefined; | ||
break; | ||
case 'bedrock': | ||
trackedChat = undefined; | ||
break; | ||
default: | ||
trackedChat = undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the plan is to fill this out later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we will add support for additional providers
// Track chat initialization | ||
this._ldClient.track('$ld:ai:config:function:initChat', context, key, 1); | ||
|
||
const config = await this.config(key, context, defaultValue, variables); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not care for this line. Can we rename one of these configs to disambiguate them?
Note
Adds a provider-based TrackedChat with initChat entrypoint, generic metrics tracking via trackMetricsOf, and logger-enabled client/provider wiring.
TrackedChat
,TrackedChatFactory
, and abstractAIProvider
withinvokeModel
and staticcreate
.ChatResponse
and export new chat modules (src/api/chat/*
).initChat(key, context, defaultValue, variables?)
toLDAIClient
/LDAIClientImpl
; emits'$ld:ai:config:function:initChat'
and returnsTrackedChat | undefined
.LDLogger
intoLDAIClientImpl
and exposelogger?
onLDClientMin
.LDAIMetrics
and export viaapi/metrics
.LDAIConfigTracker.trackMetricsOf
to record duration, success/error, and optional token usage; use inTrackedChat.invoke
.TrackedChat
tests for message history and invoke integration.LDAIConfigTrackerImpl
tests to covertrackMetricsOf
success/failure and token usage.api/index.ts
.tsconfig.eslint.json
includes/excludes.Written by Cursor Bugbot for commit cd534e3. This will update automatically on new commits. Configure here.