Document invocation observation and cost reporting
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -62,6 +63,7 @@ func TestOrdinaryRunCostMatchesTerminalWithOrWithoutObserver(t *testing.T) {
|
||||
|
||||
func TestOrdinaryRunCostFailureAndFallback(t *testing.T) {
|
||||
charge := .125
|
||||
invalid := math.Inf(1)
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
response *promptkit.GenerateResponse
|
||||
@@ -70,6 +72,7 @@ func TestOrdinaryRunCostFailureAndFallback(t *testing.T) {
|
||||
}{
|
||||
{"reported takes precedence", &promptkit.GenerateResponse{Content: "ok", CostUSD: &charge}, nil, promptkit.ObservedCost{Value: .125, Known: true, Complete: true, Source: promptkit.CostSourceProvider}},
|
||||
{"failed dispatch fallback", nil, errors.New("failure"), promptkit.ObservedCost{Known: true, Complete: true, Source: promptkit.CostSourceConfiguredZero}},
|
||||
{"nonfinite report falls back", &promptkit.GenerateResponse{Content: "ok", CostUSD: &invalid}, nil, promptkit.ObservedCost{Known: true, Complete: true, Source: promptkit.CostSourceConfiguredZero}},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
engine := costEngine(t, true, nil, promptkit.WithLLMClient(observationClientFunc(func(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {
|
||||
|
||||
Reference in New Issue
Block a user