provider

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package provider defines Alaska's LLM provider abstraction. Concrete providers (Anthropic, OpenAI, Alaska API) live in subpackages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatRequest

type ChatRequest struct {
	Model           string
	System          string
	Messages        []Message
	MaxTokens       int
	Temperature     float64
	ReasoningEffort string
	Tools           []ToolSpec
}

type Message

type Message struct {
	Role       Role
	Content    string
	ToolCalls  []ToolCall
	ToolCallID string
}

Message is one entry in the chat transcript sent to the model.

  • role=user → Content is what the user typed.
  • role=assistant → Content is the model's text (may be empty if only tool_calls). ToolCalls is populated when the model asked to run tools.
  • role=tool → Content is the tool output; ToolCallID ties it to a specific call.

type ModelInfo

type ModelInfo struct {
	ID          string
	DisplayName string
	Note        string
}

ModelCatalog is a curated list of models known to work with each provider type. Used by `/model` (interactive picker) and `alaska provider models`. Custom providers of type "openai" with a base_url get no default catalog — users list models via `alaska provider models <name>` which hits the remote /models endpoint.

func KnownModels

func KnownModels(providerType string) []ModelInfo

KnownModels returns a static catalog for a provider type. Empty slice means "no known catalog — discover at runtime or let the user type the id".

type Provider

type Provider interface {
	Name() string
	Stream(ctx context.Context, req ChatRequest) (<-chan StreamChunk, error)
	// SupportsTools reports whether the provider forwards Tools to the model.
	// Providers that return false will silently ignore req.Tools.
	SupportsTools() bool
}

type Role

type Role string
const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool" // reply from the local machine after executing a tool_call
)

type StreamChunk

type StreamChunk struct {
	Delta    string
	ToolCall *ToolCall
	Err      error
}

StreamChunk carries one piece of the provider's streaming response. Exactly one of Delta / ToolCall / Err is populated per chunk.

type ToolCall added in v0.4.0

type ToolCall struct {
	ID       string
	Name     string
	ArgsJSON string
}

ToolCall is a single function-call requested by the model.

type ToolSpec added in v0.4.0

type ToolSpec struct {
	Name        string
	Description string
	Schema      json.RawMessage
}

ToolSpec describes a local tool to the model so it knows what arguments are valid. Schema is a JSON-Schema object.

Directories

Path Synopsis
Package anthropic implements the provider.Provider interface on top of the official anthropics/anthropic-sdk-go client.
Package anthropic implements the provider.Provider interface on top of the official anthropics/anthropic-sdk-go client.
Package factory constructs a provider.Provider from a config entry + OS keyring.
Package factory constructs a provider.Provider from a config entry + OS keyring.
Package openai implements the provider.Provider interface on top of the official openai/openai-go client.
Package openai implements the provider.Provider interface on top of the official openai/openai-go client.

Jump to

Keyboard shortcuts

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