11import { LDContext } from '@launchdarkly/js-server-sdk-common' ;
22
3- import { LDAIDefaults , LDGenerationConfig } from '../src/api/config' ;
3+ import { LDAIDefaults } from '../src/api/config' ;
44import { LDAIClientImpl } from '../src/LDAIClientImpl' ;
55import { LDClientMin } from '../src/LDClientMin' ;
66
@@ -56,13 +56,11 @@ it('returns model config with interpolated prompts', async () => {
5656 const result = await client . modelConfig ( key , testContext , defaultValue , variables ) ;
5757
5858 expect ( result ) . toEqual ( {
59- config : {
60- model : { modelId : 'example-provider' , name : 'imagination' } ,
61- prompt : [
62- { role : 'system' , content : 'Hello John' } ,
63- { role : 'user' , content : 'Score: 42' } ,
64- ] ,
65- } ,
59+ model : { modelId : 'example-provider' , name : 'imagination' } ,
60+ prompt : [
61+ { role : 'system' , content : 'Hello John' } ,
62+ { role : 'user' , content : 'Score: 42' } ,
63+ ] ,
6664 tracker : expect . any ( Object ) ,
6765 enabled : true ,
6866 } ) ;
@@ -71,7 +69,7 @@ it('returns model config with interpolated prompts', async () => {
7169it ( 'includes context in variables for prompt interpolation' , async ( ) => {
7270 const client = new LDAIClientImpl ( mockLdClient ) ;
7371 const key = 'test-flag' ;
74- const defaultValue : LDGenerationConfig = {
72+ const defaultValue : LDAIDefaults = {
7573 model : { modelId : 'test' , name : 'test-model' } ,
7674 prompt : [ ] ,
7775 } ;
@@ -85,13 +83,13 @@ it('includes context in variables for prompt interpolation', async () => {
8583
8684 const result = await client . modelConfig ( key , testContext , defaultValue ) ;
8785
88- expect ( result . config . prompt ?. [ 0 ] . content ) . toBe ( 'User key: test-user' ) ;
86+ expect ( result . prompt ?. [ 0 ] . content ) . toBe ( 'User key: test-user' ) ;
8987} ) ;
9088
9189it ( 'handles missing metadata in variation' , async ( ) => {
9290 const client = new LDAIClientImpl ( mockLdClient ) ;
9391 const key = 'test-flag' ;
94- const defaultValue : LDGenerationConfig = {
92+ const defaultValue : LDAIDefaults = {
9593 model : { modelId : 'test' , name : 'test-model' } ,
9694 prompt : [ ] ,
9795 } ;
@@ -106,10 +104,8 @@ it('handles missing metadata in variation', async () => {
106104 const result = await client . modelConfig ( key , testContext , defaultValue ) ;
107105
108106 expect ( result ) . toEqual ( {
109- config : {
110- model : { modelId : 'example-provider' , name : 'imagination' } ,
111- prompt : [ { role : 'system' , content : 'Hello' } ] ,
112- } ,
107+ model : { modelId : 'example-provider' , name : 'imagination' } ,
108+ prompt : [ { role : 'system' , content : 'Hello' } ] ,
113109 tracker : expect . any ( Object ) ,
114110 enabled : false ,
115111 } ) ;
@@ -118,17 +114,19 @@ it('handles missing metadata in variation', async () => {
118114it ( 'passes the default value to the underlying client' , async ( ) => {
119115 const client = new LDAIClientImpl ( mockLdClient ) ;
120116 const key = 'non-existent-flag' ;
121- const defaultValue : LDGenerationConfig = {
117+ const defaultValue : LDAIDefaults = {
122118 model : { modelId : 'default-model' , name : 'default' } ,
123119 prompt : [ { role : 'system' , content : 'Default prompt' } ] ,
120+ enabled : true ,
124121 } ;
125122
126123 mockLdClient . variation . mockResolvedValue ( defaultValue ) ;
127124
128125 const result = await client . modelConfig ( key , testContext , defaultValue ) ;
129126
130127 expect ( result ) . toEqual ( {
131- config : defaultValue ,
128+ model : defaultValue . model ,
129+ prompt : defaultValue . prompt ,
132130 tracker : expect . any ( Object ) ,
133131 enabled : false ,
134132 } ) ;
0 commit comments