Add independent native run report delivery
This commit is contained in:
@@ -18,6 +18,8 @@ type runInput struct {
|
||||
Execution ckprompt.ExecutionInput
|
||||
Namespaces promptkit.Namespaces
|
||||
OperationTimeout time.Duration
|
||||
ReportPath commandkit.Supplied[string]
|
||||
ReportFormat commandkit.Supplied[commandkit.Format]
|
||||
}
|
||||
|
||||
var artifactTextTemplate = template.Must(commandkit.ParseTextTemplate("artifact", `{{printf "%s" .Artifact.Body}}`, nil))
|
||||
@@ -30,6 +32,7 @@ func runDeclarations() []commandkit.Declaration {
|
||||
flags = append(flags, resources.Profile, resources.SessionID)
|
||||
flags = append(flags, inputs.All()...)
|
||||
flags = append(flags, execution.All()...)
|
||||
flags = append(flags, reportFlags()...)
|
||||
flags = append(flags, commandkit.ValueFlag(commandkit.FlagMeta{Name: "run-timeout", Usage: "Whole-operation timeout as a Go duration."}, (*time.Duration)(nil), time.ParseDuration,
|
||||
func(input *runInput, value commandkit.Supplied[time.Duration]) { input.OperationTimeout = value.Value }))
|
||||
for _, namespace := range []struct {
|
||||
@@ -47,7 +50,8 @@ func runDeclarations() []commandkit.Declaration {
|
||||
Name: "run", Summary: "Run a stored prompt.", Flags: flags,
|
||||
Arguments: []commandkit.Argument[runInput]{commandkit.ValueArgument(commandkit.ArgumentMeta{Name: "PROMPT_ID", Usage: "Stored prompt identifier."}, true, parseString,
|
||||
func(input *runInput, value commandkit.Supplied[string]) { input.PromptID = value.Value })},
|
||||
Run: runPrompt,
|
||||
Run: runPrompt,
|
||||
CheckInput: func(input runInput) error { return checkReportInput(input.ReportPath) },
|
||||
})
|
||||
declarations := []commandkit.Declaration{command}
|
||||
for _, name := range []string{"profile", "session-id", "var", "input-text", "input-file", "endpoint", "model", "temperature", "max-tokens", "top-p", "timeout-seconds", "service-tier", "reasoning-effort", "api-key-env", "transient-retries", "extra-params", "prompt-namespace", "profile-namespace", "backend-namespace"} {
|
||||
@@ -89,11 +93,5 @@ func runPrompt(invocation commandkit.Invocation, input runInput) commandkit.Outc
|
||||
if err != nil {
|
||||
return requestFailure(err, explanation)
|
||||
}
|
||||
outcome := completedRunOutcome(result)
|
||||
if result == nil {
|
||||
return outcome
|
||||
}
|
||||
_ = invocation.Reporter().Report(commandkit.Report{Value: result, TextTemplate: artifactTextTemplate})
|
||||
_ = invocation.Reporter().Info("Prompt execution completed.")
|
||||
return outcome
|
||||
return deliverRunResult(invocation, input, result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user