Skip to content

Commit b3a200d

Browse files
committed
Fix tests.
1 parent 259ad3f commit b3a200d

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

packages/sdk/server-ai/__tests__/LDAIClientImpl.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { LDContext } from '@launchdarkly/js-server-sdk-common';
22

3-
import { LDAIDefaults, LDGenerationConfig } from '../src/api/config';
3+
import { LDAIDefaults } from '../src/api/config';
44
import { LDAIClientImpl } from '../src/LDAIClientImpl';
55
import { 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 () => {
7169
it('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

9189
it('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 () => {
118114
it('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
});

packages/sdk/server-ai/src/api/config/LDAIConfig.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,6 @@ export interface LDMessage {
4040
content: string;
4141
}
4242

43-
/**
44-
* Configuration which affects generation.
45-
*/
46-
export interface LDGenerationConfig {
47-
/**
48-
* Optional model configuration.
49-
*/
50-
model?: LDModelConfig;
51-
/**
52-
* Optional prompt data.
53-
*/
54-
prompt?: LDMessage[];
55-
}
56-
5743
/**
5844
* AI configuration and tracker.
5945
*/

0 commit comments

Comments
 (0)