Skip to content

Commit c51d811

Browse files
committed
fix naming of completion config type
1 parent c682595 commit c51d811

File tree

7 files changed

+42
-46
lines changed

7 files changed

+42
-46
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LDContext } from '@launchdarkly/js-server-sdk-common';
22

33
import {
44
LDAIAgentConfigDefault,
5-
LDAIConversationConfigDefault,
5+
LDAICompletionConfigDefault,
66
LDAIJudgeConfigDefault,
77
} from '../src/api/config/types';
88
import { Judge } from '../src/api/judge/Judge';
@@ -29,7 +29,7 @@ const testContext: LDContext = { kind: 'user', key: 'test-user' };
2929
it('returns config with interpolated messages', async () => {
3030
const client = new LDAIClientImpl(mockLdClient);
3131
const key = 'test-flag';
32-
const defaultValue: LDAIConversationConfigDefault = {
32+
const defaultValue: LDAICompletionConfigDefault = {
3333
model: { name: 'test', parameters: { name: 'test-model' } },
3434
messages: [],
3535
enabled: true,
@@ -88,7 +88,7 @@ it('returns config with interpolated messages', async () => {
8888
it('includes context in variables for messages interpolation', async () => {
8989
const client = new LDAIClientImpl(mockLdClient);
9090
const key = 'test-flag';
91-
const defaultValue: LDAIConversationConfigDefault = {
91+
const defaultValue: LDAICompletionConfigDefault = {
9292
model: { name: 'test', parameters: { name: 'test-model' } },
9393
messages: [],
9494
};
@@ -109,7 +109,7 @@ it('includes context in variables for messages interpolation', async () => {
109109
it('handles missing metadata in variation', async () => {
110110
const client = new LDAIClientImpl(mockLdClient);
111111
const key = 'test-flag';
112-
const defaultValue: LDAIConversationConfigDefault = {
112+
const defaultValue: LDAICompletionConfigDefault = {
113113
model: { name: 'test', parameters: { name: 'test-model' } },
114114
messages: [],
115115
};
@@ -134,7 +134,7 @@ it('handles missing metadata in variation', async () => {
134134
it('passes the default value to the underlying client', async () => {
135135
const client = new LDAIClientImpl(mockLdClient);
136136
const key = 'non-existent-flag';
137-
const defaultValue: LDAIConversationConfigDefault = {
137+
const defaultValue: LDAICompletionConfigDefault = {
138138
model: { name: 'default-model', parameters: { name: 'default' } },
139139
provider: { name: 'default-provider' },
140140
messages: [{ role: 'system', content: 'Default messages' }],

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { TrackedChat } from '../src/api/chat/TrackedChat';
22
import { ChatResponse } from '../src/api/chat/types';
33
import { LDAIConfigTracker } from '../src/api/config/LDAIConfigTracker';
4-
import { LDAIConversationConfig, LDMessage } from '../src/api/config/types';
4+
import { LDAICompletionConfig, LDMessage } from '../src/api/config/types';
55
import { AIProvider } from '../src/api/providers/AIProvider';
66

77
describe('TrackedChat', () => {
88
let mockProvider: jest.Mocked<AIProvider>;
99
let mockTracker: jest.Mocked<LDAIConfigTracker>;
10-
let aiConfig: LDAIConversationConfig;
10+
let aiConfig: LDAICompletionConfig;
1111

1212
beforeEach(() => {
1313
// Mock the AIProvider
@@ -136,7 +136,7 @@ describe('TrackedChat', () => {
136136
});
137137

138138
it('returns empty array when no messages exist and includeConfigMessages is false', () => {
139-
const configWithoutMessages: LDAIConversationConfig = {
139+
const configWithoutMessages: LDAICompletionConfig = {
140140
...aiConfig,
141141
messages: [],
142142
};
@@ -167,7 +167,7 @@ describe('TrackedChat', () => {
167167
});
168168

169169
it('handles undefined config messages gracefully', () => {
170-
const configWithoutMessages: LDAIConversationConfig = {
170+
const configWithoutMessages: LDAICompletionConfig = {
171171
...aiConfig,
172172
messages: undefined,
173173
};

packages/sdk/server-ai/src/LDAIClientImpl.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
LDAIAgentConfig,
88
LDAIAgentConfigDefault,
99
LDAIAgentRequestConfig,
10+
LDAICompletionConfig,
11+
LDAICompletionConfigDefault,
1012
LDAIConfigDefaultKind,
1113
LDAIConfigKind,
1214
LDAIConfigMode,
13-
LDAIConversationConfig,
14-
LDAIConversationConfigDefault,
1515
LDAIJudgeConfig,
1616
LDAIJudgeConfigDefault,
1717
LDJudge,
@@ -89,10 +89,10 @@ export class LDAIClientImpl implements LDAIClient {
8989
}
9090

9191
private _applyInterpolation(
92-
config: LDAIConversationConfig | LDAIAgentConfig | LDAIJudgeConfig,
92+
config: LDAIConfigKind,
9393
context: LDContext,
9494
variables?: Record<string, unknown>,
95-
): LDAIConversationConfig | LDAIAgentConfig | LDAIJudgeConfig {
95+
): LDAIConfigKind {
9696
const allVariables = { ...variables, ldctx: context };
9797

9898
if ('messages' in config && config.messages) {
@@ -115,7 +115,7 @@ export class LDAIClientImpl implements LDAIClient {
115115
return config;
116116
}
117117

118-
private _addVercelAISDKSupport(config: LDAIConversationConfig): LDAIConversationConfig {
118+
private _addVercelAISDKSupport(config: LDAICompletionConfig): LDAICompletionConfig {
119119
const { messages } = config;
120120
const mapper = new LDAIConfigMapper(config.model, config.provider, messages);
121121

@@ -160,13 +160,13 @@ export class LDAIClientImpl implements LDAIClient {
160160
async completionConfig(
161161
key: string,
162162
context: LDContext,
163-
defaultValue: LDAIConversationConfigDefault,
163+
defaultValue: LDAICompletionConfigDefault,
164164
variables?: Record<string, unknown>,
165-
): Promise<LDAIConversationConfig> {
165+
): Promise<LDAICompletionConfig> {
166166
this._ldClient.track(TRACK_CONFIG_SINGLE, context, key, 1);
167167

168168
const config = await this._evaluate(key, context, defaultValue, 'completion', variables);
169-
return this._addVercelAISDKSupport(config as LDAIConversationConfig);
169+
return this._addVercelAISDKSupport(config as LDAICompletionConfig);
170170
}
171171

172172
/**
@@ -175,9 +175,9 @@ export class LDAIClientImpl implements LDAIClient {
175175
async config(
176176
key: string,
177177
context: LDContext,
178-
defaultValue: LDAIConversationConfigDefault,
178+
defaultValue: LDAICompletionConfigDefault,
179179
variables?: Record<string, unknown>,
180-
): Promise<LDAIConversationConfig> {
180+
): Promise<LDAICompletionConfig> {
181181
return this.completionConfig(key, context, defaultValue, variables);
182182
}
183183

@@ -254,7 +254,7 @@ export class LDAIClientImpl implements LDAIClient {
254254
async createChat(
255255
key: string,
256256
context: LDContext,
257-
defaultValue: LDAIConversationConfigDefault,
257+
defaultValue: LDAICompletionConfigDefault,
258258
variables?: Record<string, unknown>,
259259
defaultAiProvider?: SupportedAIProvider,
260260
): Promise<TrackedChat | undefined> {
@@ -335,7 +335,7 @@ export class LDAIClientImpl implements LDAIClient {
335335
async initChat(
336336
key: string,
337337
context: LDContext,
338-
defaultValue: LDAIConversationConfigDefault,
338+
defaultValue: LDAICompletionConfigDefault,
339339
variables?: Record<string, unknown>,
340340
defaultAiProvider?: SupportedAIProvider,
341341
): Promise<TrackedChat | undefined> {

packages/sdk/server-ai/src/api/LDAIClient.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
LDAIAgentConfig,
66
LDAIAgentConfigDefault,
77
LDAIAgentRequestConfig,
8-
LDAIConversationConfig,
9-
LDAIConversationConfigDefault,
8+
LDAICompletionConfig,
9+
LDAICompletionConfigDefault,
1010
LDAIJudgeConfig,
1111
LDAIJudgeConfigDefault,
1212
} from './config';
@@ -73,19 +73,19 @@ export interface LDAIClient {
7373
completionConfig(
7474
key: string,
7575
context: LDContext,
76-
defaultValue: LDAIConversationConfigDefault,
76+
defaultValue: LDAICompletionConfigDefault,
7777
variables?: Record<string, unknown>,
78-
): Promise<LDAIConversationConfig>;
78+
): Promise<LDAICompletionConfig>;
7979

8080
/**
8181
* @deprecated Use `completionConfig` instead. This method will be removed in a future version.
8282
*/
8383
config(
8484
key: string,
8585
context: LDContext,
86-
defaultValue: LDAIConversationConfigDefault,
86+
defaultValue: LDAICompletionConfigDefault,
8787
variables?: Record<string, unknown>,
88-
): Promise<LDAIConversationConfig>;
88+
): Promise<LDAICompletionConfig>;
8989

9090
/**
9191
* Retrieves and processes a single AI Config agent based on the provided key, LaunchDarkly context,
@@ -268,7 +268,7 @@ export interface LDAIClient {
268268
createChat(
269269
key: string,
270270
context: LDContext,
271-
defaultValue: LDAIConversationConfigDefault,
271+
defaultValue: LDAICompletionConfigDefault,
272272
variables?: Record<string, unknown>,
273273
defaultAiProvider?: SupportedAIProvider,
274274
): Promise<TrackedChat | undefined>;
@@ -279,7 +279,7 @@ export interface LDAIClient {
279279
initChat(
280280
key: string,
281281
context: LDContext,
282-
defaultValue: LDAIConversationConfigDefault,
282+
defaultValue: LDAICompletionConfigDefault,
283283
variables?: Record<string, unknown>,
284284
defaultAiProvider?: SupportedAIProvider,
285285
): Promise<TrackedChat | undefined>;

packages/sdk/server-ai/src/api/chat/TrackedChat.ts

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

33
import { LDAIConfigTracker } from '../config/LDAIConfigTracker';
4-
import { LDAIConversationConfig, LDMessage } from '../config/types';
4+
import { LDAICompletionConfig, LDMessage } from '../config/types';
55
import { Judge } from '../judge/Judge';
66
import { JudgeResponse } from '../judge/types';
77
import { AIProvider } from '../providers/AIProvider';
@@ -19,7 +19,7 @@ export class TrackedChat {
1919
private readonly _logger?: LDLogger;
2020

2121
constructor(
22-
protected readonly aiConfig: LDAIConversationConfig,
22+
protected readonly aiConfig: LDAICompletionConfig,
2323
protected readonly tracker: LDAIConfigTracker,
2424
protected readonly provider: AIProvider,
2525
judges?: Record<string, Judge>,
@@ -111,7 +111,7 @@ export class TrackedChat {
111111
/**
112112
* Get the underlying AI configuration used to initialize this TrackedChat.
113113
*/
114-
getConfig(): LDAIConversationConfig {
114+
getConfig(): LDAICompletionConfig {
115115
return this.aiConfig;
116116
}
117117

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { LDAIConfigTracker } from './LDAIConfigTracker';
22
import {
33
LDAIAgentConfig,
4+
LDAICompletionConfig,
45
LDAIConfigDefaultKind,
6+
LDAIConfigKind,
57
LDAIConfigMode,
6-
LDAIConversationConfig,
78
LDAIJudgeConfig,
89
LDJudgeConfiguration,
910
LDMessage,
@@ -81,10 +82,7 @@ export class LDAIConfigUtils {
8182
* @param tracker The tracker to add to the config
8283
* @returns The appropriate AI configuration type
8384
*/
84-
static fromFlagValue(
85-
flagValue: LDAIConfigFlagValue,
86-
tracker: LDAIConfigTracker,
87-
): LDAIConversationConfig | LDAIAgentConfig | LDAIJudgeConfig {
85+
static fromFlagValue(flagValue: LDAIConfigFlagValue, tracker: LDAIConfigTracker): LDAIConfigKind {
8886
// Determine the actual mode from flag value
8987
// eslint-disable-next-line no-underscore-dangle
9088
const flagValueMode = flagValue._ldMeta?.mode;
@@ -107,9 +105,7 @@ export class LDAIConfigUtils {
107105
* @param mode The mode for the disabled config
108106
* @returns A disabled config of the appropriate type
109107
*/
110-
static createDisabledConfig(
111-
mode: LDAIConfigMode,
112-
): LDAIConversationConfig | LDAIAgentConfig | LDAIJudgeConfig {
108+
static createDisabledConfig(mode: LDAIConfigMode): LDAIConfigKind {
113109
switch (mode) {
114110
case 'agent':
115111
return {
@@ -128,7 +124,7 @@ export class LDAIConfigUtils {
128124
return {
129125
enabled: false,
130126
tracker: undefined,
131-
} as LDAIConversationConfig;
127+
} as LDAICompletionConfig;
132128
}
133129
}
134130

@@ -157,7 +153,7 @@ export class LDAIConfigUtils {
157153
static toCompletionConfig(
158154
flagValue: LDAIConfigFlagValue,
159155
tracker: LDAIConfigTracker,
160-
): LDAIConversationConfig {
156+
): LDAICompletionConfig {
161157
return {
162158
...this._toBaseConfig(flagValue),
163159
tracker,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export interface LDAIAgentConfigDefault extends LDAIConfigDefault {
138138
/**
139139
* Default Completion AI Config (default mode).
140140
*/
141-
export interface LDAIConversationConfigDefault extends LDAIConfigDefault {
141+
export interface LDAICompletionConfigDefault extends LDAIConfigDefault {
142142
/**
143143
* Optional prompt data for completion configurations.
144144
*/
@@ -187,7 +187,7 @@ export interface LDAIAgentConfig extends LDAIConfig {
187187
/**
188188
* Completion AI Config (default mode).
189189
*/
190-
export interface LDAIConversationConfig extends LDAIConfig {
190+
export interface LDAICompletionConfig extends LDAIConfig {
191191
/**
192192
* Optional prompt data for completion configurations.
193193
*/
@@ -216,13 +216,13 @@ export interface LDMessage {
216216
/**
217217
* Union type for all AI Config variants.
218218
*/
219-
export type LDAIConfigKind = LDAIConversationConfig | LDAIAgentConfig | LDAIJudgeConfig;
219+
export type LDAIConfigKind = LDAICompletionConfig | LDAIAgentConfig | LDAIJudgeConfig;
220220

221221
/**
222222
* Union type for all default AI Config variants.
223223
*/
224224
export type LDAIConfigDefaultKind =
225-
| LDAIConversationConfigDefault
225+
| LDAICompletionConfigDefault
226226
| LDAIAgentConfigDefault
227227
| LDAIJudgeConfigDefault;
228228

0 commit comments

Comments
 (0)