File tree Expand file tree Collapse file tree 5 files changed +23
-10
lines changed
packages/sdk/server-ai/examples/tracked-chat Expand file tree Collapse file tree 5 files changed +23
-10
lines changed Original file line number Diff line number Diff line change 3333 " packages/sdk/server-ai" ,
3434 " packages/sdk/server-ai/examples/bedrock" ,
3535 " packages/sdk/server-ai/examples/openai" ,
36+ " packages/sdk/server-ai/examples/tracked-chat" ,
3637 " packages/sdk/server-ai/examples/vercel-ai" ,
37- " packages/sdk/server-ai/examples/langchain-chat" ,
3838 " packages/telemetry/browser-telemetry" ,
3939 " contract-tests" ,
4040 " packages/sdk/combined-browser"
Original file line number Diff line number Diff line change 1- # LangChain Chat Example
1+ # Tracked Chat Example
22
3- This example demonstrates how to use the LaunchDarkly AI SDK with LangChain for chat interactions.
3+ This example demonstrates how to use the LaunchDarkly AI SDK chat functionality with multiple providers for tracked chat interactions.
44
55## Prerequisites
66
771 . A LaunchDarkly account and SDK key
8- 1 . An OpenAI API key (for the LangChain integration )
8+ 1 . An OpenAI API key (for the AI provider )
991 . Node.js 16 or later
1010
1111## Setup
@@ -72,5 +72,5 @@ This will:
7272- ** AI Config Integration** : Using LaunchDarkly to configure AI models and prompts
7373- ** Variable Interpolation** : Using Mustache templates with runtime variables
7474- ** Chat Conversations** : Multi-turn conversations with message history
75- - ** Provider Integration** : Using LangChain as the AI provider
75+ - ** Provider Integration** : Using multiple AI providers through the LaunchDarkly AI SDK
7676- ** Metrics Tracking** : Automatic tracking of token usage and performance
Original file line number Diff line number Diff line change 11{
2- "name" : " langchain -chat-example" ,
2+ "name" : " tracked -chat-example" ,
33 "version" : " 1.0.0" ,
4- "description" : " Example demonstrating LaunchDarkly AI SDK with LangChain " ,
4+ "description" : " Example demonstrating LaunchDarkly AI SDK chat functionality with multiple providers " ,
55 "type" : " module" ,
66 "scripts" : {
77 "build" : " tsc" ,
88 "start" : " yarn build && node ./dist/index.js"
99 },
1010 "dependencies" : {
11+ "@ai-sdk/google" : " ^2.0.20" ,
1112 "@langchain/core" : " ^0.3.78" ,
1213 "@langchain/google-genai" : " ^0.2.18" ,
1314 "@launchdarkly/node-server-sdk" : " ^9.0.0" ,
1415 "@launchdarkly/server-sdk-ai" : " 0.11.4" ,
15- "@launchdarkly/server-sdk-ai-langchain" : " 0.1.0" ,
16+ "@launchdarkly/server-sdk-ai-langchain" : " 0.0.0" ,
17+ "@launchdarkly/server-sdk-ai-vercel" : " 0.0.0" ,
1618 "dotenv" : " ^16.0.0" ,
1719 "langchain" : " ^0.1.0"
1820 },
Original file line number Diff line number Diff line change 11/* eslint-disable no-console */
2- import { init , type LDContext } from '@launchdarkly/node-server-sdk' ;
2+ import {
3+ basicLogger ,
4+ init ,
5+ type LDContext ,
6+ LDLogger ,
7+ LDOptions ,
8+ } from '@launchdarkly/node-server-sdk' ;
39import { initAi } from '@launchdarkly/server-sdk-ai' ;
410
511// Environment variables
@@ -12,8 +18,13 @@ if (!sdkKey) {
1218 process . exit ( 1 ) ;
1319}
1420
21+ const logger = basicLogger ( { level : 'debug' , destination : console . log } ) ;
22+ const options : LDOptions = {
23+ logger,
24+ } ;
25+
1526// Initialize LaunchDarkly client
16- const ldClient = init ( sdkKey ) ;
27+ const ldClient = init ( sdkKey , options ) ;
1728
1829// Set up the context properties. This context should appear on your LaunchDarkly contexts dashboard
1930// soon after you run the demo.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments