Documentation
¶
Index ¶
- Constants
- func DocumentFromBase64(content string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func DocumentFromByte(content []byte, options ...contractsai.AttachmentOption) contractsai.Attachment
- func DocumentFromID(id string) contractsai.ProviderFile
- func DocumentFromPath(path string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func DocumentFromReader(reader io.Reader, options ...contractsai.AttachmentOption) contractsai.Attachment
- func DocumentFromStorage(path string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func DocumentFromString(content string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func DocumentFromURL(rawURL string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func DocumentFromUpload(file contractsfilesystem.File, options ...contractsai.AttachmentOption) contractsai.Attachment
- func ImageFromBase64(content string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func ImageFromByte(content []byte, options ...contractsai.AttachmentOption) contractsai.Attachment
- func ImageFromID(id string) contractsai.ProviderFile
- func ImageFromPath(path string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func ImageFromReader(reader io.Reader, options ...contractsai.AttachmentOption) contractsai.Attachment
- func ImageFromStorage(path string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func ImageFromURL(rawURL string, options ...contractsai.AttachmentOption) contractsai.Attachment
- func ImageFromUpload(file contractsfilesystem.File, options ...contractsai.AttachmentOption) contractsai.Attachment
- func NewAudioRequest(ctx context.Context, app *Application, prompt string) contractsai.AudioRequest
- func NewAudioResponse(content []byte, mimeType string, usage contractsai.Usage) contractsai.AudioResponse
- func NewConversation(ctx context.Context, agent contractsai.Agent, provider contractsai.Provider, ...) *conversation
- func NewFailoverError(provider string, reason contractsai.FailoverReason, cause error) error
- func NewFileResponse(id, mimeType string, content []byte) contractsai.FileResponse
- func NewImageRequest(ctx context.Context, app *Application, prompt string) contractsai.ImageRequest
- func NewImageResponse(content []byte, mimeType string, usage contractsai.Usage) contractsai.ImageResponse
- func NewImageStorer() contractsai.ImageStorer
- func NewStreamableResponse(ctx context.Context, runner StreamRunner) contractsai.StreamableAgentResponse
- func NewTextResponse(text string, usage contractsai.Usage, toolCalls []contractsai.ToolCall) contractsai.AgentResponse
- func NewTranscriptionRequest(ctx context.Context, app *Application, file contractsai.StorableFile) contractsai.TranscriptionRequest
- func NewTranscriptionResponse(text string, segments []contractsai.TranscriptionSegment, ...) contractsai.TranscriptionResponse
- func NewUsage(input, output, total int) contractsai.Usage
- func WithAttachments(attachments ...contractsai.Attachment) contractsai.ConversationOption
- func WithDisk(disk string) contractsai.AttachmentOption
- func WithMiddleware(middlewares ...contractsai.Middleware) contractsai.Option
- func WithMimeType(mimeType string) contractsai.AttachmentOption
- func WithModel(model string) contractsai.Option
- func WithProvider(provider string, failovers ...string) contractsai.Option
- func WithStreamCode(code int) contractsai.StreamOption
- func WithStreamRender(render contractsai.RenderFunc) contractsai.StreamOption
- func WithTitle(title string) contractsai.AttachmentOption
- type Application
- func (r *Application) Agent(agent contractsai.Agent, options ...contractsai.Option) (contractsai.Conversation, error)
- func (r *Application) Audio(prompt string) contractsai.AudioRequest
- func (r *Application) Image(prompt string) contractsai.ImageRequest
- func (r *Application) Transcription(file contractsai.StorableFile) contractsai.TranscriptionRequest
- func (r *Application) WithContext(ctx context.Context) contractsai.AI
- type FailoverRules
- type ProviderResolver
- type ServiceProvider
- type StreamRunner
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 DocumentFromUpload ¶
func DocumentFromUpload(file contractsfilesystem.File, 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 ImageFromUpload ¶
func ImageFromUpload(file contractsfilesystem.File, 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 NewStreamableResponse ¶
func NewStreamableResponse(ctx context.Context, runner StreamRunner) contractsai.StreamableAgentResponse
func NewTextResponse ¶
func NewTextResponse(text string, usage contractsai.Usage, toolCalls []contractsai.ToolCall) contractsai.AgentResponse
func NewTranscriptionRequest ¶
func NewTranscriptionRequest(ctx context.Context, app *Application, file contractsai.StorableFile) contractsai.TranscriptionRequest
func NewTranscriptionResponse ¶
func NewTranscriptionResponse(text string, segments []contractsai.TranscriptionSegment, usage contractsai.Usage) contractsai.TranscriptionResponse
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 (r *Application) Agent(agent contractsai.Agent, options ...contractsai.Option) (contractsai.Conversation, error)
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 (r *Application) Transcription(file contractsai.StorableFile) contractsai.TranscriptionRequest
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 ¶
func (r FailoverRules) Match(err error) (contractsai.FailoverReason, bool)
Match returns the configured failover reason for err.
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)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.