provider

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatClient

type ChatClient interface {
	Chat(ctx context.Context, req ChatRequest) (<-chan StreamEvent, error)
	Model() string
	ContextWindow() int
	Pricing() (float64, float64, float64)
}

type ChatRequest

type ChatRequest struct {
	Model           string            `json:"model"`
	Messages        []message.Message `json:"messages"`
	Tools           []message.ToolDef `json:"tools,omitempty"`
	Stream          bool              `json:"stream"`
	MaxTokens       int               `json:"max_tokens,omitempty"`
	StreamOptions   *StreamOptions    `json:"stream_options,omitempty"`
	Thinking        *ThinkingConfig   `json:"thinking,omitempty"`
	ReasoningEffort string            `json:"reasoning_effort,omitempty"`
}

type Client

type Client struct {
	Profile ModelProfile
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL, model, apiKey string, profile ModelProfile) *Client

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, req ChatRequest) (<-chan StreamEvent, error)

func (*Client) ContextWindow

func (c *Client) ContextWindow() int

func (*Client) Model

func (c *Client) Model() string

func (*Client) Pricing added in v0.1.1

func (c *Client) Pricing() (float64, float64, float64)

func (*Client) SetDebug

func (c *Client) SetDebug(enabled bool)

type ModelProfile

type ModelProfile struct {
	ContextWindow    int
	MaxOutputTokens  int
	ThinkingType     string
	ReasoningEffort  string
	InputPrice       float64
	CachedInputPrice float64
	OutputPrice      float64
}

type PromptTokensDetails added in v0.1.1

type PromptTokensDetails struct {
	CachedTokens int `json:"cached_tokens"`
}

type ProviderError added in v0.1.1

type ProviderError struct {
	StatusCode int
	Body       string
}

func (*ProviderError) Error added in v0.1.1

func (e *ProviderError) Error() string

func (*ProviderError) Retryable added in v0.1.1

func (e *ProviderError) Retryable() bool

type StreamEvent

type StreamEvent struct {
	Type           string          `json:"type"`
	Delta          string          `json:"delta,omitempty"`
	ReasoningDelta string          `json:"reasoningDelta,omitempty"`
	ToolCall       *StreamToolCall `json:"toolCall,omitempty"`
	Usage          *Usage          `json:"usage,omitempty"`
	FinishReason   string          `json:"finishReason,omitempty"`
	Error          error           `json:"-"`
}

type StreamOptions

type StreamOptions struct {
	IncludeUsage bool `json:"include_usage"`
}

type StreamToolCall

type StreamToolCall struct {
	ID        string
	Name      string
	Arguments string
}

type ThinkingConfig

type ThinkingConfig struct {
	Type string `json:"type"`
}

type Usage

type Usage struct {
	PromptTokens         int                  `json:"prompt_tokens"`
	CompletionTokens     int                  `json:"completion_tokens"`
	TotalTokens          int                  `json:"total_tokens"`
	PromptCacheHitTokens int                  `json:"prompt_cache_hit_tokens"`
	PromptTokensDetails  *PromptTokensDetails `json:"prompt_tokens_details"`
}

Jump to

Keyboard shortcuts

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