apitype

package
v2026.609.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LastAssistantIndex

func LastAssistantIndex(msgs []chatstore.Message) int

func MessageForAPI

func MessageForAPI(m chatstore.Message, includeReasoning bool) chatstore.Message

func MessagesForAPI

func MessagesForAPI(msgs []chatstore.Message) []chatstore.Message

Types

type AssistantToolCall

type AssistantToolCall struct {
	ID        string
	Name      string
	Arguments string
}

type AssistantTurnResult

type AssistantTurnResult struct {
	Content             string
	ReasoningText       string
	ToolCalls           []AssistantToolCall
	Usage               UsageStats
	ProxyToolCorrection string
}

type CompletionBackend

type CompletionBackend interface {
	Protocol() Protocol
	StreamTurn(ctx context.Context, req TurnRequest, contentOut io.Writer, opts StreamOpts) (AssistantTurnResult, error)
	StreamText(ctx context.Context, req SimpleCompletionRequest, contentOut io.Writer, opts StreamOpts) (string, UsageStats, error)
	CompleteText(ctx context.Context, req SimpleCompletionRequest) (string, error)
	ListModels(ctx context.Context) ([]string, error)
}

type Protocol

type Protocol string
const (
	ProtocolOpenAI    Protocol = "openai"
	ProtocolAnthropic Protocol = "anthropic"
)

type SimpleCompletionRequest

type SimpleCompletionRequest struct {
	Cfg                   *config.Root
	Model                 string
	System                string
	User                  string
	ForceDisableReasoning bool
}

type StreamOpts

type StreamOpts struct {
	ShowThinking  bool
	ReasoningSink io.Writer
	OnDelta       func(channel, text string)
	OnRetry       func(attempt int, max int, err error, wait time.Duration)
}

type ToolDef

type ToolDef struct {
	Name        string
	Description string
	Parameters  map[string]any
	Required    []string
}

type TurnRequest

type TurnRequest struct {
	Cfg                   *config.Root
	Model                 string
	System                string
	Messages              []chatstore.Message
	ImageFiles            map[int]string
	Tools                 []ToolDef
	ParallelToolCalls     bool
	ForceDisableReasoning bool
}

type UsageStats

type UsageStats struct {
	PromptTokens              int64
	CachedPromptTokens        int64
	CacheCreationPromptTokens int64
	ReasoningTokens           int64
	ResponseTokens            int64
	TotalTokens               int64
	OutputTPS                 float64
	TTFTSecs                  float64
	PromptTPS                 float64
	TurnWallSecs              float64
	ThoughtSecs               float64
}

Jump to

Keyboard shortcuts

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