@@ -82,19 +82,23 @@ export class LDAIConfigUtils {
8282 * @param tracker The tracker to add to the config
8383 * @returns The appropriate AI configuration type
8484 */
85- static fromFlagValue ( flagValue : LDAIConfigFlagValue , tracker : LDAIConfigTracker ) : LDAIConfigKind {
85+ static fromFlagValue (
86+ key : string ,
87+ flagValue : LDAIConfigFlagValue ,
88+ tracker : LDAIConfigTracker ,
89+ ) : LDAIConfigKind {
8690 // Determine the actual mode from flag value
8791 // eslint-disable-next-line no-underscore-dangle
8892 const flagValueMode = flagValue . _ldMeta ?. mode ;
8993
9094 switch ( flagValueMode ) {
9195 case 'agent' :
92- return this . toAgentConfig ( flagValue , tracker ) ;
96+ return this . toAgentConfig ( key , flagValue , tracker ) ;
9397 case 'judge' :
94- return this . toJudgeConfig ( flagValue , tracker ) ;
98+ return this . toJudgeConfig ( key , flagValue , tracker ) ;
9599 case 'completion' :
96100 default :
97- return this . toCompletionConfig ( flagValue , tracker ) ;
101+ return this . toCompletionConfig ( key , flagValue , tracker ) ;
98102 }
99103 }
100104
@@ -104,15 +108,17 @@ export class LDAIConfigUtils {
104108 * @param mode The mode for the disabled config
105109 * @returns A disabled config of the appropriate type
106110 */
107- static createDisabledConfig ( mode : LDAIConfigMode ) : LDAIConfigKind {
111+ static createDisabledConfig ( key : string , mode : LDAIConfigMode ) : LDAIConfigKind {
108112 switch ( mode ) {
109113 case 'agent' :
110114 return {
115+ key,
111116 enabled : false ,
112117 tracker : undefined ,
113118 } as LDAIAgentConfig ;
114119 case 'judge' :
115120 return {
121+ key,
116122 enabled : false ,
117123 tracker : undefined ,
118124 evaluationMetricKeys : [ ] ,
@@ -121,6 +127,7 @@ export class LDAIConfigUtils {
121127 default :
122128 // Default to completion config for completion mode or any unexpected mode
123129 return {
130+ key,
124131 enabled : false ,
125132 tracker : undefined ,
126133 } as LDAICompletionConfig ;
@@ -133,8 +140,9 @@ export class LDAIConfigUtils {
133140 * @param flagValue The flag value from LaunchDarkly
134141 * @returns Base configuration object
135142 */
136- private static _toBaseConfig ( flagValue : LDAIConfigFlagValue ) {
143+ private static _toBaseConfig ( key : string , flagValue : LDAIConfigFlagValue ) {
137144 return {
145+ key,
138146 // eslint-disable-next-line no-underscore-dangle
139147 enabled : flagValue . _ldMeta ?. enabled ?? false ,
140148 model : flagValue . model ,
@@ -150,11 +158,12 @@ export class LDAIConfigUtils {
150158 * @returns A completion configuration
151159 */
152160 static toCompletionConfig (
161+ key : string ,
153162 flagValue : LDAIConfigFlagValue ,
154163 tracker : LDAIConfigTracker ,
155164 ) : LDAICompletionConfig {
156165 return {
157- ...this . _toBaseConfig ( flagValue ) ,
166+ ...this . _toBaseConfig ( key , flagValue ) ,
158167 tracker,
159168 messages : flagValue . messages ,
160169 judgeConfiguration : flagValue . judgeConfiguration ,
@@ -169,11 +178,12 @@ export class LDAIConfigUtils {
169178 * @returns An agent configuration
170179 */
171180 static toAgentConfig (
181+ key : string ,
172182 flagValue : LDAIConfigFlagValue ,
173183 tracker : LDAIConfigTracker ,
174184 ) : LDAIAgentConfig {
175185 return {
176- ...this . _toBaseConfig ( flagValue ) ,
186+ ...this . _toBaseConfig ( key , flagValue ) ,
177187 tracker,
178188 instructions : flagValue . instructions ,
179189 judgeConfiguration : flagValue . judgeConfiguration ,
@@ -188,11 +198,12 @@ export class LDAIConfigUtils {
188198 * @returns A judge configuration
189199 */
190200 static toJudgeConfig (
201+ key : string ,
191202 flagValue : LDAIConfigFlagValue ,
192203 tracker : LDAIConfigTracker ,
193204 ) : LDAIJudgeConfig {
194205 return {
195- ...this . _toBaseConfig ( flagValue ) ,
206+ ...this . _toBaseConfig ( key , flagValue ) ,
196207 tracker,
197208 messages : flagValue . messages ,
198209 evaluationMetricKeys : flagValue . evaluationMetricKeys || [ ] ,
0 commit comments