Documentation
¶
Index ¶
- Constants
- Variables
- func CacheRebuildCost(event Event, prices *TokenPrices) (float64, bool)
- func CacheRebuildDollars(event Event, prices TokenPrices) float64
- func CacheRebuildNotice(event Event, cost string) string
- func FailureText(event Event) string
- func IsCacheRebuildWorthNoticing(event Event, prices *TokenPrices) bool
- func TitleFromEvent(event Event) (string, bool)
- type Agent
- func (self *Agent) AddUserMessage(text string)
- func (self *Agent) CacheLifetime() time.Duration
- func (self *Agent) Dump() ([]json.RawMessage, error)
- func (self *Agent) IsToolEnabled(name string) bool
- func (self *Agent) Load(items []json.RawMessage) error
- func (self *Agent) RestoreCache(cacheReading CacheReading)
- func (self *Agent) RestoreState(events []Event) error
- func (self *Agent) Send(ctx context.Context, message string) (string, error)
- func (self *Agent) StorePicturesWith(store func(tool.Image) *Picture)
- func (self *Agent) Stream(ctx context.Context, message string, interjections *Interjections) iter.Seq2[Update, error]
- func (self *Agent) TakeRetryWaitsAtOnce()
- func (self *Agent) TakeTimeFrom(clock func() time.Time)
- func (self *Agent) Tool(name string) (tool.Tool, bool)
- type CacheCause
- type CacheLifetimeReporter
- type CacheReading
- type CacheUsage
- type CallFaulted
- type Delta
- type Event
- type Failure
- type FailureKind
- type FallbackRendering
- type Interjections
- func (self *Interjections) Add(text string) bool
- func (self *Interjections) HasMessages() bool
- func (self *Interjections) Note(text string) bool
- func (self *Interjections) Peek() []string
- func (self *Interjections) Take() (string, bool)
- func (self *Interjections) TakeLast() (string, bool)
- func (self *Interjections) TakeNotes() (string, bool)
- type Kind
- type Lister
- type Model
- type Output
- type Picture
- type PriceTier
- type Provider
- type Reply
- type Resumable
- type Retriable
- type State
- type Status
- type TitleState
- type TokenPrices
- type ToolCall
- type ToolCallResult
- type Update
- type Usage
- type UsageAvailability
- type UsageLimitError
- type UsageProbe
- type UsageProber
- type UsageReporter
- type UsageWindow
- type Yield
Constants ¶
View Source
const ( SilentTurnNotice = "Model returned no reply." PrefixRewriteNotice = "Request prefix changed: " )
View Source
const CancelledOutput = "the call was cancelled"
View Source
const InterjectionSeparator = "\n\n"
View Source
const TitleStateKey = "title"
View Source
const (
TokensPerPricedUnit = 1_000_000
)
Variables ¶
Functions ¶
func CacheRebuildCost ¶ added in v0.12.0
func CacheRebuildCost(event Event, prices *TokenPrices) (float64, bool)
func CacheRebuildDollars ¶ added in v0.12.0
func CacheRebuildDollars(event Event, prices TokenPrices) float64
func CacheRebuildNotice ¶
func FailureText ¶
func IsCacheRebuildWorthNoticing ¶ added in v0.12.0
func IsCacheRebuildWorthNoticing(event Event, prices *TokenPrices) bool
func TitleFromEvent ¶
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewWithEnabledTools ¶
func (*Agent) AddUserMessage ¶
func (*Agent) CacheLifetime ¶
func (*Agent) IsToolEnabled ¶
func (*Agent) RestoreCache ¶
func (self *Agent) RestoreCache(cacheReading CacheReading)
func (*Agent) RestoreState ¶
func (*Agent) StorePicturesWith ¶
func (*Agent) TakeRetryWaitsAtOnce ¶
func (self *Agent) TakeRetryWaitsAtOnce()
func (*Agent) TakeTimeFrom ¶
type CacheCause ¶
type CacheCause string
const ( CacheReopened CacheCause = "reopened" CacheExpired CacheCause = "expired" CacheRebuilt CacheCause = "rebuilt" CacheSettling CacheCause = "settling" )
type CacheLifetimeReporter ¶
type CacheReading ¶
type CacheUsage ¶
type CallFaulted ¶
type Event ¶
type Event struct {
FallbackRendering
Kind Kind `json:"kind"`
Text string `json:"text,omitempty"`
Failure *Failure `json:"failure,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Status Status `json:"status,omitempty"`
Took time.Duration `json:"took,omitempty"`
Attempt int `json:"attempt,omitempty"`
Metrics *tool.ToolCallMetrics `json:"stats,omitempty"`
Picture *Picture `json:"picture,omitempty"`
State json.RawMessage `json:"state,omitempty"`
Usage *Usage `json:"usage,omitempty"`
}
type Failure ¶
type Failure struct {
Kind FailureKind `json:"kind"`
Context string `json:"context,omitempty"`
Message string `json:"message,omitempty"`
HTTPStatus int `json:"http_status,omitempty"`
Code string `json:"code,omitempty"`
Body string `json:"body,omitempty"`
MediaType string `json:"media_type,omitempty"`
}
func FailureFrom ¶
func (Failure) IsContextExceeded ¶
type FailureKind ¶
type FailureKind string
const ( GenericFailure FailureKind = "generic_error" HTTPStatusFailure FailureKind = "http_status" )
type FallbackRendering ¶
type FallbackRendering struct {
RenderingKind string `json:"rendering_kind,omitempty"`
Subject string `json:"render,omitempty"`
Note string `json:"detail,omitempty"`
PathLine string `json:"path_line,omitempty"`
Emphasis tool.Emphasis `json:"emphasis,omitzero"`
Continuation []tool.CallRendering `json:"continuation,omitempty"`
Intent string `json:"intent,omitempty"`
Introduces string `json:"introduces,omitempty"`
Mentions []string `json:"mentions,omitempty"`
ShowOutput bool `json:"show_output,omitempty"`
ReadOnly bool `json:"read_only,omitempty"`
MarksSuccess bool `json:"marks_success,omitempty"`
}
func (*FallbackRendering) Describe ¶
func (self *FallbackRendering) Describe(toolCall tool.ToolCall)
func (*FallbackRendering) SetRendering ¶ added in v0.11.0
func (self *FallbackRendering) SetRendering(rendering tool.CallRendering)
type Interjections ¶
type Interjections struct {
// contains filtered or unexported fields
}
func (*Interjections) Add ¶
func (self *Interjections) Add(text string) bool
func (*Interjections) HasMessages ¶ added in v0.9.0
func (self *Interjections) HasMessages() bool
func (*Interjections) Note ¶
func (self *Interjections) Note(text string) bool
func (*Interjections) Peek ¶
func (self *Interjections) Peek() []string
func (*Interjections) Take ¶
func (self *Interjections) Take() (string, bool)
func (*Interjections) TakeLast ¶
func (self *Interjections) TakeLast() (string, bool)
func (*Interjections) TakeNotes ¶
func (self *Interjections) TakeNotes() (string, bool)
type Kind ¶
type Kind string
const ( StartupEvent Kind = "session_startup" UserMessageEvent Kind = "user_message" SilentTurnEvent Kind = "silent_turn" PrefixRewriteEvent Kind = "prefix_rewrite" CacheRebuildEvent Kind = "cache_rebuild" ModelReasoningEvent Kind = "model_reasoning" ModelMessageEvent Kind = "model_message" ToolCallRequestEvent Kind = "tool_call_request" ToolCallResultEvent Kind = "tool_call_result" StateChangeEvent Kind = "state_change" InterruptionEvent Kind = "turn_interruption" RetryingEvent Kind = "request_retry" FailureEvent Kind = "turn_failure" )
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
EffortLevels []string `json:"efforts,omitempty"`
IsEffortless bool `json:"effortless,omitempty"`
ContextWindowTokens int `json:"context,omitempty"`
MaxOutputTokens int `json:"output,omitempty"`
Prices *TokenPrices `json:"prices,omitempty"`
}
type Provider ¶
type Provider interface {
Configure(systemPrompt string, tools []tool.Definition)
AddUserMessage(text string)
AddToolResults(toolResults []ToolCallResult)
Send(ctx context.Context, yield Yield) (Reply, error)
}
type State ¶
type State interface {
Dump() []json.RawMessage
Load(items []json.RawMessage)
}
type TitleState ¶
type TitleState struct {
Title string `json:"title"`
}
type TokenPrices ¶
type TokenPrices struct {
Input float64 `json:"input,omitempty"`
Output float64 `json:"output,omitempty"`
CacheRead float64 `json:"cache_read,omitempty"`
CacheWrite float64 `json:"cache_write,omitempty"`
}
func (TokenPrices) BlendedRate ¶
func (self TokenPrices) BlendedRate() float64
func (TokenPrices) IsKnown ¶
func (self TokenPrices) IsKnown() bool
func (TokenPrices) Tier ¶
func (self TokenPrices) Tier() PriceTier
type ToolCallResult ¶
type Usage ¶
type Usage struct {
InputTokens int `json:"input_tokens,omitempty"`
OutputTokens int `json:"output_tokens,omitempty"`
Cache *CacheUsage `json:"cache,omitempty"`
}
type UsageAvailability ¶
type UsageAvailability int
const ( UsageAvailabilityUnknown UsageAvailability = iota UsageAvailabilityAllowed UsageAvailabilityLimited )
type UsageLimitError ¶
type UsageLimitError struct {
Cause error
Windows []UsageWindow
}
func (*UsageLimitError) Error ¶
func (self *UsageLimitError) Error() string
func (*UsageLimitError) Retriable ¶
func (*UsageLimitError) Retriable() bool
func (*UsageLimitError) RetryAfter ¶
func (*UsageLimitError) RetryAfter() time.Duration
func (*UsageLimitError) Unwrap ¶
func (self *UsageLimitError) Unwrap() error
type UsageProbe ¶
type UsageProbe struct {
Windows []UsageWindow
Availability UsageAvailability
RefreshAfter time.Duration
}
type UsageProber ¶
type UsageProber interface {
ProbeUsage(context context.Context) (UsageProbe, error)
}
type UsageReporter ¶
type UsageReporter interface {
IsAvailable() bool
UsageWindows(context context.Context) ([]UsageWindow, error)
}
type UsageWindow ¶
Click to show internal directories.
Click to hide internal directories.