Documentation
¶
Index ¶
- Variables
- func BuildPrompt(focusHint string, language ...string) string
- func DefaultPrompt() string
- func HostCallbackID(ctx context.Context) string
- func IsPayloadTooLarge(err error) bool
- func NormalizeLanguage(language string) string
- func WithHostCallbackID(ctx context.Context, callbackID string) context.Context
- type Analyzer
- type AttemptFailure
- type BatchAnalyzer
- type Failure
- type FailureCategory
- type FallbackAnalyzer
- type FallbackOptions
- type HTTPStatusError
- type HostClient
- type HostExecuteFunc
- type HostOptions
- type ImageInput
Constants ¶
This section is empty.
Variables ¶
var ( 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 ¶
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 IsPayloadTooLarge ¶
func NormalizeLanguage ¶
NormalizeLanguage returns a stable, prompt-safe language identifier used by both the request prompt and preprocessing cache key.
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.
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) 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) AnalyzeBatch ¶
func (c *HostClient) AnalyzeBatch(ctx context.Context, images []ImageInput, promptContext string) (string, error)
type HostExecuteFunc ¶
type HostExecuteFunc func(context.Context, pluginapi.HostModelExecutionRequest, string) (pluginapi.HostModelExecutionResponse, error)
type HostOptions ¶
type HostOptions struct {
Model string
MaxResponseBytes int64
Language string
Execute HostExecuteFunc
}
type ImageInput ¶
ImageInput identifies one image inside a prompt-level visual request.