Help us shape the future of Go! Take the 2026 Go Developer Survey

attachments

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxFiles          = 20
	DefaultMaxTotalBytes     = int64(50_000_000)
	DefaultMaxPDFBytes       = int64(25_000_000)
	DefaultMaxExtractedChars = 200_000
)

Variables

This section is empty.

Functions

func ExtractPDFText

func ExtractPDFText(data []byte, maxChars int) (string, bool, error)

ExtractPDFText performs a best-effort text extraction for simple PDFs without external binaries. It scans raw and Flate-compressed streams for PDF string drawing operators. Complex/encrypted/scanned PDFs may still require native PDF model input or OCR.

func ImageMimeFromExt

func ImageMimeFromExt(ext string) string

func IsInlineTextFile

func IsInlineTextFile(path string, data []byte) bool

func SniffImageMime

func SniffImageMime(b []byte) string

Types

type AttachedFile

type AttachedFile struct {
	Path     string
	MimeType string
	Mode     string // native, extracted-text, inlined-text
}

type Options

type Options struct {
	CWD               string
	Provider          string
	Model             string
	MaxFiles          int
	MaxTotalBytes     int64
	MaxPDFBytes       int64
	MaxExtractedChars int
}

type ResolvedUserInput

type ResolvedUserInput struct {
	Text        string
	Attachments []ai.ContentBlock
	Warnings    []string
	Attached    []AttachedFile
}

func ResolveUserInput

func ResolveUserInput(text string, opts Options) ResolvedUserInput

ResolveUserInput finds local file references in user text, inlines readable text files, and returns image/PDF content blocks plus warnings for anything that looked like a reference but could not be used.

Jump to

Keyboard shortcuts

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