Move execution reporting into the HTTP adapter
This commit is contained in:
@@ -215,6 +215,9 @@ protected. The numeric assertion correction is already owned by stage 1.
|
|||||||
|
|
||||||
## Stage 6: Move HTTP Report Implementation Into Its Adapter
|
## Stage 6: Move HTTP Report Implementation Into Its Adapter
|
||||||
|
|
||||||
|
**Status: complete.** HTTP owns the terminal report projection and its real-engine
|
||||||
|
tests; distinct cache-token fields and their encoded presence are verified.
|
||||||
|
|
||||||
**Findings:** 10 and 16.
|
**Findings:** 10 and 16.
|
||||||
**Files:** `internal/report/report.go`, `report_test.go`, HTTP `handler.go` and
|
**Files:** `internal/report/report.go`, `report_test.go`, HTTP `handler.go` and
|
||||||
`dto.go`; destination `internal/adapter/http/execution_report.go` and
|
`dto.go`; destination `internal/adapter/http/execution_report.go` and
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ import (
|
|||||||
_ "gitea.maximumdirect.net/eric/scriptorium/internal/adapter/http"
|
_ "gitea.maximumdirect.net/eric/scriptorium/internal/adapter/http"
|
||||||
_ "gitea.maximumdirect.net/eric/scriptorium/internal/config"
|
_ "gitea.maximumdirect.net/eric/scriptorium/internal/config"
|
||||||
_ "gitea.maximumdirect.net/eric/scriptorium/internal/defaults"
|
_ "gitea.maximumdirect.net/eric/scriptorium/internal/defaults"
|
||||||
_ "gitea.maximumdirect.net/eric/scriptorium/internal/report"
|
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
if err := os.WriteFile(sourcePath, []byte(source), 0o644); err != nil {
|
if err := os.WriteFile(sourcePath, []byte(source), 0o644); err != nil {
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package httpadapter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
executionreport "gitea.maximumdirect.net/eric/scriptorium/internal/report"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type runRequestDTO struct {
|
type runRequestDTO struct {
|
||||||
@@ -39,11 +37,11 @@ type modelOverrideRequestDTO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type runResponseDTO struct {
|
type runResponseDTO struct {
|
||||||
Artifact artifactDTO `json:"artifact"`
|
Artifact artifactDTO `json:"artifact"`
|
||||||
Validation validationDTO `json:"validation"`
|
Validation validationDTO `json:"validation"`
|
||||||
Metadata metadataDTO `json:"metadata"`
|
Metadata metadataDTO `json:"metadata"`
|
||||||
RawModelOutput *string `json:"raw_model_output,omitempty"`
|
RawModelOutput *string `json:"raw_model_output,omitempty"`
|
||||||
Execution *executionreport.Execution `json:"execution,omitempty"`
|
Execution *executionReport `json:"execution,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type artifactDTO struct {
|
type artifactDTO struct {
|
||||||
@@ -102,8 +100,8 @@ type validationDTO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type errorResponse struct {
|
type errorResponse struct {
|
||||||
Error errorBody `json:"error"`
|
Error errorBody `json:"error"`
|
||||||
Execution *executionreport.Execution `json:"execution,omitempty"`
|
Execution *executionReport `json:"execution,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type errorBody struct {
|
type errorBody struct {
|
||||||
|
|||||||
104
internal/adapter/http/execution_report.go
Normal file
104
internal/adapter/http/execution_report.go
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
package httpadapter
|
||||||
|
|
||||||
|
import "go.maximumdirect.net/promptkit"
|
||||||
|
|
||||||
|
// executionReport is the terminal observation exposed by the HTTP adapter.
|
||||||
|
type executionReport struct {
|
||||||
|
RunID string `json:"run_id,omitempty"`
|
||||||
|
PromptID string `json:"prompt_id,omitempty"`
|
||||||
|
ProfileID string `json:"profile_id,omitempty"`
|
||||||
|
BackendID string `json:"backend_id,omitempty"`
|
||||||
|
Model string `json:"model,omitempty"`
|
||||||
|
Outcome string `json:"outcome"`
|
||||||
|
Failure string `json:"failure"`
|
||||||
|
StatusCode int `json:"status_code,omitempty"`
|
||||||
|
RetriesExhausted bool `json:"retries_exhausted"`
|
||||||
|
Attempts uint64 `json:"attempts"`
|
||||||
|
TransientRetries uint64 `json:"transient_retries"`
|
||||||
|
RepairCalls uint64 `json:"repair_calls"`
|
||||||
|
DurationMS int64 `json:"duration_ms"`
|
||||||
|
CapacityWaitMS int64 `json:"capacity_wait_ms"`
|
||||||
|
GenerationDurationMS int64 `json:"generation_duration_ms"`
|
||||||
|
RetryDelayMS int64 `json:"retry_delay_ms"`
|
||||||
|
Usage executionUsage `json:"usage"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type executionUsage struct {
|
||||||
|
PromptTokens executionTokenCount `json:"prompt_tokens"`
|
||||||
|
CompletionTokens executionTokenCount `json:"completion_tokens"`
|
||||||
|
TotalTokens executionTokenCount `json:"total_tokens"`
|
||||||
|
CachedTokens executionTokenCount `json:"cached_tokens"`
|
||||||
|
CacheWriteTokens executionTokenCount `json:"cache_write_tokens"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type executionTokenCount struct {
|
||||||
|
Value int `json:"value"`
|
||||||
|
Known bool `json:"known"`
|
||||||
|
Complete bool `json:"complete"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// executionCollector retains at most one terminal observation from a synchronous run.
|
||||||
|
type executionCollector struct {
|
||||||
|
report *executionReport
|
||||||
|
}
|
||||||
|
|
||||||
|
func newExecutionCollector() *executionCollector { return &executionCollector{} }
|
||||||
|
|
||||||
|
func (collector *executionCollector) Observe(event promptkit.ExecutionEvent) {
|
||||||
|
if event.Kind != promptkit.ExecutionFinished {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
count := func(value promptkit.ObservedTokenCount) executionTokenCount {
|
||||||
|
return executionTokenCount{Value: value.Value, Known: value.Known, Complete: value.Complete}
|
||||||
|
}
|
||||||
|
collector.report = &executionReport{
|
||||||
|
RunID: event.RunID, PromptID: event.PromptID,
|
||||||
|
ProfileID: event.ProfileID, BackendID: event.BackendID, Model: event.Model,
|
||||||
|
Outcome: executionOutcome(event.Outcome), Failure: executionFailure(event.Failure),
|
||||||
|
StatusCode: event.StatusCode, RetriesExhausted: event.RetriesExhausted,
|
||||||
|
Attempts: event.Attempts, TransientRetries: event.TransientRetries, RepairCalls: event.RepairCalls,
|
||||||
|
DurationMS: event.Duration.Milliseconds(), CapacityWaitMS: event.CapacityWait.Milliseconds(),
|
||||||
|
GenerationDurationMS: event.GenerationDuration.Milliseconds(), RetryDelayMS: event.RetryDelay.Milliseconds(),
|
||||||
|
Usage: executionUsage{
|
||||||
|
PromptTokens: count(event.Usage.PromptTokens), CompletionTokens: count(event.Usage.CompletionTokens),
|
||||||
|
TotalTokens: count(event.Usage.TotalTokens), CachedTokens: count(event.Usage.CachedTokens),
|
||||||
|
CacheWriteTokens: count(event.Usage.CacheWriteTokens),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (collector *executionCollector) Snapshot() *executionReport {
|
||||||
|
if collector.report == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
value := *collector.report
|
||||||
|
return &value
|
||||||
|
}
|
||||||
|
|
||||||
|
func executionOutcome(value promptkit.ExecutionOutcome) string {
|
||||||
|
switch value {
|
||||||
|
case promptkit.ExecutionOutcomeSuccess, promptkit.ExecutionOutcomeInvalidOutput, promptkit.ExecutionOutcomeError:
|
||||||
|
return string(value)
|
||||||
|
default:
|
||||||
|
return "other"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func executionFailure(value promptkit.ExecutionFailureKind) string {
|
||||||
|
switch value {
|
||||||
|
case promptkit.ExecutionFailureNone:
|
||||||
|
return "none"
|
||||||
|
case promptkit.ExecutionFailureCanceled, promptkit.ExecutionFailureDeadline,
|
||||||
|
promptkit.ExecutionFailureTransport, promptkit.ExecutionFailureProviderStatus,
|
||||||
|
promptkit.ExecutionFailureMalformedResponse, promptkit.ExecutionFailureCapacity,
|
||||||
|
promptkit.ExecutionFailureInvalidConfig, promptkit.ExecutionFailureInvalidRequest,
|
||||||
|
promptkit.ExecutionFailurePromptNotFound, promptkit.ExecutionFailureProfileNotFound,
|
||||||
|
promptkit.ExecutionFailurePromptLoad, promptkit.ExecutionFailureProfileLoad,
|
||||||
|
promptkit.ExecutionFailureArtifactLoad, promptkit.ExecutionFailurePromptRender,
|
||||||
|
promptkit.ExecutionFailureValidation, promptkit.ExecutionFailureGeneration,
|
||||||
|
promptkit.ExecutionFailureOther:
|
||||||
|
return string(value)
|
||||||
|
default:
|
||||||
|
return "other"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package report
|
package httpadapter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -14,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
||||||
collector := NewCollector()
|
collector := newExecutionCollector()
|
||||||
if collector.Snapshot() != nil {
|
if collector.Snapshot() != nil {
|
||||||
t.Fatal("empty collector produced a report")
|
t.Fatal("empty collector produced a report")
|
||||||
}
|
}
|
||||||
@@ -33,6 +34,8 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
|||||||
PromptTokens: promptkit.ObservedTokenCount{Value: 0, Known: true, Complete: true},
|
PromptTokens: promptkit.ObservedTokenCount{Value: 0, Known: true, Complete: true},
|
||||||
CompletionTokens: promptkit.ObservedTokenCount{Value: 0, Known: false, Complete: false},
|
CompletionTokens: promptkit.ObservedTokenCount{Value: 0, Known: false, Complete: false},
|
||||||
TotalTokens: promptkit.ObservedTokenCount{Value: 11, Known: true, Complete: false},
|
TotalTokens: promptkit.ObservedTokenCount{Value: 11, Known: true, Complete: false},
|
||||||
|
CachedTokens: promptkit.ObservedTokenCount{Value: 4, Known: true, Complete: true},
|
||||||
|
CacheWriteTokens: promptkit.ObservedTokenCount{Value: 7, Known: true, Complete: false},
|
||||||
ReasoningTokens: promptkit.ObservedTokenCount{Value: 3, Known: true, Complete: true},
|
ReasoningTokens: promptkit.ObservedTokenCount{Value: 3, Known: true, Complete: true},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -44,7 +47,7 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
|||||||
if report.DurationMS != 1500 || report.CapacityWaitMS != 20 || report.GenerationDurationMS != 300 || report.RetryDelayMS != 700 {
|
if report.DurationMS != 1500 || report.CapacityWaitMS != 20 || report.GenerationDurationMS != 300 || report.RetryDelayMS != 700 {
|
||||||
t.Fatalf("terminal timings changed: %+v", report)
|
t.Fatalf("terminal timings changed: %+v", report)
|
||||||
}
|
}
|
||||||
if report.Usage.PromptTokens != (TokenCount{Known: true, Complete: true}) || report.Usage.CompletionTokens != (TokenCount{}) || report.Usage.TotalTokens != (TokenCount{Value: 11, Known: true}) {
|
if report.Usage.PromptTokens != (executionTokenCount{Known: true, Complete: true}) || report.Usage.CompletionTokens != (executionTokenCount{}) || report.Usage.TotalTokens != (executionTokenCount{Value: 11, Known: true}) {
|
||||||
t.Fatalf("presence-aware usage changed: %+v", report.Usage)
|
t.Fatalf("presence-aware usage changed: %+v", report.Usage)
|
||||||
}
|
}
|
||||||
encoded, err := json.Marshal(report)
|
encoded, err := json.Marshal(report)
|
||||||
@@ -60,10 +63,16 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
|||||||
t.Fatalf("report missing %q: %s", key, encoded)
|
t.Fatalf("report missing %q: %s", key, encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, key := range []string{"prompt_tokens", "completion_tokens", "total_tokens", "cached_tokens", "cache_write_tokens"} {
|
for key, want := range map[string]map[string]any{
|
||||||
|
"prompt_tokens": {"value": float64(0), "known": true, "complete": true},
|
||||||
|
"completion_tokens": {"value": float64(0), "known": false, "complete": false},
|
||||||
|
"total_tokens": {"value": float64(11), "known": true, "complete": false},
|
||||||
|
"cached_tokens": {"value": float64(4), "known": true, "complete": true},
|
||||||
|
"cache_write_tokens": {"value": float64(7), "known": true, "complete": false},
|
||||||
|
} {
|
||||||
item := fields["usage"].(map[string]any)[key].(map[string]any)
|
item := fields["usage"].(map[string]any)[key].(map[string]any)
|
||||||
if len(item) != 3 {
|
if !reflect.DeepEqual(item, want) {
|
||||||
t.Fatalf("incomplete token count %q: %#v", key, item)
|
t.Fatalf("token count %q: got %#v, want %#v", key, item, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, forbidden := range []string{"prompt_version", "session_id", "headers", "endpoint", "api_key", "error", "output", "input"} {
|
for _, forbidden := range []string{"prompt_version", "session_id", "headers", "endpoint", "api_key", "error", "output", "input"} {
|
||||||
@@ -77,8 +86,8 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCollectorHandlesUnknownValuesAndKeepsInvocationsSeparate(t *testing.T) {
|
func TestCollectorHandlesUnknownValuesAndKeepsInvocationsSeparate(t *testing.T) {
|
||||||
first := NewCollector()
|
first := newExecutionCollector()
|
||||||
second := NewCollector()
|
second := newExecutionCollector()
|
||||||
first.Observe(promptkit.ExecutionEvent{Kind: promptkit.ExecutionFinished, RunID: "first", Outcome: "future", Failure: "future"})
|
first.Observe(promptkit.ExecutionEvent{Kind: promptkit.ExecutionFinished, RunID: "first", Outcome: "future", Failure: "future"})
|
||||||
second.Observe(promptkit.ExecutionEvent{Kind: promptkit.ExecutionFinished, RunID: "second", Outcome: promptkit.ExecutionOutcomeSuccess})
|
second.Observe(promptkit.ExecutionEvent{Kind: promptkit.ExecutionFinished, RunID: "second", Outcome: promptkit.ExecutionOutcomeSuccess})
|
||||||
one := first.Snapshot()
|
one := first.Snapshot()
|
||||||
@@ -145,7 +154,7 @@ func TestCollectorReceivesRealEngineTerminalEvent(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
collector := NewCollector()
|
collector := newExecutionCollector()
|
||||||
if _, err := engine.Run(context.Background(), promptkit.RunRequest{PromptID: "p", Observer: collector.Observe}); err != nil {
|
if _, err := engine.Run(context.Background(), promptkit.RunRequest{PromptID: "p", Observer: collector.Observe}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/scriptorium/internal/defaults"
|
"gitea.maximumdirect.net/eric/scriptorium/internal/defaults"
|
||||||
executionreport "gitea.maximumdirect.net/eric/scriptorium/internal/report"
|
|
||||||
"go.maximumdirect.net/promptkit"
|
"go.maximumdirect.net/promptkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -121,13 +120,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
TransientRetries: req.TransientRetries,
|
TransientRetries: req.TransientRetries,
|
||||||
OperationTimeout: operationTimeout,
|
OperationTimeout: operationTimeout,
|
||||||
}
|
}
|
||||||
var collector *executionreport.Collector
|
var collector *executionCollector
|
||||||
if req.IncludeExecutionReport {
|
if req.IncludeExecutionReport {
|
||||||
collector = executionreport.NewCollector()
|
collector = newExecutionCollector()
|
||||||
mappedRequest.Observer = collector.Observe
|
mappedRequest.Observer = collector.Observe
|
||||||
}
|
}
|
||||||
res, err := h.runner.Run(r.Context(), mappedRequest)
|
res, err := h.runner.Run(r.Context(), mappedRequest)
|
||||||
var execution *executionreport.Execution
|
var execution *executionReport
|
||||||
if collector != nil {
|
if collector != nil {
|
||||||
execution = collector.Snapshot()
|
execution = collector.Snapshot()
|
||||||
}
|
}
|
||||||
@@ -185,7 +184,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeLimitedJSON(w, http.StatusOK, resp, h.options.MaxResponseBytes)
|
writeLimitedJSON(w, http.StatusOK, resp, h.options.MaxResponseBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeRunFailure(w http.ResponseWriter, status int, code, message string, execution *executionreport.Execution, maxBytes int64) {
|
func writeRunFailure(w http.ResponseWriter, status int, code, message string, execution *executionReport, maxBytes int64) {
|
||||||
if execution == nil {
|
if execution == nil {
|
||||||
writeError(w, status, code, message)
|
writeError(w, status, code, message)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
package report
|
|
||||||
|
|
||||||
import "go.maximumdirect.net/promptkit"
|
|
||||||
|
|
||||||
// Execution is the terminal observation exposed by Scriptorium's opt-in adapters.
|
|
||||||
type Execution struct {
|
|
||||||
RunID string `json:"run_id,omitempty"`
|
|
||||||
PromptID string `json:"prompt_id,omitempty"`
|
|
||||||
ProfileID string `json:"profile_id,omitempty"`
|
|
||||||
BackendID string `json:"backend_id,omitempty"`
|
|
||||||
Model string `json:"model,omitempty"`
|
|
||||||
Outcome string `json:"outcome"`
|
|
||||||
Failure string `json:"failure"`
|
|
||||||
StatusCode int `json:"status_code,omitempty"`
|
|
||||||
RetriesExhausted bool `json:"retries_exhausted"`
|
|
||||||
Attempts uint64 `json:"attempts"`
|
|
||||||
TransientRetries uint64 `json:"transient_retries"`
|
|
||||||
RepairCalls uint64 `json:"repair_calls"`
|
|
||||||
DurationMS int64 `json:"duration_ms"`
|
|
||||||
CapacityWaitMS int64 `json:"capacity_wait_ms"`
|
|
||||||
GenerationDurationMS int64 `json:"generation_duration_ms"`
|
|
||||||
RetryDelayMS int64 `json:"retry_delay_ms"`
|
|
||||||
Usage Usage `json:"usage"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Usage struct {
|
|
||||||
PromptTokens TokenCount `json:"prompt_tokens"`
|
|
||||||
CompletionTokens TokenCount `json:"completion_tokens"`
|
|
||||||
TotalTokens TokenCount `json:"total_tokens"`
|
|
||||||
CachedTokens TokenCount `json:"cached_tokens"`
|
|
||||||
CacheWriteTokens TokenCount `json:"cache_write_tokens"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TokenCount struct {
|
|
||||||
Value int `json:"value"`
|
|
||||||
Known bool `json:"known"`
|
|
||||||
Complete bool `json:"complete"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collector retains at most one terminal observation from a synchronous run.
|
|
||||||
type Collector struct {
|
|
||||||
report *Execution
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCollector() *Collector { return &Collector{} }
|
|
||||||
|
|
||||||
func (collector *Collector) Observe(event promptkit.ExecutionEvent) {
|
|
||||||
if event.Kind != promptkit.ExecutionFinished {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
count := func(value promptkit.ObservedTokenCount) TokenCount {
|
|
||||||
return TokenCount{Value: value.Value, Known: value.Known, Complete: value.Complete}
|
|
||||||
}
|
|
||||||
collector.report = &Execution{
|
|
||||||
RunID: event.RunID, PromptID: event.PromptID,
|
|
||||||
ProfileID: event.ProfileID, BackendID: event.BackendID, Model: event.Model,
|
|
||||||
Outcome: outcome(event.Outcome), Failure: failure(event.Failure),
|
|
||||||
StatusCode: event.StatusCode, RetriesExhausted: event.RetriesExhausted,
|
|
||||||
Attempts: event.Attempts, TransientRetries: event.TransientRetries, RepairCalls: event.RepairCalls,
|
|
||||||
DurationMS: event.Duration.Milliseconds(), CapacityWaitMS: event.CapacityWait.Milliseconds(),
|
|
||||||
GenerationDurationMS: event.GenerationDuration.Milliseconds(), RetryDelayMS: event.RetryDelay.Milliseconds(),
|
|
||||||
Usage: Usage{
|
|
||||||
PromptTokens: count(event.Usage.PromptTokens), CompletionTokens: count(event.Usage.CompletionTokens),
|
|
||||||
TotalTokens: count(event.Usage.TotalTokens), CachedTokens: count(event.Usage.CachedTokens),
|
|
||||||
CacheWriteTokens: count(event.Usage.CacheWriteTokens),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (collector *Collector) Snapshot() *Execution {
|
|
||||||
if collector.report == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
value := *collector.report
|
|
||||||
return &value
|
|
||||||
}
|
|
||||||
|
|
||||||
func outcome(value promptkit.ExecutionOutcome) string {
|
|
||||||
switch value {
|
|
||||||
case promptkit.ExecutionOutcomeSuccess, promptkit.ExecutionOutcomeInvalidOutput, promptkit.ExecutionOutcomeError:
|
|
||||||
return string(value)
|
|
||||||
default:
|
|
||||||
return "other"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func failure(value promptkit.ExecutionFailureKind) string {
|
|
||||||
switch value {
|
|
||||||
case promptkit.ExecutionFailureNone:
|
|
||||||
return "none"
|
|
||||||
case promptkit.ExecutionFailureCanceled, promptkit.ExecutionFailureDeadline,
|
|
||||||
promptkit.ExecutionFailureTransport, promptkit.ExecutionFailureProviderStatus,
|
|
||||||
promptkit.ExecutionFailureMalformedResponse, promptkit.ExecutionFailureCapacity,
|
|
||||||
promptkit.ExecutionFailureInvalidConfig, promptkit.ExecutionFailureInvalidRequest,
|
|
||||||
promptkit.ExecutionFailurePromptNotFound, promptkit.ExecutionFailureProfileNotFound,
|
|
||||||
promptkit.ExecutionFailurePromptLoad, promptkit.ExecutionFailureProfileLoad,
|
|
||||||
promptkit.ExecutionFailureArtifactLoad, promptkit.ExecutionFailurePromptRender,
|
|
||||||
promptkit.ExecutionFailureValidation, promptkit.ExecutionFailureGeneration,
|
|
||||||
promptkit.ExecutionFailureOther:
|
|
||||||
return string(value)
|
|
||||||
default:
|
|
||||||
return "other"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user