43 lines
1.8 KiB
Go
43 lines
1.8 KiB
Go
package promptkit
|
|
|
|
import "go.maximumdirect.net/promptkit/internal/domain"
|
|
|
|
// CostSource identifies how an observed USD cost was supplied.
|
|
type CostSource string
|
|
|
|
const (
|
|
// CostSourceNone denotes no known sourced contribution.
|
|
CostSourceNone CostSource = ""
|
|
// CostSourceProvider denotes a reported provider or injected-client amount.
|
|
CostSourceProvider CostSource = "provider"
|
|
// CostSourceConfiguredZero denotes an explicitly configured zero fallback.
|
|
CostSourceConfiguredZero CostSource = "configured_zero"
|
|
// CostSourceMixed denotes both provider and configured-zero contributions.
|
|
CostSourceMixed CostSource = "mixed"
|
|
)
|
|
|
|
// ObservedCost reports an available USD subtotal and its coverage and source.
|
|
// Known means at least one contribution is available. Complete means all
|
|
// included dispatched attempts have an amount under the selected policy; it
|
|
// does not verify billing. A completed run with no dispatched attempts, or an
|
|
// empty group, has known complete zero with no source. A group with members but
|
|
// no terminals has unknown cost. Amounts are unrounded binary floating point.
|
|
type ObservedCost struct {
|
|
// Value is the known USD subtotal.
|
|
Value float64 `json:"value"`
|
|
// Known reports whether a subtotal is available.
|
|
Known bool `json:"known"`
|
|
// Complete reports whether all included dispatched attempts are covered.
|
|
Complete bool `json:"complete"`
|
|
// Source summarizes the known contributions.
|
|
Source CostSource `json:"source"`
|
|
}
|
|
|
|
func fromDomainCost(value domain.ObservedCost) ObservedCost {
|
|
return ObservedCost{Value: value.Value, Known: value.Known, Complete: value.Complete, Source: CostSource(value.Source)}
|
|
}
|
|
|
|
func toDomainCost(value ObservedCost) domain.ObservedCost {
|
|
return domain.ObservedCost{Value: value.Value, Known: value.Known, Complete: value.Complete, Source: domain.CostSource(value.Source)}
|
|
}
|