Documentation
¶
Overview ¶
Package types provides Hawk-owned runtime types and shared compatibility aliases. Severity, TokenSeverity, and AuditSeverity are forwarded from hawk-core-contracts/types. Provider-facing compatibility now lives in explicit adapters inside internal/types/client.go.
Index ¶
- Constants
- Variables
- func DetectProvider() string
- func RegisterDynamicProvider(name, baseURL, apiKeyEnv string) error
- func ToClientChatOptions(opts ChatOptions) client.ChatOptions
- func ToClientConfig(cfg *ClientConfig) *client.EyrieConfig
- func ToClientContinuationConfig(cfg ContinuationConfig) client.ContinuationConfig
- func ToClientEyrieTool(tool EyrieTool) client.EyrieTool
- func ToClientEyrieTools(tools []EyrieTool) []client.EyrieTool
- func ToClientMessage(msg EyrieMessage) client.EyrieMessage
- func ToClientMessages(messages []EyrieMessage) []client.EyrieMessage
- func ToClientResponseFormat(format *ResponseFormat) *client.ResponseFormat
- func ToClientStreamEvent(ev EyrieStreamEvent) client.EyrieStreamEvent
- func ToClientToolCall(tc ToolCall) client.ToolCall
- func ToClientToolCalls(calls []ToolCall) []client.ToolCall
- func ToClientToolChoiceOption(choice *ToolChoiceOption) *client.ToolChoiceOption
- func ToClientToolResult(tr ToolResult) client.ToolResult
- func ToClientToolResults(results []ToolResult) []client.ToolResult
- func ToClientUsage(usage *EyrieUsage) *client.EyrieUsage
- type Attribution
- type AuditSeverity
- type ChatOptions
- type ChatProvider
- type ClientConfig
- type ContentPart
- type ContinuationConfig
- type EyrieClient
- func (c *EyrieClient) Chat(ctx context.Context, messages []EyrieMessage, opts ChatOptions) (*EyrieResponse, error)
- func (c *EyrieClient) GetProviders() []string
- func (c *EyrieClient) Name() string
- func (c *EyrieClient) Ping(ctx context.Context) error
- func (c *EyrieClient) SetAPIKey(provider, apiKey string)
- func (c *EyrieClient) StreamChat(ctx context.Context, messages []EyrieMessage, opts ChatOptions) (*StreamResult, error)
- func (c *EyrieClient) StreamChatContinue(ctx context.Context, messages []EyrieMessage, opts ChatOptions, ...) (*StreamResult, error)
- type EyrieMessage
- type EyrieResponse
- type EyrieStreamEvent
- type EyrieTool
- type EyrieUsage
- type ImageURLPart
- type InputAudioPart
- type ResponseFormat
- type Severity
- type StreamResult
- type TokenSeverity
- type ToolCall
- type ToolChoiceOption
- type ToolResult
Constants ¶
const ( SeverityInfo = contracts.SeverityInfo SeverityLow = contracts.SeverityLow SeverityMedium = contracts.SeverityMedium SeverityHigh = contracts.SeverityHigh SeverityCritical = contracts.SeverityCritical )
const ( TokenSeverityCritical = contracts.TokenSeverityCritical TokenSeverityHigh = contracts.TokenSeverityHigh TokenSeverityMedium = contracts.TokenSeverityMedium TokenSeverityLow = contracts.TokenSeverityLow )
const ( AuditSeverityCritical = contracts.AuditSeverityCritical AuditSeverityWarning = contracts.AuditSeverityWarning AuditSeverityInfo = contracts.AuditSeverityInfo )
Variables ¶
var ParseSeverity = contracts.ParseSeverity
ParseSeverity converts a string to a Severity.
Functions ¶
func DetectProvider ¶
func DetectProvider() string
func RegisterDynamicProvider ¶
func ToClientChatOptions ¶
func ToClientChatOptions(opts ChatOptions) client.ChatOptions
ToClientChatOptions converts Hawk runtime chat options into the provider-runtime shape.
func ToClientConfig ¶
func ToClientConfig(cfg *ClientConfig) *client.EyrieConfig
ToClientConfig converts Hawk-owned transport config into the provider-runtime shape.
func ToClientContinuationConfig ¶
func ToClientContinuationConfig(cfg ContinuationConfig) client.ContinuationConfig
ToClientContinuationConfig converts Hawk runtime continuation settings into the provider-runtime shape.
func ToClientEyrieTool ¶
ToClientEyrieTool converts a Hawk runtime tool definition into the provider-runtime shape.
func ToClientEyrieTools ¶
ToClientEyrieTools converts Hawk runtime tool definitions into provider-runtime tool definitions.
func ToClientMessage ¶
func ToClientMessage(msg EyrieMessage) client.EyrieMessage
ToClientMessage converts a Hawk runtime message into the provider-runtime shape.
func ToClientMessages ¶
func ToClientMessages(messages []EyrieMessage) []client.EyrieMessage
ToClientMessages converts Hawk runtime messages into provider-runtime messages.
func ToClientResponseFormat ¶
func ToClientResponseFormat(format *ResponseFormat) *client.ResponseFormat
ToClientResponseFormat converts a Hawk runtime response format into the provider-runtime shape.
func ToClientStreamEvent ¶
func ToClientStreamEvent(ev EyrieStreamEvent) client.EyrieStreamEvent
ToClientStreamEvent converts a Hawk runtime stream event into the provider-runtime shape.
func ToClientToolCall ¶
ToClientToolCall converts a Hawk runtime tool call into the provider-runtime shape.
func ToClientToolCalls ¶
ToClientToolCalls converts Hawk runtime tool calls into provider-runtime tool calls.
func ToClientToolChoiceOption ¶
func ToClientToolChoiceOption(choice *ToolChoiceOption) *client.ToolChoiceOption
ToClientToolChoiceOption converts a Hawk runtime tool choice into the provider-runtime shape.
func ToClientToolResult ¶
func ToClientToolResult(tr ToolResult) client.ToolResult
ToClientToolResult converts a Hawk runtime tool result into the provider-runtime shape.
func ToClientToolResults ¶
func ToClientToolResults(results []ToolResult) []client.ToolResult
ToClientToolResults converts Hawk runtime tool results into provider-runtime tool results.
func ToClientUsage ¶
func ToClientUsage(usage *EyrieUsage) *client.EyrieUsage
ToClientUsage converts a Hawk runtime usage payload into the provider-runtime shape.
Types ¶
type Attribution ¶
type AuditSeverity ¶
type AuditSeverity = contracts.AuditSeverity
AuditSeverity indicates how dangerous a security audit finding is.
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"`
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 Hawk-owned request options for a runtime chat call.
type ChatProvider ¶
type ChatProvider interface {
Chat(ctx context.Context, messages []EyrieMessage, opts ChatOptions) (*EyrieResponse, error)
StreamChat(ctx context.Context, messages []EyrieMessage, opts ChatOptions) (*StreamResult, error)
Ping(ctx context.Context) error
Name() string
}
ChatProvider is Hawk's transport-provider interface.
func WrapClientProvider ¶
func WrapClientProvider(p client.Provider) ChatProvider
type ClientConfig ¶
type ClientConfig 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"`
}
ClientConfig is Hawk-owned client construction config at the transport edge.
type ContentPart ¶
type ContentPart = client.ContentPart
type ContinuationConfig ¶
ContinuationConfig controls output continuation behavior for Hawk runtime calls.
func DefaultContinuationConfig ¶
func DefaultContinuationConfig() ContinuationConfig
type EyrieClient ¶
type EyrieClient struct {
// contains filtered or unexported fields
}
EyrieClient adapts eyrie's client to Hawk-owned message DTOs.
func NewClient ¶
func NewClient(cfg *ClientConfig) *EyrieClient
func (*EyrieClient) Chat ¶
func (c *EyrieClient) Chat(ctx context.Context, messages []EyrieMessage, opts ChatOptions) (*EyrieResponse, error)
func (*EyrieClient) GetProviders ¶
func (c *EyrieClient) GetProviders() []string
func (*EyrieClient) Name ¶
func (c *EyrieClient) Name() string
func (*EyrieClient) SetAPIKey ¶
func (c *EyrieClient) SetAPIKey(provider, apiKey string)
func (*EyrieClient) StreamChat ¶
func (c *EyrieClient) StreamChat(ctx context.Context, messages []EyrieMessage, opts ChatOptions) (*StreamResult, error)
func (*EyrieClient) StreamChatContinue ¶
func (c *EyrieClient) StreamChatContinue(ctx context.Context, messages []EyrieMessage, opts ChatOptions, cfg ContinuationConfig) (*StreamResult, error)
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 Hawk's runtime conversation DTO. It intentionally mirrors the provider runtime shape while remaining Hawk-owned.
func FromClientMessage ¶
func FromClientMessage(msg client.EyrieMessage) EyrieMessage
FromClientMessage converts a provider-runtime message into Hawk's runtime shape.
func FromClientMessages ¶
func FromClientMessages(messages []client.EyrieMessage) []EyrieMessage
FromClientMessages converts provider-runtime messages into Hawk runtime messages.
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"`
}
EyrieResponse is Hawk's runtime chat response DTO.
func FromClientResponse ¶
func FromClientResponse(resp *client.EyrieResponse) *EyrieResponse
FromClientResponse converts a provider-runtime response into Hawk's runtime shape.
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"`
RequestID string `json:"request_id,omitempty"`
Usage *EyrieUsage `json:"usage,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
TTFTms int `json:"ttft_ms,omitempty"`
TTFT int `json:"ttft,omitempty"`
}
EyrieStreamEvent is Hawk's runtime stream event DTO.
func FromClientStreamEvent ¶
func FromClientStreamEvent(ev client.EyrieStreamEvent) EyrieStreamEvent
FromClientStreamEvent converts a provider-runtime stream event into Hawk's runtime shape.
type EyrieTool ¶
type EyrieTool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]interface{} `json:"parameters"`
}
EyrieTool is Hawk's runtime tool definition DTO.
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 for Hawk runtime responses and streams.
func FromClientUsage ¶
func FromClientUsage(usage *client.EyrieUsage) *EyrieUsage
FromClientUsage converts a provider-runtime usage payload into Hawk's runtime shape.
type ImageURLPart ¶
type ImageURLPart = client.ImageURLPart
type InputAudioPart ¶
type InputAudioPart = client.InputAudioPart
type ResponseFormat ¶
ResponseFormat specifies the desired output format for a Hawk runtime request.
type StreamResult ¶
type StreamResult struct {
Events <-chan EyrieStreamEvent
RequestID string
// contains filtered or unexported fields
}
StreamResult wraps a Hawk-owned streaming response with cleanup.
func FromClientStreamResult ¶
func FromClientStreamResult(stream *client.StreamResult) *StreamResult
FromClientStreamResult converts a provider-runtime stream result into Hawk's runtime shape.
func StreamChatWithContinuation ¶
func StreamChatWithContinuation(ctx context.Context, p ChatProvider, messages []EyrieMessage, opts ChatOptions, cfg ContinuationConfig) (*StreamResult, error)
func (*StreamResult) Close ¶
func (sr *StreamResult) Close()
Close stops the stream and releases resources.
type TokenSeverity ¶
type TokenSeverity = contracts.TokenSeverity
TokenSeverity defines rule severity for compression error patterns.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Arguments map[string]interface{} `json:"arguments"`
}
ToolCall is Hawk's runtime tool invocation DTO.
func FromClientToolCall ¶
FromClientToolCall converts a provider-runtime tool call into Hawk's runtime shape.
func FromClientToolCalls ¶
FromClientToolCalls converts provider-runtime tool calls into Hawk runtime tool calls.
func ParseInlineToolCalls ¶
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 struct {
ToolUseID string `json:"tool_use_id"`
Content string `json:"content"`
IsError bool `json:"is_error,omitempty"`
}
ToolResult is Hawk's runtime tool result DTO.
func FromClientToolResult ¶
func FromClientToolResult(tr client.ToolResult) ToolResult
FromClientToolResult converts a provider-runtime tool result into Hawk's runtime shape.
func FromClientToolResults ¶
func FromClientToolResults(results []client.ToolResult) []ToolResult
FromClientToolResults converts provider-runtime tool results into Hawk runtime tool results.