codeinterp

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout             = errors.New("codeinterp: timeout")
	ErrBudgetExceeded      = errors.New("codeinterp: budget exceeded")
	ErrTokenBudgetExceeded = errors.New("codeinterp: token budget exceeded")
	ErrConversion          = errors.New("codeinterp: conversion error")
)

Functions

func NewTool

func NewTool(model ai.Model, catalog []agent.AgentTool) agent.AgentTool

Types

type BudgetExceededError

type BudgetExceededError struct{ Msg string }

func (BudgetExceededError) Error

func (e BudgetExceededError) Error() string

func (BudgetExceededError) Unwrap

func (BudgetExceededError) Unwrap() error

type Config

type Config struct {
	MaxSteps       int
	MaxWallTime    time.Duration
	MaxTraceBytes  int
	MaxResultBytes int

	MaxLLMCalls     int
	MaxLLMTokens    int
	MaxLLMCostUSD   float64
	LLMConcurrency  int
	DefaultLLMModel string

	MaxStoreBytes     int64
	MaxStoreKeySize   int
	MaxStoreValueSize int64

	Tier Tier
}

func DefaultFullConfig

func DefaultFullConfig() Config

func DefaultLightweightConfig

func DefaultLightweightConfig() Config

type ExecuteRequest

type ExecuteRequest struct {
	Code          string
	Entrypoint    string
	Args          map[string]any
	Tier          string
	MaxSteps      int
	TimeoutMs     int
	MaxLLMTokens  int
	MaxLLMCostUSD float64
	DatastoreType string
}

type ExecuteResult

type ExecuteResult struct {
	Result    any         `json:"result"`
	Trace     []TraceStep `json:"trace"`
	Stats     Stats       `json:"stats"`
	Truncated bool        `json:"truncated"`
	Tier      string      `json:"tier"`
}

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime(model ai.Model, catalog []agent.AgentTool) *Runtime

func (*Runtime) Execute

func (r *Runtime) Execute(ctx context.Context, req ExecuteRequest) (ExecuteResult, error)

type Stats

type Stats struct {
	Steps         int     `json:"steps"`
	DurationMs    int64   `json:"duration_ms"`
	ToolCalls     int     `json:"tool_calls"`
	DiscoverCalls int     `json:"discover_calls"`
	DescribeCalls int     `json:"describe_calls"`
	LLMCalls      int     `json:"llm_calls"`
	LLMTokensUsed int     `json:"llm_tokens_used"`
	LLMCostUSD    float64 `json:"llm_cost_usd"`
	StoreOps      int     `json:"store_ops"`
}

type Tier

type Tier int
const (
	TierLightweight Tier = iota
	TierFull
)

func ClassifyTier

func ClassifyTier(code string, req ExecuteRequest) Tier

type TimeoutError

type TimeoutError struct{ Msg string }

func (TimeoutError) Error

func (e TimeoutError) Error() string

func (TimeoutError) Unwrap

func (TimeoutError) Unwrap() error

type TokenBudgetExceededError

type TokenBudgetExceededError struct{ Msg string }

func (TokenBudgetExceededError) Error

func (e TokenBudgetExceededError) Error() string

func (TokenBudgetExceededError) Unwrap

type TraceStep

type TraceStep struct {
	Kind       string         `json:"kind"`
	Name       string         `json:"name"`
	Input      map[string]any `json:"input,omitempty"`
	Output     any            `json:"output,omitempty"`
	Error      string         `json:"error,omitempty"`
	DurationMs int64          `json:"duration_ms,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL