Documentation
¶
Overview ¶
Package llm is the canonical provider port contract for the hawk ecosystem.
It is the single source of truth for the conversation DTOs and the Provider interface that hawk (product face) and eyrie (provider engine) speak across their boundary. Both sides alias to these types, so there is exactly one definition of each DTO and no per-call conversion.
hawk owns the product vocabulary (hence names like EyrieMessage); eyrie implements the port. eyrie's internal transport types stay eyrie-scoped and never appear here.
Index ¶
- type CatalogHealth
- type CatalogMaintenance
- type CatalogSnapshot
- type ChatOptions
- type CheckStatus
- type ContentPart
- type ContinuationConfig
- type CredentialManager
- type CredentialProviderOption
- type CredentialResolution
- type CredentialStatus
- type DeploymentSummary
- type EventStreamer
- type EyrieConfig
- type EyrieMessage
- type EyrieResponse
- type EyrieStreamEvent
- type EyrieTool
- type EyrieUsage
- type Gateway
- type GatewayInspector
- type GenerateRequest
- type GenerationOptions
- type Generator
- type ImageURLPart
- type InputAudioPart
- type Intent
- type Limits
- type Metadata
- type Model
- type ModelCatalog
- type ModelClass
- type NativeCompactionRequest
- type NativeCompactor
- type Preference
- type PreflightCheck
- type PreflightOptions
- type PreflightReport
- type Provider
- type ProviderStateSecurity
- type Requirements
- type ResolvedRoute
- type ResponseFormat
- type Selection
- type SelectionManager
- type SelectionOptions
- type StatePaths
- type StreamResult
- type ToolCall
- type ToolChoiceOption
- type ToolResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatalogHealth ¶
type CatalogHealth struct {
Path string `json:"path"`
Exists bool `json:"exists"`
ModifiedAt time.Time `json:"modified_at,omitempty"`
Size int64 `json:"size,omitempty"`
Models int `json:"models,omitempty"`
Deployments int `json:"deployments,omitempty"`
Offerings int `json:"offerings,omitempty"`
Stale bool `json:"stale,omitempty"`
StaleAfter time.Time `json:"stale_after,omitempty"`
Source string `json:"source,omitempty"`
Error string `json:"error,omitempty"`
}
CatalogHealth reports the health of the model catalog (host-facing).
type CatalogMaintenance ¶
type CatalogMaintenance interface {
RefreshCatalog(ctx context.Context, providerID string) (CatalogSnapshot, error)
CatalogHealth(ctx context.Context) CatalogHealth
StatePaths() StatePaths
DefaultProviderFilter(ctx context.Context) string
Preflight(ctx context.Context) PreflightReport
PreflightWithOptions(ctx context.Context, opts PreflightOptions) PreflightReport
ProviderStateSecurityStatus() ProviderStateSecurity
MigrateProviderSecrets() error
MigrateProviderSecretsContext(ctx context.Context) error
}
CatalogMaintenance is the refresh/preflight/security facet (config only).
type CatalogSnapshot ¶
type CatalogSnapshot struct {
Models []Model `json:"models"`
CachePath string `json:"cache_path,omitempty"`
RemoteURL string `json:"remote_url,omitempty"`
Stale bool `json:"stale,omitempty"`
LoadedAt time.Time `json:"loaded_at"`
}
CatalogSnapshot is an immutable, point-in-time host-facing view of a loaded model catalog. It is the canonical definition; eyrie's engine.CatalogSnapshot is a type alias to this so a single struct crosses the host boundary.
type ChatOptions ¶
type ChatOptions struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Stream bool `json:"stream,omitempty"`
Tools []EyrieTool `json:"tools,omitempty"`
System string `json:"system,omitempty"`
EnableCaching bool `json:"enable_caching,omitempty"`
ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
ThinkingBudgetTokens int `json:"thinking_budget_tokens,omitempty"`
ThinkingMode string `json:"thinking_mode,omitempty"`
ThinkingDisplay string `json:"thinking_display,omitempty"`
ThinkingEnabled *bool `json:"thinking_enabled,omitempty"`
// GLMThinkingEnabled toggles GLM/Z.ai extended reasoning via the provider's
// non-OpenAI thinking={"type":"enabled"|"disabled"} request parameter. Only
// applied for OpenAI-compatible providers whose compat config sets
// ThinkingFormat to "zai". When nil the parameter is omitted and the model
// uses its default (GLM defaults to enabled).
GLMThinkingEnabled *bool `json:"glm_thinking_enabled,omitempty"`
VirtualKeyID string `json:"virtual_key_id,omitempty"`
KimiContextCacheID string `json:"kimi_context_cache_id,omitempty"`
KimiCacheResetTTL bool `json:"kimi_cache_reset_ttl,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
ToolChoice *ToolChoiceOption `json:"tool_choice,omitempty"`
MetadataUserID string `json:"metadata_user_id,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
OutputEffort string `json:"output_effort,omitempty"`
OutputSchema string `json:"output_schema,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
N *int `json:"n,omitempty"`
LogProbs *bool `json:"logprobs,omitempty"`
TopLogProbs *int `json:"top_logprobs,omitempty"`
Seed *int `json:"seed,omitempty"`
Store *bool `json:"store,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Modalities []string `json:"modalities,omitempty"`
AudioConfig string `json:"audio_config,omitempty"`
Prediction string `json:"prediction,omitempty"`
WebSearchOptions string `json:"web_search_options,omitempty"`
}
ChatOptions holds request options for an engine chat call.
type CheckStatus ¶ added in v0.1.8
type CheckStatus string
CheckStatus is a preflight check status string.
const ( CheckOK CheckStatus = "ok" CheckFail CheckStatus = "fail" CheckWarn CheckStatus = "warn" )
Common preflight check statuses.
type ContentPart ¶
type ContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *ImageURLPart `json:"image_url,omitempty"`
InputAudio *InputAudioPart `json:"input_audio,omitempty"`
}
ContentPart is a provider-neutral multimodal message part.
type ContinuationConfig ¶
ContinuationConfig controls output continuation behavior.
type CredentialManager ¶
type CredentialManager interface {
SaveCredential(ctx context.Context, providerID, secret string) (CredentialStatus, error)
RemoveCredential(ctx context.Context, providerID string) error
CredentialStatus(ctx context.Context, providerID string) (CredentialStatus, error)
SaveCredentialEnv(ctx context.Context, envVar, secret string) error
HasCredentialEnv(ctx context.Context, envVar string) bool
CredentialEnvKeys(providerID string) []string
ResolveCredential(ctx context.Context, secret string) CredentialResolution
CredentialProviders(context.Context) []CredentialProviderOption
ApplyCredentials(ctx context.Context, providerID string) (CatalogSnapshot, error)
}
CredentialManager is the key/credential facet (config only).
type CredentialProviderOption ¶
type CredentialProviderOption struct {
ProviderID string `json:"provider_id"`
DeploymentID string `json:"deployment_id,omitempty"`
EnvVar string `json:"env_var"`
DisplayName string `json:"display_name"`
Inferred bool `json:"inferred,omitempty"`
RequiresKey bool `json:"requires_key"`
Rank int `json:"rank"`
}
CredentialProviderOption is one provider row in the key picker.
type CredentialResolution ¶
type CredentialResolution struct {
FormatOK bool `json:"format_ok"`
FormatError string `json:"format_error,omitempty"`
Providers []CredentialProviderOption
ProbeDisambiguationUsed bool `json:"probe_disambiguation_used,omitempty"`
}
CredentialResolution is the result of validating a pasted API key.
type CredentialStatus ¶
type CredentialStatus struct {
Configured bool `json:"configured"`
ProviderID string `json:"provider_id,omitempty"`
EnvironmentVariable string `json:"environment_variable,omitempty"`
EnvironmentConflict bool `json:"environment_conflict,omitempty"`
Verified bool `json:"verified,omitempty"`
Masked string `json:"masked,omitempty"`
EnvVar string `json:"env_var,omitempty"`
}
CredentialStatus reports whether a provider's credential is configured.
type DeploymentSummary ¶
type DeploymentSummary struct {
RoutingSource string `json:"routing_source,omitempty"`
RoutingStages int `json:"routing_stages,omitempty"`
Formatted string `json:"formatted"`
}
DeploymentSummary summarizes deployment routing for a model (host-facing).
type EventStreamer ¶ added in v0.1.8
type EventStreamer interface {
Next() bool
Event() EyrieStreamEvent
Err() error
Close() error
}
EventStreamer is the pull-based host stream contract used by the engine facade. Next must not be called concurrently. Close is idempotent.
type EyrieConfig ¶
type EyrieConfig struct {
Provider string `json:"provider,omitempty"`
APIKey string `json:"-"`
BaseURL string `json:"base_url,omitempty"`
Model string `json:"model,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
}
EyrieConfig holds client configuration.
type EyrieMessage ¶
type EyrieMessage struct {
Role string `json:"role"`
Content string `json:"content,omitempty"`
Thinking string `json:"thinking,omitempty"`
ContentParts []ContentPart `json:"content_parts,omitempty"`
Images []string `json:"images,omitempty"`
ToolUse []ToolCall `json:"tool_use,omitempty"`
ToolResults []ToolResult `json:"tool_results,omitempty"`
}
EyrieMessage is the provider-neutral conversation message shape.
type EyrieResponse ¶
type EyrieResponse struct {
Content string `json:"content"`
Thinking string `json:"thinking,omitempty"`
Usage *EyrieUsage `json:"usage,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
FinishReason string `json:"finish_reason"`
RequestID string `json:"request_id,omitempty"`
OrganizationID string `json:"organization_id,omitempty"`
Route *ResolvedRoute `json:"route,omitempty"`
}
EyrieResponse is the chat response DTO.
type EyrieStreamEvent ¶
type EyrieStreamEvent struct {
Type string `json:"type"`
Content string `json:"content,omitempty"`
ToolCall *ToolCall `json:"tool_call,omitempty"`
Thinking string `json:"thinking,omitempty"`
Error string `json:"error,omitempty"`
Warning string `json:"warning,omitempty"`
RequestID string `json:"request_id,omitempty"`
Usage *EyrieUsage `json:"usage,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
// TTFT and TTFTms both carry time-to-first-token in milliseconds but ride
// different events: the dedicated "ttft" event populates TTFT, while the
// terminal "done" event populates TTFTms. The engine normalizes the two
// into a single value (preferring TTFTms, falling back to TTFT). Both are
// retained for wire compatibility with existing producers/consumers.
TTFTms int `json:"ttft_ms,omitempty"`
TTFT int `json:"ttft,omitempty"`
Route *ResolvedRoute `json:"route,omitempty"`
}
EyrieStreamEvent is a streaming event.
type EyrieTool ¶
type EyrieTool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]interface{} `json:"parameters"`
}
EyrieTool is a tool definition.
type EyrieUsage ¶
type EyrieUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
CacheCreationTokens int `json:"cache_creation_tokens,omitempty"`
CacheReadTokens int `json:"cache_read_tokens,omitempty"`
ThinkingTokens int `json:"thinking_tokens,omitempty"`
}
EyrieUsage tracks token usage.
type Gateway ¶
type Gateway struct {
ID string `json:"id"`
DisplayName string `json:"display_name"`
DeploymentID string `json:"deployment_id,omitempty"`
CredentialEnv string `json:"credential_env"`
RequiresKey bool `json:"requires_key"`
SortOrder int `json:"sort_order"`
ChatPreference int `json:"chat_preference"`
SupportsLiveDiscovery bool `json:"supports_live_discovery"`
CredentialConfigured bool `json:"credential_configured"`
DeploymentConfigured bool `json:"deployment_configured"`
ModelCount int `json:"model_count"`
RegionLabel string `json:"region_label,omitempty"`
RegionRequired bool `json:"region_required"`
Active bool `json:"active"`
}
Gateway is a provider/gateway descriptor.
type GatewayInspector ¶
type GatewayInspector interface {
GatewayDefinitions() []Gateway
Gateways(ctx context.Context) []Gateway
GatewayRegion(providerID string) (label string, required bool)
SetGatewayRegion(ctx context.Context, providerID, value string) error
GatewayForModel(ctx context.Context, modelID string) string
CanonicalModel(ctx context.Context, modelID string) string
DeploymentRoutingEnabled(override *bool) bool
DeploymentStatus(ctx context.Context, activeModel string) (string, error)
DeploymentSummary(ctx context.Context, activeModel string) (DeploymentSummary, error)
RoutingPreview(ctx context.Context, modelID string) (string, error)
}
GatewayInspector is the gateway/deployment facet (config only).
type GenerateRequest ¶
type GenerateRequest struct {
Messages []EyrieMessage
SystemPrompt string
Tools []EyrieTool
Requirements Requirements
Preference Preference
Limits Limits
Metadata Metadata
Temperature *float64
OutputSchema string
Options GenerationOptions
}
GenerateRequest is the normalized generation request.
type GenerationOptions ¶
type GenerationOptions struct {
EnableCaching bool
ReasoningEffort string
ThinkingBudgetTokens int
ThinkingMode string
ThinkingDisplay string
ThinkingEnabled *bool
// GLMThinkingEnabled toggles GLM/Z.ai extended reasoning via the provider's
// non-OpenAI thinking={"type":"enabled"|"disabled"} request parameter. Only
// applied for OpenAI-compatible providers whose compat config sets
// ThinkingFormat to "zai". When nil the parameter is omitted and the model
// uses its default (GLM defaults to enabled).
GLMThinkingEnabled *bool
VirtualKeyID string
KimiContextCacheID string
KimiCacheResetTTL bool
TopP *float64
TopK *int
StopSequences []string
ToolChoice *ToolChoiceOption
ServiceTier string
OutputEffort string
PresencePenalty *float64
FrequencyPenalty *float64
N *int
LogProbs *bool
TopLogProbs *int
Seed *int
Store *bool
Metadata map[string]string
Modalities []string
AudioConfig string
Prediction string
WebSearchOptions string
}
GenerationOptions holds provider-specific generation knobs.
type Generator ¶
type Generator interface {
Generate(ctx context.Context, req GenerateRequest) (*EyrieResponse, error)
Stream(ctx context.Context, req GenerateRequest) (EventStreamer, error)
}
Generator is the chat transport facet: the only part the ChatClient path uses.
Stream returns a pull-based EventStreamer (the host engine facade contract). Lower-level channel-based streaming still uses StreamResult on the client transport layer; that type is intentionally not part of this host port.
type ImageURLPart ¶
ImageURLPart describes an image URL or data URI.
type InputAudioPart ¶
InputAudioPart describes base64-encoded audio content.
type Intent ¶
type Intent string
Intent expresses a host's semantic preference without naming a provider.
type Limits ¶
type Limits struct {
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
MaxContinuations int `json:"max_continuations,omitempty"`
MaxTotalOutputTokens int `json:"max_total_output_tokens,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
}
Limits declares output limits.
type Metadata ¶
type Metadata struct {
SessionID string `json:"session_id,omitempty"`
TurnID string `json:"turn_id,omitempty"`
UserID string `json:"user_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
}
Metadata carries request-scoped metadata.
type Model ¶
type Model struct {
ID string `json:"id"`
ProviderID string `json:"provider_id"`
CanonicalID string `json:"canonical_id,omitempty"`
DisplayName string `json:"display_name"`
Description string `json:"description,omitempty"`
Owner string `json:"owner,omitempty"`
GatewayID string `json:"gateway_id,omitempty"`
ContextWindow int `json:"context_window,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
InputPricePer1M float64 `json:"input_price_per_1m,omitempty"`
OutputPricePer1M float64 `json:"output_price_per_1m,omitempty"`
PriceKnown bool `json:"price_known"`
Capabilities []string `json:"capabilities,omitempty"`
Source string `json:"source,omitempty"`
LiveMetadata json.RawMessage `json:"live_metadata,omitempty"`
}
Model is the product-facing view of model metadata.
type ModelCatalog ¶
type ModelCatalog interface {
ListModels(ctx context.Context, providerID string, refresh bool) ([]Model, error)
ListLiveModels(ctx context.Context, providerID string) ([]Model, error)
ListPublicModels(ctx context.Context, providerID string) ([]Model, error)
ModelInfo(ctx context.Context, modelID string) (Model, bool, error)
ModelProviders(ctx context.Context) ([]string, error)
DefaultModel(ctx context.Context, provider, fallback string) string
PreferredModel(ctx context.Context, provider string, class ModelClass, fallback string) string
PreferredModels(ctx context.Context, primaryProvider string, class ModelClass, limit int) []string
ModelClassOf(ctx context.Context, modelID string) ModelClass
ProviderForModel(ctx context.Context, modelID string) string
PrimaryModel(ctx context.Context) string
ModelNames(ctx context.Context) []string
Catalog(ctx context.Context) (CatalogSnapshot, error)
}
ModelCatalog is the model-discovery facet (used by routing + config).
type ModelClass ¶
type ModelClass string
ModelClass is a provider-neutral relative model cost/capability band.
const ( ModelClassEconomical ModelClass = "economical" ModelClassBalanced ModelClass = "balanced" ModelClassPremium ModelClass = "premium" )
type NativeCompactionRequest ¶
type NativeCompactionRequest struct {
Provider string
Model string
Messages []EyrieMessage
ContextWindow int
ThresholdPct int
MaxOutputTokens int
}
NativeCompactionRequest is a native-compaction request.
type NativeCompactor ¶
type NativeCompactor interface {
SupportsNativeCompaction(ctx context.Context, provider, model string) bool
CompactNative(ctx context.Context, req NativeCompactionRequest) (string, error)
}
NativeCompactor is the provider-native-compaction facet.
type Preference ¶
type Preference struct {
Intent Intent `json:"intent,omitempty"`
PreferredProvider string `json:"-"`
PreferredModelID string `json:"preferred_model_id,omitempty"`
AllowFallback bool `json:"allow_fallback,omitempty"`
MaximumCostUSD float64 `json:"maximum_cost_usd,omitempty"`
}
Preference declares the preferred provider/model.
type PreflightCheck ¶
type PreflightCheck struct {
Name string `json:"name"`
Status CheckStatus `json:"status"`
Detail string `json:"detail,omitempty"`
}
PreflightCheck is one readiness check.
type PreflightOptions ¶
type PreflightOptions struct {
VerifyLive bool `json:"verify_live,omitempty"`
}
PreflightOptions configures a preflight check.
type PreflightReport ¶
type PreflightReport struct {
Ready bool `json:"ready"`
LiveVerified bool `json:"live_verified"`
Checks []PreflightCheck `json:"checks"`
}
PreflightReport is the result of a preflight check.
type Provider ¶
type Provider interface {
Generator
ModelCatalog
CredentialManager
SelectionManager
GatewayInspector
CatalogMaintenance
NativeCompactor
}
Provider is hawk's hawk-owned view of the provider engine: a composition of the role interfaces below. It is the single integration surface — hawk never holds an *eyrieengine.Engine, and eyrie never imports hawk/internal.
Callers that need only a subset depend on the relevant role interface directly (e.g. session_factory depends only on Generator), keeping the declared dependency precise and the test stub small.
type ProviderStateSecurity ¶
type ProviderStateSecurity struct {
Path string `json:"path"`
HasSecrets bool `json:"has_secrets"`
Detail string `json:"detail,omitempty"`
Error string `json:"error,omitempty"`
}
ProviderStateSecurity reports security state of provider config.
type Requirements ¶
type Requirements struct {
Streaming bool
Tools bool
Vision bool
StructuredJSON bool
Reasoning bool
MinimumContext int `json:"minimum_context,omitempty"`
}
Requirements declare what the request needs from the engine.
type ResolvedRoute ¶
type ResolvedRoute struct {
Provider string `json:"provider"`
Model string `json:"model"`
DeploymentRouting bool `json:"deployment_routing,omitempty"`
}
ResolvedRoute is the concrete provider/model route selected by the engine.
type ResponseFormat ¶
ResponseFormat specifies the desired output format for a model response.
type Selection ¶
type Selection struct {
Provider string `json:"provider"`
Model string `json:"model"`
HasConfiguredDeployment bool `json:"has_configured_deployment"`
DeploymentRouting bool `json:"deployment_routing"`
}
Selection is the effective provider/model pair.
type SelectionManager ¶
type SelectionManager interface {
ActiveSelection(ctx context.Context) ResolvedRoute
EffectiveSelection(ctx context.Context, opts SelectionOptions) Selection
SetActiveProvider(ctx context.Context, provider string) error
SetActiveModel(ctx context.Context, modelID string) error
SetSelection(ctx context.Context, provider, modelID string) error
ClearSelection(ctx context.Context) error
}
SelectionManager is the get/set selection facet (config only).
type SelectionOptions ¶
type SelectionOptions struct {
ProviderOverride string
ModelOverride string
DeploymentRoutingOverride *bool
}
SelectionOptions controls effective-selection resolution.
type StatePaths ¶
type StatePaths struct {
Catalog string `json:"catalog"`
ProviderConfig string `json:"provider_config"`
}
StatePaths is the on-disk location of catalog + provider config.
type StreamResult ¶
type StreamResult struct {
Events <-chan EyrieStreamEvent
RequestID string
// contains filtered or unexported fields
}
StreamResult wraps a streaming response with cleanup. Callers must call Close() when done reading events, or cancel the context.
func NewStreamResult ¶
func NewStreamResult(events <-chan EyrieStreamEvent, requestID string, cancel context.CancelFunc) *StreamResult
NewStreamResult constructs a stream result. The cancel function is optional and must be idempotent.
func (*StreamResult) Close ¶
func (sr *StreamResult) Close()
Close stops the stream and releases resources.
type ToolCall ¶
ToolCall is a tool invocation. Aliased to tools.ToolCall so the ecosystem has a single ToolCall/ToolResult vocabulary (see tools/tool.go).
type ToolChoiceOption ¶
type ToolChoiceOption struct {
Type string `json:"type"`
Name string `json:"name,omitempty"`
DisableParallelToolUse bool `json:"disable_parallel_tool_use,omitempty"`
}
ToolChoiceOption controls how the model uses tools.
type ToolResult ¶
type ToolResult = tools.ToolResult
ToolResult is a tool execution result. Aliased to tools.ToolResult.