Notify callers from the prepared execution snapshot
This commit is contained in:
@@ -166,7 +166,7 @@ func (r *Runner) Run(ctx context.Context, req domain.RunRequest) (*domain.RunRes
|
||||
}
|
||||
directAPIKey := state.effectiveModel.APIKey
|
||||
|
||||
return r.executePreparedRun(ctx, operation.run, operation.capture, operation.parent, directAPIKey, state.transientRetries, runID, start, func(
|
||||
return r.executePreparedRun(ctx, operation.run, req.OnPrepared, operation.capture, operation.parent, directAPIKey, state.transientRetries, runID, start, func(
|
||||
ctx context.Context,
|
||||
artifact *domain.Artifact,
|
||||
attemptsUsed int,
|
||||
@@ -186,6 +186,7 @@ type preparedValidationFunc func(
|
||||
func (r *Runner) executePreparedRun(
|
||||
ctx context.Context,
|
||||
prepared *domain.PreparedRun,
|
||||
onPrepared func(context.Context, *domain.PreparedRun),
|
||||
capture bool,
|
||||
parent *domain.Exchange,
|
||||
directAPIKey string,
|
||||
@@ -194,6 +195,15 @@ func (r *Runner) executePreparedRun(
|
||||
start time.Time,
|
||||
validateArtifact preparedValidationFunc,
|
||||
) (*domain.RunResult, error) {
|
||||
if onPrepared != nil {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, wrapGenerationError(err)
|
||||
}
|
||||
onPrepared(ctx, prepared)
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, wrapGenerationError(err)
|
||||
}
|
||||
}
|
||||
executionTarget := prepared.EffectiveModelParams
|
||||
executionTarget.APIKey = directAPIKey
|
||||
genResp, err := r.llm.Generate(ctx, newGenerationRequest(
|
||||
|
||||
Reference in New Issue
Block a user