@@ -5,6 +5,7 @@ import {Executor} from '../orchestration/executors/executor.js';
55import { Rating , RatingCategory } from '../ratings/rating-types.js' ;
66import {
77 FrameworkInfo ,
8+ LlmResponseFile ,
89 MultiStepPromptDefinition ,
910 PromptDefinition ,
1011 RatingContextFilter ,
@@ -83,6 +84,9 @@ export class Environment {
8384 /** Runner that user can use to access an LLM to augment prompts. */
8485 private augmentationRunner : GenkitRunner | null = null ;
8586
87+ /** User-provided callback for augmenting the LLM-generated files. */
88+ private readonly augmentFileCallback : ( ( file : LlmResponseFile ) => string ) | null ;
89+
8690 constructor (
8791 rootPath : string ,
8892 private readonly config : EnvironmentConfig & Required < Pick < EnvironmentConfig , 'executor' > > ,
@@ -114,6 +118,7 @@ export class Environment {
114118 this . ratingHash = this . getRatingHash ( this . ratings , this . ratingCategories ) ;
115119 this . analysisPrompts = this . resolveAnalysisPrompts ( config ) ;
116120 this . augmentExecutablePrompt = config . augmentExecutablePrompt || null ;
121+ this . augmentFileCallback = config . augmentGeneratedFile || null ;
117122 this . validateRatingHash ( this . ratingHash , config ) ;
118123 }
119124
@@ -191,6 +196,13 @@ export class Environment {
191196 } ) ;
192197 }
193198
199+ /** Augments response files based on the user's configuration. */
200+ augmentResponseFiles ( files : LlmResponseFile [ ] ) : void {
201+ if ( this . augmentFileCallback ) {
202+ files . forEach ( file => ( file . code = this . augmentFileCallback ! ( file ) ) ) ;
203+ }
204+ }
205+
194206 async destroy ( ) : Promise < void > {
195207 await this . executor . destroy ( ) ;
196208
0 commit comments