ai

package
v1.17.2-0...-d44f2c8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultFemaleVoice = "default-female"
View Source
const DefaultMaleVoice = "default-male"
View Source
const MaxToolCallIterations = 10

MaxToolCallIterations is the maximum number of tool-call/re-prompt cycles that Prompt() will execute before returning an error. This guards against infinite loops when the model keeps requesting tool invocations.

Variables

This section is empty.

Functions

func DocumentFromBase64

func DocumentFromBase64(content string, options ...contractsai.AttachmentOption) contractsai.Attachment

func DocumentFromByte

func DocumentFromByte(content []byte, options ...contractsai.AttachmentOption) contractsai.Attachment

func DocumentFromID

func DocumentFromID(id string) contractsai.ProviderFile

func DocumentFromPath

func DocumentFromPath(path string, options ...contractsai.AttachmentOption) contractsai.Attachment

func DocumentFromReader

func DocumentFromReader(reader io.Reader, options ...contractsai.AttachmentOption) contractsai.Attachment

func DocumentFromStorage

func DocumentFromStorage(path string, options ...contractsai.AttachmentOption) contractsai.Attachment

func DocumentFromString

func DocumentFromString(content string, options ...contractsai.AttachmentOption) contractsai.Attachment

func DocumentFromURL

func DocumentFromURL(rawURL string, options ...contractsai.AttachmentOption) contractsai.Attachment

func ImageFromBase64

func ImageFromBase64(content string, options ...contractsai.AttachmentOption) contractsai.Attachment

func ImageFromByte

func ImageFromByte(content []byte, options ...contractsai.AttachmentOption) contractsai.Attachment

func ImageFromID

func ImageFromID(id string) contractsai.ProviderFile

func ImageFromPath

func ImageFromPath(path string, options ...contractsai.AttachmentOption) contractsai.Attachment

func ImageFromReader

func ImageFromReader(reader io.Reader, options ...contractsai.AttachmentOption) contractsai.Attachment

func ImageFromStorage

func ImageFromStorage(path string, options ...contractsai.AttachmentOption) contractsai.Attachment

func ImageFromURL

func ImageFromURL(rawURL string, options ...contractsai.AttachmentOption) contractsai.Attachment

func NewAudioRequest

func NewAudioRequest(ctx context.Context, app *Application, prompt string) contractsai.AudioRequest

func NewAudioResponse

func NewAudioResponse(content []byte, mimeType string, usage contractsai.Usage) contractsai.AudioResponse

func NewConversation

func NewConversation(ctx context.Context, agent contractsai.Agent, provider contractsai.Provider, model string, middlewares []contractsai.Middleware) *conversation

func NewFailoverError

func NewFailoverError(provider string, reason contractsai.FailoverReason, cause error) error

NewFailoverError returns an error that instructs the framework to try the next provider.

func NewFileResponse

func NewFileResponse(id, mimeType string, content []byte) contractsai.FileResponse

func NewImageRequest

func NewImageRequest(ctx context.Context, app *Application, prompt string) contractsai.ImageRequest

func NewImageResponse

func NewImageResponse(content []byte, mimeType string, usage contractsai.Usage) contractsai.ImageResponse

func NewImageStorer

func NewImageStorer() contractsai.ImageStorer

func NewTextResponse

func NewTextResponse(text string, usage contractsai.Usage, toolCalls []contractsai.ToolCall) contractsai.AgentResponse

func NewUsage

func NewUsage(input, output, total int) contractsai.Usage

func WithAttachments

func WithAttachments(attachments ...contractsai.Attachment) contractsai.ConversationOption

func WithDisk

func WithDisk(disk string) contractsai.AttachmentOption

func WithMiddleware

func WithMiddleware(middlewares ...contractsai.Middleware) contractsai.Option

func WithMimeType

func WithMimeType(mimeType string) contractsai.AttachmentOption

func WithModel

func WithModel(model string) contractsai.Option

func WithProvider

func WithProvider(provider string, failovers ...string) contractsai.Option

func WithStreamCode

func WithStreamCode(code int) contractsai.StreamOption

func WithStreamRender

func WithStreamRender(render contractsai.RenderFunc) contractsai.StreamOption

func WithTitle

func WithTitle(title string) contractsai.AttachmentOption

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication(ctx context.Context, config contractsai.Config) *Application

func (*Application) Agent

func (*Application) Audio

func (r *Application) Audio(prompt string) contractsai.AudioRequest

func (*Application) Image

func (r *Application) Image(prompt string) contractsai.ImageRequest

func (*Application) Transcription

func (*Application) WithContext

func (r *Application) WithContext(ctx context.Context) contractsai.AI

type FailoverRules

type FailoverRules struct {
	// contains filtered or unexported fields
}

FailoverRules matches provider errors against configured failover patterns.

func NewFailoverRules

func NewFailoverRules(provider string, patterns map[contractsai.FailoverReason][]string) (FailoverRules, error)

NewFailoverRules compiles provider failover patterns. Plain patterns use substring matching; slash-delimited patterns use Go regex syntax.

func (FailoverRules) Match

Match returns the configured failover reason for err.

func (FailoverRules) Wrap

func (r FailoverRules) Wrap(provider string, err error) error

Wrap converts err to a failover error when it matches a configured rule.

type ProviderResolver

type ProviderResolver struct {
	// contains filtered or unexported fields
}

func NewProviderResolver

func NewProviderResolver(config contractsai.Config) *ProviderResolver

func (*ProviderResolver) New

func (r *ProviderResolver) New(providerName string) (contractsai.Provider, error)

type ServiceProvider

type ServiceProvider struct{}

func (*ServiceProvider) Boot

func (r *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (r *ServiceProvider) Register(app foundation.Application)

func (*ServiceProvider) Relationship

func (r *ServiceProvider) Relationship() binding.Relationship

type StreamRunner

type StreamRunner func(ctx context.Context, emit func(contractsai.StreamEvent) error) (contractsai.AgentResponse, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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