@@ -69,7 +69,7 @@ export class Environment {
6969
7070 /** Prompts that should be executed as a part of the evaluation. */
7171 executablePrompts = lazy ( async ( ) => {
72- return this . resolveExecutablePrompts ( this . config . executablePrompts , this . config . ratings ) ;
72+ return this . resolveExecutablePrompts ( this . config . executablePrompts , this . config ) ;
7373 } ) ;
7474
7575 systemPromptGeneration = lazy ( async ( ) => {
@@ -166,15 +166,32 @@ export class Environment {
166166
167167 /**
168168 * Resolves the prompt configuration into prompt definitions.
169- * @param rootPath Root path of the project.
170169 * @param prompts Prompts to be resolved.
171- * @param envRatings Environment-level ratings .
170+ * @param config Configuration for the environment .
172171 */
173172 private async resolveExecutablePrompts (
174173 prompts : EnvironmentConfig [ 'executablePrompts' ] ,
175- envRatings : Rating [ ] ,
174+ config : EnvironmentConfig ,
176175 ) : Promise < RootPromptDefinition [ ] > {
177176 const result : Promise < RootPromptDefinition > [ ] = [ ] ;
177+ let envRatings : Rating [ ] ;
178+
179+ if ( config . ratingOverrides ) {
180+ Object . keys ( config . ratingOverrides ) . forEach ( id => {
181+ if ( ! config . ratings . some ( rating => rating . id === id ) ) {
182+ throw new UserFacingError (
183+ `Rating with an ID of "${ id } " has not been configured. Cannot apply an override to it.` ,
184+ ) ;
185+ }
186+ } ) ;
187+
188+ envRatings = config . ratings . map ( rating => {
189+ const override = config . ratingOverrides ! [ rating . id ] ;
190+ return override ? { ...rating , ...override } : rating ;
191+ } ) ;
192+ } else {
193+ envRatings = config . ratings ;
194+ }
178195
179196 for ( const def of prompts ) {
180197 if ( def instanceof MultiStepPrompt ) {
0 commit comments