vision

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHostExecutorUnavailable = errors.New("host model executor is unavailable")
	ErrInvalidResponse         = errors.New("invalid visual model response")
	ErrEmptyResponse           = errors.New("visual model returned empty response")
	ErrResponseTooLarge        = errors.New("visual model response exceeds size limit")
	ErrResultTooLarge          = errors.New("visual model result exceeds character limit")
	ErrEmptyImageBatch         = errors.New("visual model image batch is empty")
)

Functions

func BuildPrompt

func BuildPrompt(focusHint string, language ...string) string

BuildPrompt appends an optional focus hint from the surrounding user text. The hint is bounded and clearly delimited so it cannot replace the safety instructions in the fixed prompt.

func DefaultPrompt

func DefaultPrompt() string

DefaultPrompt is exported for tests and adapters that need to include it in a cache key. The string is immutable by convention.

func HostCallbackID

func HostCallbackID(ctx context.Context) string

func IsPayloadTooLarge

func IsPayloadTooLarge(err error) bool

func NormalizeLanguage

func NormalizeLanguage(language string) string

NormalizeLanguage returns a stable, prompt-safe language identifier used by both the request prompt and preprocessing cache key.

func WithHostCallbackID

func WithHostCallbackID(ctx context.Context, callbackID string) context.Context

Types

type Analyzer

type Analyzer interface {
	Analyze(ctx context.Context, imageReference, focusHint string) (string, error)
}

Analyzer is the backward-compatible single-image seam used by simple test adapters. Production analyzers should also implement BatchAnalyzer.

type AttemptFailure added in v0.3.0

type AttemptFailure struct {
	Model          string          `json:"model"`
	Category       FailureCategory `json:"category"`
	UpstreamStatus int             `json:"upstream_status,omitempty"`
	Retryable      bool            `json:"retryable"`
}

AttemptFailure is safe to expose because it contains no provider response body, image reference, prompt, header, or credential.

func (AttemptFailure) String added in v0.3.0

func (a AttemptFailure) String() string

type BatchAnalyzer

type BatchAnalyzer interface {
	AnalyzeBatch(ctx context.Context, images []ImageInput, prompt string) (string, error)
}

BatchAnalyzer is implemented by analyzers that can preserve relationships between all images attached to one prompt in a single model request.

type Failure added in v0.3.0

type Failure struct {
	Code     string           `json:"-"`
	Attempts []AttemptFailure `json:"attempts"`
	// contains filtered or unexported fields
}

Failure reports the ordered attempts made for one prompt group.

func (*Failure) Error added in v0.3.0

func (e *Failure) Error() string

func (*Failure) Unwrap added in v0.3.0

func (e *Failure) Unwrap() error

type FailureCategory added in v0.3.0

type FailureCategory string

FailureCategory is a stable, content-free vision attempt outcome.

const (
	FailureHostExecutor     FailureCategory = "host_executor_error"
	FailureAttemptTimeout   FailureCategory = "attempt_timeout"
	FailureUpstreamHTTP     FailureCategory = "upstream_http"
	FailureInvalidResponse  FailureCategory = "invalid_response"
	FailureEmptyResponse    FailureCategory = "empty_response"
	FailureResponseTooLarge FailureCategory = "response_too_large"
	FailureResultTooLarge   FailureCategory = "result_too_large"
	FailureRequestTimeout   FailureCategory = "request_timeout"
	FailureRewriteFailed    FailureCategory = "rewrite_failed"
)

type FallbackAnalyzer added in v0.3.0

type FallbackAnalyzer struct {
	// contains filtered or unexported fields
}

FallbackAnalyzer attempts configured host models in order within the parent request deadline. It retains provider transport and credential ownership in CLIProxyAPI through HostClient.

func NewFallbackAnalyzer added in v0.3.0

func NewFallbackAnalyzer(opts FallbackOptions) (*FallbackAnalyzer, error)

func (*FallbackAnalyzer) Analyze added in v0.3.0

func (a *FallbackAnalyzer) Analyze(ctx context.Context, imageReference, focusHint string) (string, error)

func (*FallbackAnalyzer) AnalyzeBatch added in v0.3.0

func (a *FallbackAnalyzer) AnalyzeBatch(ctx context.Context, images []ImageInput, prompt string) (string, error)

type FallbackOptions added in v0.3.0

type FallbackOptions struct {
	Models           []string
	MaxResponseBytes int64
	MaxResultChars   int
	Language         string
	Execute          HostExecuteFunc
}

FallbackOptions configures an ordered primary-plus-fallback model chain.

type HTTPStatusError

type HTTPStatusError struct{ StatusCode int }

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

type HostClient

type HostClient struct {
	// contains filtered or unexported fields
}

func NewHostClient

func NewHostClient(opts HostOptions) (*HostClient, error)

func (*HostClient) Analyze

func (c *HostClient) Analyze(ctx context.Context, imageReference, focusHint string) (string, error)

func (*HostClient) AnalyzeBatch

func (c *HostClient) AnalyzeBatch(ctx context.Context, images []ImageInput, promptContext string) (string, error)

type HostOptions

type HostOptions struct {
	Model            string
	MaxResponseBytes int64
	Language         string
	Execute          HostExecuteFunc
}

type ImageInput

type ImageInput struct {
	Number    int    `json:"number"`
	Reference string `json:"reference"`
}

ImageInput identifies one image inside a prompt-level visual request.

Jump to

Keyboard shortcuts

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