perception

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package perception defines transport-free content interpretation and image observation contracts. Providers decide which modalities they can handle; callers decide what content may be sent to them.

Index

Constants

View Source
const APIVersion = "intelligence.perception/v1"

Variables

View Source
var ErrInvalid = errors.New("invalid perception value")

Functions

This section is empty.

Types

type Finding

type Finding struct {
	Kind        string   `json:"kind"`
	Text        string   `json:"text"`
	SourceParts []int    `json:"sourceParts"`
	Confidence  *float64 `json:"confidence,omitempty"`
}

Finding preserves the source part indexes for model-produced claims.

type Info

type Info struct {
	ID           string   `json:"id"`
	Capabilities []string `json:"capabilities"`
}

Info is the provider's declared capabilities, not a claim about every model.

func (Info) Validate

func (i Info) Validate() error

type InterpretRequest

type InterpretRequest struct {
	APIVersion string `json:"apiVersion"`
	RequestID  string `json:"requestId,omitempty"`
	Model      string `json:"model"`
	Parts      []Part `json:"parts"`
	Prompt     string `json:"prompt,omitempty"`
}

func (InterpretRequest) Validate

func (r InterpretRequest) Validate() error

type InterpretResponse

type InterpretResponse struct {
	APIVersion string    `json:"apiVersion"`
	RequestID  string    `json:"requestId,omitempty"`
	Findings   []Finding `json:"findings"`
}

func (InterpretResponse) Validate

func (r InterpretResponse) Validate(request InterpretRequest) error

type Interpreter

type Interpreter interface {
	Interpret(context.Context, InterpretRequest) (InterpretResponse, error)
}

type Observation

type Observation struct {
	Kind       string  `json:"kind"`
	Label      string  `json:"label"`
	Confidence float64 `json:"confidence"`
	Region     Region  `json:"region"`
	Mask       string  `json:"mask,omitempty"`
	Evidence   string  `json:"evidence,omitempty"`
}

Observation describes a detected region. Mask is a base64 PNG, when set.

type ObserveRequest

type ObserveRequest struct {
	APIVersion string `json:"apiVersion"`
	RequestID  string `json:"requestId,omitempty"`
	Model      string `json:"model"`
	MediaType  string `json:"mediaType"`
	Image      []byte `json:"image"`
	Prompt     string `json:"prompt,omitempty"`
}

func (ObserveRequest) Validate

func (r ObserveRequest) Validate() error

type ObserveResponse

type ObserveResponse struct {
	APIVersion   string        `json:"apiVersion"`
	RequestID    string        `json:"requestId,omitempty"`
	Observations []Observation `json:"observations"`
}

func (ObserveResponse) Validate

func (r ObserveResponse) Validate(request ObserveRequest) error

type Observer

type Observer interface {
	Observe(context.Context, ObserveRequest) (ObserveResponse, error)
}

type Part

type Part struct {
	Kind      string `json:"kind"` // text, image, audio, or video
	Text      string `json:"text,omitempty"`
	MediaType string `json:"mediaType,omitempty"`
	Data      []byte `json:"data,omitempty"`
}

Part is caller-supplied content. No field is an implicit path to open.

type Provider

type Provider interface {
	Info(context.Context) (Info, error)
	Close() error
}

type Region

type Region struct {
	X      float64 `json:"x"`
	Y      float64 `json:"y"`
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

Jump to

Keyboard shortcuts

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