files

package
v0.0.0-...-f1e0a5e Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Providers = map[string]ProviderConstraints{
	"openai": {
		Provider:        "openai",
		SupportsImage:   true,
		SupportsPDF:     true,
		SupportsAudio:   true,
		SupportsVideo:   false,
		SupportsText:    true,
		ImageMaxBytes:   20 * 1024 * 1024,
		ImageMaxCount:   10,
		PDFMaxBytes:     32 * 1024 * 1024,
		PDFMaxPages:     100,
		AudioMaxBytes:   25 * 1024 * 1024,
		AudioMaxMinutes: 25,
	},
	"anthropic": {
		Provider:       "anthropic",
		SupportsImage:  true,
		SupportsPDF:    true,
		SupportsAudio:  false,
		SupportsVideo:  false,
		SupportsText:   true,
		ImageMaxBytes:  5 * 1024 * 1024,
		ImageMaxCount:  100,
		ImageMaxWidth:  8000,
		ImageMaxHeight: 8000,
		PDFMaxBytes:    32 * 1024 * 1024,
		PDFMaxPages:    100,
	},
	"gemini": {
		Provider:        "gemini",
		SupportsImage:   true,
		SupportsPDF:     true,
		SupportsAudio:   true,
		SupportsVideo:   true,
		SupportsText:    true,
		ImageMaxBytes:   100 * 1024 * 1024,
		PDFMaxBytes:     50 * 1024 * 1024,
		AudioMaxBytes:   100 * 1024 * 1024,
		AudioMaxMinutes: 570,
		VideoMaxBytes:   2 * 1024 * 1024 * 1024,
		VideoMaxMinutes: 60,
	},
	"bedrock": {
		Provider:       "bedrock",
		SupportsImage:  true,
		SupportsPDF:    true,
		SupportsAudio:  false,
		SupportsVideo:  false,
		SupportsText:   true,
		ImageMaxBytes:  4608 * 1024,
		ImageMaxWidth:  8000,
		ImageMaxHeight: 8000,
		PDFMaxBytes:    3840 * 1024,
		PDFMaxPages:    100,
	},
}

Known provider constraints (from CrewAI Python documentation).

Functions

func ValidateFile

func ValidateFile(file File, provider string) error

ValidateFile checks if a file is compatible with a given provider.

Types

type File

type File interface {
	Type() FileType
	Source() string
	Mode() FileMode
	Data() ([]byte, error)
	Base64() (string, error)
	MimeType() string
	SizeBytes() (int64, error)
	TransmitAs() TransmitMethod
}

File is the base interface for all file types.

func AudioFile

func AudioFile(source string, mode ...FileMode) File

AudioFile creates a file handle for audio content.

func FromBytes

func FromBytes(fb FileBytes, mode ...FileMode) File

FromBytes creates a file from raw bytes.

func ImageFile

func ImageFile(source string, mode ...FileMode) File

ImageFile creates a file handle for an image.

func NewFile

func NewFile(source string, mode ...FileMode) File

NewFile auto-detects the file type from extension/content.

func PDFFile

func PDFFile(source string, mode ...FileMode) File

PDFFile creates a file handle for a PDF.

func TextFile

func TextFile(source string, mode ...FileMode) File

TextFile creates a file handle for text content.

func VideoFile

func VideoFile(source string, mode ...FileMode) File

VideoFile creates a file handle for video content.

type FileBytes

type FileBytes struct {
	RawData  []byte
	Filename string
}

FileBytes wraps raw bytes with a filename for in-memory file creation.

type FileMode

type FileMode string

FileMode controls how files are handled when they exceed provider limits.

const (
	ModeStrict FileMode = "strict" // Error if file exceeds limits
	ModeAuto   FileMode = "auto"   // Auto-resize, compress, etc.
	ModeWarn   FileMode = "warn"   // Warn but attempt to send
	ModeChunk  FileMode = "chunk"  // Split large files into chunks
)

type FileType

type FileType string

FileType represents the category of a file.

const (
	TypeImage   FileType = "image"
	TypePDF     FileType = "pdf"
	TypeAudio   FileType = "audio"
	TypeVideo   FileType = "video"
	TypeText    FileType = "text"
	TypeGeneric FileType = "generic"
)

type ProviderConstraints

type ProviderConstraints struct {
	Provider        string
	ImageMaxBytes   int64
	ImageMaxCount   int
	ImageMaxWidth   int
	ImageMaxHeight  int
	PDFMaxBytes     int64
	PDFMaxPages     int
	AudioMaxBytes   int64
	AudioMaxMinutes float64
	VideoMaxBytes   int64
	VideoMaxMinutes float64
	SupportsImage   bool
	SupportsPDF     bool
	SupportsAudio   bool
	SupportsVideo   bool
	SupportsText    bool
}

ProviderConstraints defines the file size and count limits for an LLM provider.

type TransmitMethod

type TransmitMethod string

TransmitMethod indicates how the file content is sent to the LLM.

const (
	TransmitInlineBase64 TransmitMethod = "inline_base64"
	TransmitFileUpload   TransmitMethod = "file_upload"
	TransmitURLReference TransmitMethod = "url_reference"
)

Jump to

Keyboard shortcuts

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