Documentation
¶
Index ¶
- Constants
- func DataURL(mime string, data []byte) string
- func DetectMIME(path string, data []byte) string
- func EnsureInboundFileName(name, mime string, data []byte) string
- func ExtensionForMIME(mime string) string
- func FitForVision(data []byte, mime string, opt VisionFitOptions) ([]byte, string, error)
- func FormatReadImageResult(path, mime string, size int64) string
- func FormatReadImageTooLarge(path string, size, max int64) string
- func IsImage(mimeType, path string) bool
- func IsImageMIME(mime string) bool
- func IsImagePath(path string) bool
- func LoadWorkspaceImage(ctx context.Context, ws workspace.Service, workRel string, maxBytes int) ([]byte, string, error)
- func LooksLikeImageData(data []byte) bool
- func NormalizeWorkRel(rel string) string
- func ParseReadImagePath(content string) string
- func ReadFileHead(path string, n int) ([]byte, error)
- func WorkspaceFileMayBeImage(ctx context.Context, ws workspace.Service, workRel string) (bool, error)
- type VisionFitOptions
Constants ¶
const ContentTypeAttachmentRef = "attachment_ref"
ContentTypeAttachmentRef is persisted in session history for stripped attachments.
const DefaultMaxVisionEdgePixels = 2048
DefaultMaxVisionEdgePixels limits the longest image edge when FitForVision is enabled.
const DefaultMaxVisionPayloadBytes = 1 << 20
DefaultMaxVisionPayloadBytes is used when FitForVision is enabled (optional).
const DefaultMaxWorkspaceImageBytes = 10 << 20
DefaultMaxWorkspaceImageBytes caps raw image bytes sent to vision models.
const DefaultMaxWorkspaceImageReadBytes = 10 << 20
DefaultMaxWorkspaceImageReadBytes is the largest workspace image file tools and hydrate may load.
Variables ¶
This section is empty.
Functions ¶
func DetectMIME ¶
DetectMIME guesses image MIME type from path and magic bytes.
func EnsureInboundFileName ¶ added in v0.3.22
EnsureInboundFileName adds a standard image extension when MIME or content indicates an image.
func ExtensionForMIME ¶ added in v0.3.22
ExtensionForMIME maps an image MIME type to a file extension including the dot.
func FitForVision ¶ added in v0.3.22
FitForVision downscales and re-encodes images that exceed vision limits. When the input is already within limits, it is returned unchanged. If decoding fails but the payload is within MaxBytes, the original bytes are returned.
func FormatReadImageResult ¶
FormatReadImageResult is the read-tool metadata format hydrated before LLM calls.
func FormatReadImageTooLarge ¶
FormatReadImageTooLarge explains why a workspace image cannot be viewed.
func IsImageMIME ¶
IsImageMIME reports whether a MIME type is an image.
func IsImagePath ¶
IsImagePath reports whether a workspace-relative path looks like an image file.
func LoadWorkspaceImage ¶
func LoadWorkspaceImage(ctx context.Context, ws workspace.Service, workRel string, maxBytes int) ([]byte, string, error)
LoadWorkspaceImage reads an image from the tenant work tree for vision models. workRel is relative to work/ (e.g. upload/foo.png or work/upload/foo.png).
func LooksLikeImageData ¶ added in v0.3.22
LooksLikeImageData reports whether bytes begin with a known image signature.
func NormalizeWorkRel ¶
NormalizeWorkRel strips leading slashes and an optional work/ prefix.
func ParseReadImagePath ¶
ParseReadImagePath extracts a workspace image path from a read-tool result.
func ReadFileHead ¶ added in v0.3.22
ReadFileHead reads up to n bytes from a file for content sniffing.
Types ¶
type VisionFitOptions ¶ added in v0.3.22
VisionFitOptions controls downscaling and re-encoding for LLM vision input.
func DefaultVisionFitOptions ¶ added in v0.3.22
func DefaultVisionFitOptions() VisionFitOptions
DefaultVisionFitOptions returns the standard vision payload limits.