Documentation
¶
Overview ¶
Package surplus is a scriptable fake of the Surplus Intelligence API (markets, models, balance, request lookup, chat/responses/embeddings with floor and ZDR prefixes, and scripted errors).
Index ¶
Constants ¶
const ( ChargeInline = "inline" ChargeRequests = "requests" ChargeNone = "none" )
ChargeIn values for Script.ChargeIn.
const ( // DefaultChatContent holds two zero-width non-joiners (U+200C) so // byte-for-byte streaming fidelity is verified. DefaultChatContent = "می\u200cشود و نمی\u200cخواهم" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is a multi-instance Surplus fake. Each /s/{name} has independent script and recorded state. It is safe for concurrent use.
func (*Fake) Reset ¶
func (f *Fake) Reset()
Reset clears every instance's script, paths, and recorded requests.
type Script ¶
type Script struct {
Markets json.RawMessage `json:"markets,omitempty"` // whole /api/markets body; default: two models
Models json.RawMessage `json:"models,omitempty"` // whole /v1/models body; default: two models
Balance *string `json:"balance,omitempty"` // credit_balance_usdc; nil = default "5000000"
Charge *int64 `json:"charge,omitempty"` // micro-USD; nil = omit header, body field and /v1/requests value
ChargeIn string `json:"charge_in,omitempty"` // "inline" (default) | "requests" | "none"
Error *ScriptedError `json:"error,omitempty"` // next N inference calls: status, code, param, retry_after
MarketsStatus int `json:"markets_status,omitempty"` // non-zero: /api/markets answers this status
}
Script configures a named fake Surplus instance (/s/{name}).
type ScriptedError ¶
type ScriptedError struct {
Status int `json:"status"`
Code string `json:"code"`
Message string `json:"message,omitempty"`
Type string `json:"type,omitempty"`
Param string `json:"param,omitempty"`
RetryAfter string `json:"retry_after,omitempty"`
Count int `json:"count,omitempty"` // 0 defaults to 1 call; negative repeats until reset
}
ScriptedError configures an error returned by the next N inference calls.