Documentation
¶
Index ¶
- Constants
- Variables
- func AddSpanExporter(exp SpanExporter)
- func AllProviders() []string
- func ChunkText(text string, opts ...ChunkOption) []string
- func Classify(ctx context.Context, text string, labels []string, opts ...ExtractOption) (string, error)
- func CosineSimilarity(a, b []float32) float32
- func CostGuard(maxCostUSD float64) httpMiddleware
- func CostReport() string
- func DocumentText(a Attachment) (string, error)
- func Embed(ctx context.Context, text string, opts ...GenerateOption) ([]float32, error)
- func EmitRequestEvent(e RequestEvent)
- func EnableCostTracking(cfg CostConfig)
- func EnableTracing(cfg TracingConfig)
- func EstimateTokens(msgs []Message) int
- func ExecuteTool(ctx context.Context, name string, args json.RawMessage) (json.RawMessage, error)
- func Extract[T any](ctx context.Context, text string, opts ...ExtractOption) (*T, error)
- func ExtractSlice[T any](ctx context.Context, text string, opts ...ExtractOption) ([]T, error)
- func GenerateConcatFileContent(scenes []Scene) string
- func GenerateFFmpegResizeCommand(inputPath string, format OutputFormat, outputPath string) []string
- func GenerateStitchCommand(scenes []Scene, cfg StitchConfig) []string
- func GetTotalCost() float64
- func IngestDocuments(ctx context.Context, store *Store, documents map[string]string, ...) error
- func IsConfigured() bool
- func Logger() httpMiddleware
- func OnCompletion(h RequestHook)
- func OnError(h RequestHook)
- func OnRequest(h RequestHook)
- func ParseSkill(content string) (name, description, body string, err error)
- func RateLimit(maxRequests int, window time.Duration) httpMiddleware
- func RegisterProvider(name string, factory ProviderFactory)
- func RegisterTool(t Tool)
- func Reload() error
- func ResetCosts()
- func Retryable(err error) (bool, time.Duration)
- func SetModelPricing(model string, pricing ModelPricing)
- func Stream(ctx context.Context, prompt string, opts ...GenerateOption) (<-chan string, <-chan error)
- func Summarize(ctx context.Context, text string, opts ...SummarizeOption) (string, error)
- func UsageReport() string
- func WithTraceContext(ctx context.Context, tc TraceContext) context.Context
- type APIError
- type Agent
- func (a *Agent) AsTool(name, description string) *Tool
- func (a *Agent) MaxSteps(n int) *Agent
- func (a *Agent) Name() string
- func (a *Agent) Named(name, description string) *Agent
- func (a *Agent) OnApproval(fn ApprovalFunc) *Agent
- func (a *Agent) OnStep(h AgentHook) *Agent
- func (a *Agent) Pending(ctx context.Context) ([]ToolCall, error)
- func (a *Agent) Prompt(ctx context.Context, userMessage string, opts ...GenerateOption) (*GenerateResponse, error)
- func (a *Agent) Resume(ctx context.Context, decisions ...Decision) (*GenerateResponse, error)
- func (a *Agent) Stream(ctx context.Context, userMessage string, opts ...GenerateOption) (*StreamResponse, error)
- func (a *Agent) WithClient(c *Client) *Agent
- func (a *Agent) WithContextLimit(maxTokens int, opts ...ContextOption) *Agent
- func (a *Agent) WithHandoffs(agents ...*Agent) *Agent
- func (a *Agent) WithMCP(clients ...*MCPClient) *Agent
- func (a *Agent) WithMemory(m Memory, key string) *Agent
- func (a *Agent) WithMessages(msgs []Message) *Agent
- func (a *Agent) WithModel(model string) *Agent
- func (a *Agent) WithParallelTools() *Agent
- func (a *Agent) WithPromptCache() *Agent
- func (a *Agent) WithReasoning(effort string) *Agent
- func (a *Agent) WithSkill(skills ...Skill) *Agent
- func (a *Agent) WithSkills(sets ...*SkillSet) *Agent
- func (a *Agent) WithToolObjects(tools ...*Tool) *Agent
- func (a *Agent) WithTools(names ...string) *Agent
- type AgentHook
- type ApprovalFunc
- type ApprovalRequest
- type ApprovalRequiredError
- type Attachment
- type CameraMove
- type ChunkOption
- type Client
- func (c *Client) Generate(ctx context.Context, prompt string, opts ...GenerateOption) (*GenerateResponse, error)
- func (c *Client) GenerateRequest(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (c *Client) Provider() Provider
- func (c *Client) Rerank(ctx context.Context, query string, documents []string, topN int) ([]RerankResult, error)
- func (c *Client) Speak(ctx context.Context, text string, opts ...SpeakOption) (*Speech, error)
- func (c *Client) Stream(ctx context.Context, prompt string, opts ...GenerateOption) (<-chan string, <-chan error)
- func (c *Client) StreamRequest(ctx context.Context, req *GenerateRequest) (*StreamResponse, error)
- func (c *Client) Transcribe(ctx context.Context, audio string, opts ...TranscribeOption) (*Transcription, error)
- func (c *Client) TranscribeAudio(ctx context.Context, audio Attachment, opts ...TranscribeOption) (*Transcription, error)
- type ComparisonReport
- type Config
- type ContentFilter
- type ContextOption
- type ConversationRecord
- type CostConfig
- type CostEntry
- type CostSummary
- type DatabaseMemoryOption
- type Decision
- type DocQA
- type Document
- type EmbeddingProvider
- type EmbeddingRequest
- type EmbeddingResponse
- type EvalCase
- type EvalCheck
- func CustomCheck(name string, fn func(response string) (float64, string)) EvalCheck
- func ExpectContains(substr string) EvalCheck
- func ExpectJSON() EvalCheck
- func ExpectMaxLength(n int) EvalCheck
- func ExpectMinLength(n int) EvalCheck
- func ExpectNotContains(substr string) EvalCheck
- func ExpectSimilarity(expected string, threshold float64) EvalCheck
- func LLMJudge(criteria string) EvalCheck
- type EvalReport
- type EvalResult
- type EvalScore
- type EvalSuite
- func (s *EvalSuite) AddCase(name, prompt string, checks ...EvalCheck) *EvalSuite
- func (s *EvalSuite) AddCaseWithSystem(name, system, prompt string, checks ...EvalCheck) *EvalSuite
- func (s *EvalSuite) Parallel(n int) *EvalSuite
- func (s *EvalSuite) Run(ctx context.Context) *EvalReport
- func (s *EvalSuite) WithModel(model string) *EvalSuite
- func (s *EvalSuite) WithOptions(opts ...GenerateOption) *EvalSuite
- type Example
- type ExtractOption
- type FakeProvider
- func (f *FakeProvider) Client() *Client
- func (f *FakeProvider) Embed(_ context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error)
- func (f *FakeProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (f *FakeProvider) Install() (restore func())
- func (f *FakeProvider) Name() string
- func (f *FakeProvider) Remaining() int
- func (f *FakeProvider) Requests() []GenerateRequest
- func (f *FakeProvider) Stream(ctx context.Context, req *GenerateRequest) (*StreamResponse, error)
- func (f *FakeProvider) StreamsToolCalls() bool
- type FewShotTemplate
- func (f *FewShotTemplate) Add(input, output string) *FewShotTemplate
- func (f *FewShotTemplate) Format(input string) string
- func (f *FewShotTemplate) Generate(ctx context.Context, input string, opts ...GenerateOption) (*GenerateResponse, error)
- func (f *FewShotTemplate) Separator(sep string) *FewShotTemplate
- type GenerateOption
- func WithFiles(refs ...string) GenerateOption
- func WithImages(images []string) GenerateOption
- func WithMaxTokens(n int) GenerateOption
- func WithMessages(msgs []Message) GenerateOption
- func WithModel(model string) GenerateOption
- func WithPromptCache() GenerateOption
- func WithReasoning(effort string) GenerateOption
- func WithSchema(schema json.RawMessage) GenerateOption
- func WithStop(stop ...string) GenerateOption
- func WithSystem(s string) GenerateOption
- func WithTemperature(t float32) GenerateOption
- func WithThinkingBudget(tokens int) GenerateOption
- func WithToolChoice(choice string) GenerateOption
- func WithTopP(p float32) GenerateOption
- type GenerateRequest
- type GenerateResponse
- type GuardrailCheck
- type Guardrails
- func (g *Guardrails) BlockPatterns(patterns ...string) *Guardrails
- func (g *Guardrails) CustomCheck(fn GuardrailCheck) *Guardrails
- func (g *Guardrails) MaxLength(n int) *Guardrails
- func (g *Guardrails) MinLength(n int) *Guardrails
- func (g *Guardrails) RequireKeywords(keywords ...string) *Guardrails
- func (g *Guardrails) SetContentFilter(f ContentFilter) *Guardrails
- func (g *Guardrails) Validate(output string) error
- func (g *Guardrails) ValidateResponse(resp *GenerateResponse) error
- type ImageBuilder
- func (b *ImageBuilder) Count(n int) *ImageBuilder
- func (b *ImageBuilder) Generate(ctx context.Context) (*ImageResponse, error)
- func (b *ImageBuilder) Model(model string) *ImageBuilder
- func (b *ImageBuilder) Prompt(prompt string) *ImageBuilder
- func (b *ImageBuilder) Size(size string) *ImageBuilder
- func (b *ImageBuilder) Style(style string) *ImageBuilder
- func (b *ImageBuilder) WithClient(c *Client) *ImageBuilder
- type ImageData
- type ImageProvider
- type ImageRequest
- type ImageResponse
- type LegacyStreamProvider
- type LogExporter
- type MCPClient
- type MCPOption
- type MCPTransport
- func MCPHTTP(url string, headers map[string]string) MCPTransport
- func MCPInProcess(s *mcpserver.MCPServer) MCPTransport
- func MCPSSE(url string, headers map[string]string) MCPTransport
- func MCPStdio(command string, args ...string) MCPTransport
- func MCPStdioEnv(command string, env []string, args ...string) MCPTransport
- type Memory
- func DatabaseMemory(db *lucid.DB, opts ...DatabaseMemoryOption) Memory
- func MemoryStore(opts ...MemoryStoreOption) Memory
- func RedisMemory(client *redis.Client, opts ...RedisMemoryOption) Memory
- func SlidingWindowMemory(inner Memory, maxMessages int) Memory
- func SummaryMemory(inner Memory, threshold int) Memory
- type MemoryStoreOption
- type Message
- type Metrics
- type ModelCostSummary
- type ModelPricing
- type NamedStep
- type OTLPExporter
- type OutputFormat
- type PgvectorOption
- type PgvectorRecord
- type PineconeOption
- type Plugin
- type PromptChain
- type PromptTemplate
- func (p *PromptTemplate) Format(vars map[string]any) (string, error)
- func (p *PromptTemplate) Generate(ctx context.Context, vars map[string]any, opts ...GenerateOption) (*GenerateResponse, error)
- func (p *PromptTemplate) MustFormat(vars map[string]any) string
- func (p *PromptTemplate) Role(role string) *PromptTemplate
- type Provider
- type ProviderCostSummary
- type ProviderFactory
- type QdrantOption
- type RAG
- func (r *RAG) Ask(ctx context.Context, question string, opts ...GenerateOption) (*RAGResponse, error)
- func (r *RAG) AskStream(ctx context.Context, question string, opts ...GenerateOption) (*StreamResponse, []Document, error)
- func (r *RAG) MinScore(score float32) *RAG
- func (r *RAG) Model(m string) *RAG
- func (r *RAG) OnPostprocess(fn func(string, []Document) string) *RAG
- func (r *RAG) OnPreprocess(fn func(string) string) *RAG
- func (r *RAG) SystemPrompt(s string) *RAG
- func (r *RAG) TopK(k int) *RAG
- func (r *RAG) WithCitations(enabled bool) *RAG
- func (r *RAG) WithClient(c *Client) *RAG
- func (r *RAG) WithReranker(c *Client, keep int) *RAG
- type RAGResponse
- type RawToolFunc
- type Reasoning
- type ReasoningBlock
- type RedisMemoryOption
- type RequestEvent
- type RequestHook
- type RerankProvider
- type RerankRequest
- type RerankResult
- type Scene
- type ScenePlan
- type Skill
- type SkillSet
- type SocialPackage
- type Span
- type SpanEvent
- type SpanExporter
- type SpeakOption
- type Speech
- type SpeechProvider
- type SpeechRequest
- type StepHandler
- type StepResult
- type StitchConfig
- type Store
- func (s *Store) Add(ctx context.Context, id, text string, metadata ...map[string]string) error
- func (s *Store) AddBatch(ctx context.Context, items []struct{ ... }) error
- func (s *Store) AddDocument(ctx context.Context, doc Document) error
- func (s *Store) Count(ctx context.Context) (int, error)
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) Search(ctx context.Context, query string, topK int) ([]Document, error)
- func (s *Store) SearchVector(ctx context.Context, vector []float32, topK int) ([]Document, error)
- type StreamChunk
- type StreamResponse
- type SummarizeOption
- type Tool
- type ToolBuilder
- type ToolCall
- type ToolCallStreamer
- type ToolSpec
- type TraceContext
- type TracingConfig
- type TranscribeOption
- type TranscriptSegment
- type Transcription
- type TranscriptionProvider
- type TranscriptionRequest
- type Usage
- type VectorStoreBackend
- func NewMemoryVectorStore() VectorStoreBackend
- func NewPgvectorStore(db *lucid.DB, opts ...PgvectorOption) VectorStoreBackend
- func NewPineconeStore(host, apiKey string, opts ...PineconeOption) VectorStoreBackend
- func NewQdrantStore(baseURL, collection string, opts ...QdrantOption) VectorStoreBackend
- type VideoBuilder
- func (b *VideoBuilder) Duration(seconds int) *VideoBuilder
- func (b *VideoBuilder) FPS(fps int) *VideoBuilder
- func (b *VideoBuilder) FromImage(url string) *VideoBuilder
- func (b *VideoBuilder) Generate(ctx context.Context) (*VideoResponse, error)
- func (b *VideoBuilder) Model(model string) *VideoBuilder
- func (b *VideoBuilder) Prompt(prompt string) *VideoBuilder
- func (b *VideoBuilder) Size(size string) *VideoBuilder
- func (b *VideoBuilder) WithClient(c *Client) *VideoBuilder
- type VideoPipeline
- func (p *VideoPipeline) ConcurrentScenes(n int) *VideoPipeline
- func (p *VideoPipeline) DefaultDuration(seconds int) *VideoPipeline
- func (p *VideoPipeline) DraftMode(draft bool) *VideoPipeline
- func (p *VideoPipeline) ExpanderModel(model string) *VideoPipeline
- func (p *VideoPipeline) Generate(ctx context.Context, prompt string) (*VideoProject, error)
- func (p *VideoPipeline) GenerateWithSocial(ctx context.Context, prompt string) (*VideoProject, error)
- func (p *VideoPipeline) GlobalStyle(style string) *VideoPipeline
- func (p *VideoPipeline) ImageModel(model string) *VideoPipeline
- func (p *VideoPipeline) MaxScenes(n int) *VideoPipeline
- func (p *VideoPipeline) OnScene(fn func(scene Scene, stage string)) *VideoPipeline
- func (p *VideoPipeline) OutputFmt(format OutputFormat) *VideoPipeline
- func (p *VideoPipeline) PlannerModel(model string) *VideoPipeline
- func (p *VideoPipeline) SeedVariants(n int) *VideoPipeline
- func (p *VideoPipeline) VideoModel(model string) *VideoPipeline
- func (p *VideoPipeline) WithClient(c *Client) *VideoPipeline
- type VideoPipelineConfig
- type VideoProject
- type VideoProvider
- type VideoRequest
- type VideoResponse
- type Workflow
- func (w *Workflow) Branch(name string, selector func(wc *WorkflowContext) string, ...) *Workflow
- func (w *Workflow) OnStep(h WorkflowHook) *Workflow
- func (w *Workflow) Parallel(name string, steps ...NamedStep) *Workflow
- func (w *Workflow) Run(ctx context.Context, input WorkflowInput) (*WorkflowResult, error)
- func (w *Workflow) Step(name string, handler StepHandler) *Workflow
- type WorkflowContext
- type WorkflowHook
- type WorkflowInput
- type WorkflowResult
Constants ¶
const ( MaxSkillNameLen = 64 MaxSkillDescriptionLen = 1024 // MaxSkillFileBytes caps a SKILL.md or a resource file the agent reads, // so one oversized file cannot flood the model's context. MaxSkillFileBytes = 256 << 10 )
Skill limits, from the SKILL.md format.
const ( RoleSystem = "system" RoleUser = "user" RoleAssistant = "assistant" RoleTool = "tool" )
Role constants for chat messages.
const ( ToolChoiceAuto = "auto" ToolChoiceNone = "none" ToolChoiceRequired = "required" )
Tool choices for WithToolChoice.
const DefaultMaxRetries = 2
DefaultMaxRetries is the number of retries after the first attempt when Config.MaxRetries is zero.
const MaxAttachmentBytes = 32 << 20
MaxAttachmentBytes caps one attachment (providers reject larger ones).
const MaxDocumentTextChars = 200_000
MaxDocumentTextChars caps the text extracted from one document for providers that cannot read PDFs themselves.
const SkillToolName = "load_skill"
SkillToolName is the tool an agent with skills calls to load one.
Variables ¶
var ( FormatTikTok = OutputFormat{Name: "tiktok", Width: 1080, Height: 1920, Aspect: "9:16"} FormatInstagram = OutputFormat{Name: "instagram_reel", Width: 1080, Height: 1920, Aspect: "9:16"} FormatYouTube = OutputFormat{Name: "youtube_short", Width: 1080, Height: 1920, Aspect: "9:16"} FormatSquare = OutputFormat{Name: "square", Width: 1080, Height: 1080, Aspect: "1:1"} FormatWide = OutputFormat{Name: "wide", Width: 1920, Height: 1080, Aspect: "16:9"} FormatCinematic = OutputFormat{Name: "cinematic", Width: 1920, Height: 816, Aspect: "2.35:1"} )
Pre-defined social-media output formats.
var DefaultPricing = map[string]ModelPricing{
"gpt-4o": {PromptPer1K: 0.0025, CompletionPer1K: 0.010},
"gpt-4o-mini": {PromptPer1K: 0.00015, CompletionPer1K: 0.0006},
"gpt-4-turbo": {PromptPer1K: 0.010, CompletionPer1K: 0.030},
"gpt-4": {PromptPer1K: 0.030, CompletionPer1K: 0.060},
"gpt-3.5-turbo": {PromptPer1K: 0.0005, CompletionPer1K: 0.0015},
"o1": {PromptPer1K: 0.015, CompletionPer1K: 0.060},
"o1-mini": {PromptPer1K: 0.003, CompletionPer1K: 0.012},
"o3-mini": {PromptPer1K: 0.0011, CompletionPer1K: 0.0044},
"claude-3-5-sonnet-20241022": {PromptPer1K: 0.003, CompletionPer1K: 0.015, CacheReadPer1K: 0.0003, CacheWritePer1K: 0.00375},
"claude-3-5-haiku-20241022": {PromptPer1K: 0.0008, CompletionPer1K: 0.004, CacheReadPer1K: 8e-05, CacheWritePer1K: 0.001},
"claude-3-opus-20240229": {PromptPer1K: 0.015, CompletionPer1K: 0.075, CacheReadPer1K: 0.0015, CacheWritePer1K: 0.01875},
"claude-sonnet-4-20250514": {PromptPer1K: 0.003, CompletionPer1K: 0.015, CacheReadPer1K: 0.0003, CacheWritePer1K: 0.00375},
"claude-opus-4-20250514": {PromptPer1K: 0.015, CompletionPer1K: 0.075, CacheReadPer1K: 0.0015, CacheWritePer1K: 0.01875},
"gemini-2.0-flash": {PromptPer1K: 0.0001, CompletionPer1K: 0.0004},
"gemini-1.5-pro": {PromptPer1K: 0.00125, CompletionPer1K: 0.005},
"gemini-1.5-flash": {PromptPer1K: 0.000075, CompletionPer1K: 0.0003},
"mistral-large-latest": {PromptPer1K: 0.002, CompletionPer1K: 0.006},
"mistral-small-latest": {PromptPer1K: 0.0002, CompletionPer1K: 0.0006},
"command-r-plus": {PromptPer1K: 0.003, CompletionPer1K: 0.015},
"command-r": {PromptPer1K: 0.0005, CompletionPer1K: 0.0015},
"grok-2": {PromptPer1K: 0.002, CompletionPer1K: 0.010},
"grok-2-mini": {PromptPer1K: 0.0002, CompletionPer1K: 0.001},
"_default": {PromptPer1K: 0.001, CompletionPer1K: 0.002},
}
DefaultPricing is the built-in pricing table (USD per 1K tokens). Override or extend with SetModelPricing.
var ErrFakeExhausted = errors.New("ai: fake provider has no more responses")
ErrFakeExhausted is returned when a fake has answered every scripted response.
var ErrNothingToResume = errors.New("ai: no tool calls are waiting for approval")
ErrNothingToResume is returned by Resume when no call is waiting.
var ExportFormats = map[string]OutputFormat{ "tiktok": FormatTikTok, "instagram": FormatInstagram, "youtube": FormatYouTube, "square": FormatSquare, "wide": FormatWide, "cinematic": FormatCinematic, }
ExportFormats defines the standard social media output set.
Functions ¶
func AddSpanExporter ¶
func AddSpanExporter(exp SpanExporter)
AddSpanExporter registers an exporter that receives completed spans. Use this to send spans to Jaeger, OTLP, Zipkin, etc.
func AllProviders ¶
func AllProviders() []string
AllProviders returns all registered provider names.
func ChunkText ¶
func ChunkText(text string, opts ...ChunkOption) []string
ChunkText splits text into chunks of roughly equal size.
func Classify ¶
func Classify(ctx context.Context, text string, labels []string, opts ...ExtractOption) (string, error)
Classify asks the model to choose one of the given labels for the text.
func CosineSimilarity ¶
CosineSimilarity computes the cosine similarity between two vectors. Returns a value in [-1, 1]; higher = more similar.
func CostGuard ¶
func CostGuard(maxCostUSD float64) httpMiddleware
CostGuard returns middleware that blocks requests when estimated cost exceeds the budget. Uses a simple token-cost model.
func DocumentText ¶ added in v1.10.0
func DocumentText(a Attachment) (string, error)
DocumentText extracts the text of a PDF or plain-text attachment.
func EmitRequestEvent ¶
func EmitRequestEvent(e RequestEvent)
EmitRequestEvent fires all registered hooks for a request event. Called internally by the client after each API call.
func EnableCostTracking ¶
func EnableCostTracking(cfg CostConfig)
EnableCostTracking activates cost tracking with the given config.
func EnableTracing ¶
func EnableTracing(cfg TracingConfig)
EnableTracing activates OpenTelemetry-compatible tracing for all AI operations. Installs observability hooks that generate spans.
func EstimateTokens ¶ added in v1.10.0
EstimateTokens roughly counts the tokens of a conversation.
func ExecuteTool ¶
func ExecuteTool(ctx context.Context, name string, args json.RawMessage) (json.RawMessage, error)
ExecuteTool finds and runs a tool by name with raw JSON arguments.
func Extract ¶
Extract asks the AI model to extract structured data from text and return it as a typed Go value. Uses JSON schema to constrain the model's output and retries on parse failure.
func ExtractSlice ¶
ExtractSlice extracts multiple items of the given type from text.
func GenerateConcatFileContent ¶
GenerateConcatFileContent returns the FFmpeg concat file content.
func GenerateFFmpegResizeCommand ¶
func GenerateFFmpegResizeCommand(inputPath string, format OutputFormat, outputPath string) []string
GenerateFFmpegResizeCommand generates an FFmpeg command to re-scale a video to a different output format.
func GenerateStitchCommand ¶
func GenerateStitchCommand(scenes []Scene, cfg StitchConfig) []string
GenerateStitchCommand builds an FFmpeg concat command for the scenes.
func IngestDocuments ¶
func IngestDocuments(ctx context.Context, store *Store, documents map[string]string, opts ...ChunkOption) error
IngestDocuments chunks and embeds a collection of texts into a vector store.
func OnCompletion ¶
func OnCompletion(h RequestHook)
OnCompletion registers a hook called on successful completion.
func OnError ¶
func OnError(h RequestHook)
OnError registers a hook called when an AI request fails.
func OnRequest ¶
func OnRequest(h RequestHook)
OnRequest registers a hook called for every AI API request.
func ParseSkill ¶ added in v1.10.0
ParseSkill splits a SKILL.md into its frontmatter name and description and its body. A file without frontmatter is an error, since the description is what the model chooses skills by.
func RegisterProvider ¶
func RegisterProvider(name string, factory ProviderFactory)
RegisterProvider makes a provider available by name. Call from init() in each provider file (e.g. openai.go, ollama.go).
func RegisterTool ¶
func RegisterTool(t Tool)
RegisterTool adds a tool to the global registry. It validates the handler signature and pre-computes the input JSON schema.
func Reload ¶ added in v1.8.1
func Reload() error
Reload rebuilds the global client from the current configuration: the plugin config and the AI_* environment, read again. An app that lets an operator change models at runtime sets the environment and calls Reload; requests already in flight finish on the client they started with. On an error the previous client stays in place. Before the plugin is registered it is a no-op, since Register will read the same settings.
func ResetCosts ¶
func ResetCosts()
ResetCosts resets all cost tracking counters (e.g., monthly reset).
func Retryable ¶ added in v1.10.0
Retryable reports whether err is worth another attempt, and how long the server asked to wait (0 when it did not say).
func SetModelPricing ¶
func SetModelPricing(model string, pricing ModelPricing)
SetModelPricing sets or updates pricing for a model.
func Stream ¶
func Stream(ctx context.Context, prompt string, opts ...GenerateOption) (<-chan string, <-chan error)
Stream is a convenience that uses the global client.
func Summarize ¶
Summarize generates a summary of the given text. For long texts, it uses a map-reduce approach: chunk → summarize each → combine.
func UsageReport ¶
func UsageReport() string
UsageReport returns a formatted string of current AI usage metrics.
func WithTraceContext ¶
func WithTraceContext(ctx context.Context, tc TraceContext) context.Context
WithTraceContext adds trace context to a Go context for propagation.
Types ¶
type APIError ¶ added in v1.10.0
type APIError struct {
Provider string
StatusCode int
Body string
// RetryAfter is the wait the server asked for (Retry-After header), or 0.
RetryAfter time.Duration
}
APIError is a non-success HTTP response from a provider.
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is an AI entity with instructions, tools, and optional conversational memory.
func (*Agent) AsTool ¶ added in v1.10.0
AsTool wraps the agent as a tool another agent can call: the caller passes a task, this agent works on it (with its own tools and a fresh conversation each time) and its answer is the tool's result.
func (*Agent) Named ¶ added in v1.10.0
Named gives the agent a name (used for handoffs and in responses) and a description of what it handles (shown to agents that can hand off to it).
func (*Agent) OnApproval ¶ added in v1.10.0
func (a *Agent) OnApproval(fn ApprovalFunc) *Agent
OnApproval decides on calls to tools that need approval as they happen. Without it, such calls pause the agent (see ApprovalRequiredError).
func (*Agent) Pending ¶ added in v1.10.0
Pending returns the tool calls waiting for approval in the agent's saved conversation.
func (*Agent) Prompt ¶
func (a *Agent) Prompt(ctx context.Context, userMessage string, opts ...GenerateOption) (*GenerateResponse, error)
Prompt sends a user message and runs the full reasoning loop (tool-call → execute → feed-back) until the model produces a text answer or maxSteps is exhausted.
func (*Agent) Resume ¶ added in v1.10.0
Resume continues a conversation paused for approval: approved calls run, denied ones are reported to the model, and calls without a decision are denied. The agent then carries on as Prompt would.
func (*Agent) Stream ¶
func (a *Agent) Stream(ctx context.Context, userMessage string, opts ...GenerateOption) (*StreamResponse, error)
Stream runs the agent loop and streams the model's text as it arrives.
When the provider reports tool calls while streaming (OpenAI and OpenAI-compatible providers), or the agent has no tools, every step is streamed. Otherwise tool steps run as ordinary requests and the final answer is delivered from that same response, so the model is never asked twice. Either way the final answer is saved to memory once the stream ends. Errors, including a failure before the first token, arrive on Err.
func (*Agent) WithClient ¶
WithClient overrides the default global client.
func (*Agent) WithContextLimit ¶ added in v1.10.0
func (a *Agent) WithContextLimit(maxTokens int, opts ...ContextOption) *Agent
WithContextLimit keeps the agent's prompt (system prompt, tools and history) under maxTokens, dropping or summarising the oldest turns.
func (*Agent) WithHandoffs ¶ added in v1.10.0
WithHandoffs lets the agent transfer the conversation to these agents, which must be Named. Each becomes a transfer_to_<name> tool.
func (*Agent) WithMemory ¶
WithMemory enables persistent memory backed by the given Memory implementation. The key scopes the conversation (e.g. session ID).
func (*Agent) WithMessages ¶
WithMessages sets initial conversation history directly.
func (*Agent) WithParallelTools ¶ added in v1.10.0
WithParallelTools runs the tool calls of one step concurrently (results keep the model's order). Use it when tools are independent and safe to run at once, e.g. several lookups.
func (*Agent) WithPromptCache ¶ added in v1.10.0
WithPromptCache caches the agent's system prompt, tools and conversation between steps and turns (see WithPromptCache). Agents resend all three on every step, so this is where caching pays most.
func (*Agent) WithReasoning ¶ added in v1.10.0
WithReasoning makes the agent think before each step ("low", "medium", "high"; see WithReasoning). Its thinking is kept with each turn, as providers require when tools are involved.
func (*Agent) WithSkills ¶ added in v1.10.0
WithSkills gives the agent skills: the system prompt lists them and the model loads one with the load_skill tool when a request matches (see skill.go). Several sets merge; a skill name may appear only once.
func (*Agent) WithToolObjects ¶
WithToolObjects attaches tool instances directly.
type ApprovalFunc ¶ added in v1.10.0
type ApprovalFunc func(ctx context.Context, req ApprovalRequest) (Decision, error)
ApprovalFunc decides on a call as it happens.
type ApprovalRequest ¶ added in v1.10.0
ApprovalRequest is one tool call waiting for a decision.
type ApprovalRequiredError ¶ added in v1.10.0
type ApprovalRequiredError struct {
Pending []ToolCall
}
ApprovalRequiredError is returned when tool calls need a person's decision. The conversation is saved; continue it with Agent.Resume.
func (*ApprovalRequiredError) Error ¶ added in v1.10.0
func (e *ApprovalRequiredError) Error() string
type Attachment ¶ added in v1.10.0
type Attachment struct {
MediaType string // e.g. image/png, application/pdf
Data []byte
Name string // file name, when known
}
Attachment is a loaded image or document.
func LoadAttachment ¶ added in v1.10.0
func LoadAttachment(ctx context.Context, ref string) (Attachment, error)
LoadAttachment reads a local path, data: URI or http(s) URL.
func (Attachment) Base64 ¶ added in v1.10.0
func (a Attachment) Base64() string
Base64 returns the data base64-encoded.
func (Attachment) DataURI ¶ added in v1.10.0
func (a Attachment) DataURI() string
DataURI renders the attachment as a data: URI.
func (Attachment) IsImage ¶ added in v1.10.0
func (a Attachment) IsImage() bool
IsImage reports whether the attachment is an image.
func (Attachment) IsPDF ¶ added in v1.10.0
func (a Attachment) IsPDF() bool
IsPDF reports whether the attachment is a PDF.
type CameraMove ¶
type CameraMove string
CameraMove is a prompt modifier for camera motion.
const ( CameraDolly CameraMove = "slow cinematic dolly in" CameraOrbit CameraMove = "smooth orbit around subject" CameraPan CameraMove = "slow horizontal pan" CameraDrone CameraMove = "aerial drone flyover" CameraHandheld CameraMove = "handheld camera movement with subtle shake" CameraMacro CameraMove = "extreme macro close-up with rack focus" CameraZoomIn CameraMove = "slow cinematic zoom in" CameraZoomOut CameraMove = "slow cinematic zoom out" CameraStatic CameraMove = "locked off static shot" CameraCrane CameraMove = "crane up reveal" CameraTracking CameraMove = "tracking shot following subject" )
type ChunkOption ¶
type ChunkOption func(*chunkConfig)
ChunkOption configures text chunking.
func ChunkOverlap ¶
func ChunkOverlap(n int) ChunkOption
ChunkOverlap sets the overlap between consecutive chunks.
func ChunkSeparator ¶
func ChunkSeparator(sep string) ChunkOption
ChunkSeparator sets the preferred split point (e.g. "\n\n" for paragraphs).
func ChunkSize ¶
func ChunkSize(n int) ChunkOption
ChunkSize sets the target chunk size in characters.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main AI client that delegates to the configured provider.
func GetClient ¶
func GetClient() *Client
GetClient returns the global AI client. Panics if the plugin is not registered.
func WithGuardrailsClient ¶
func WithGuardrailsClient(c *Client, g *Guardrails) *Client
WithGuardrails returns a new client that validates all responses.
func (*Client) Generate ¶
func (c *Client) Generate(ctx context.Context, prompt string, opts ...GenerateOption) (*GenerateResponse, error)
Generate produces a completion for the given prompt.
func (*Client) GenerateRequest ¶
func (c *Client) GenerateRequest(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
GenerateRequest produces a completion for the given request.
func (*Client) Rerank ¶ added in v1.10.0
func (c *Client) Rerank(ctx context.Context, query string, documents []string, topN int) ([]RerankResult, error)
Rerank orders documents by relevance to query and returns the best topN (all of them when topN <= 0), most relevant first.
func (*Client) Stream ¶
func (c *Client) Stream(ctx context.Context, prompt string, opts ...GenerateOption) (<-chan string, <-chan error)
Stream produces a streaming completion.
func (*Client) StreamRequest ¶
func (c *Client) StreamRequest(ctx context.Context, req *GenerateRequest) (*StreamResponse, error)
StreamRequest produces a v2 StreamResponse.
func (*Client) Transcribe ¶ added in v1.10.0
func (c *Client) Transcribe(ctx context.Context, audio string, opts ...TranscribeOption) (*Transcription, error)
Transcribe turns audio into text. audio is a path, URL or data: URI.
func (*Client) TranscribeAudio ¶ added in v1.10.0
func (c *Client) TranscribeAudio(ctx context.Context, audio Attachment, opts ...TranscribeOption) (*Transcription, error)
TranscribeAudio is Transcribe for audio already in memory.
type ComparisonReport ¶
type ComparisonReport struct {
Suite string `json:"suite"`
Reports []EvalReport `json:"reports"`
}
ComparisonReport compares evaluation results across models.
func CompareModels ¶
func CompareModels(ctx context.Context, suite *EvalSuite, models ...string) *ComparisonReport
CompareModels runs the same eval suite across multiple models and returns a comparison report.
func (*ComparisonReport) Summary ¶
func (cr *ComparisonReport) Summary() string
Summary returns a comparison summary.
type Config ¶
type Config struct {
Provider string
Model string
// ImageProvider and ImageModel configure image generation separately from
// text. Images come from a different endpoint, and the best image model is
// rarely from the same family as the text model — so "gemini for pictures,
// something else for reasoning" is a supported combination.
//
// Resolution order for the model: ai.Image().Model(…) → ImageModel →
// the provider's default.
ImageProvider string
ImageModel string
// ImageAPIKey and ImageBaseURL put image generation on its own account
// and endpoint; VideoProvider, VideoModel, VideoAPIKey and VideoBaseURL
// do the same for video. Unset, each falls back to the text setting
// (see media.go).
ImageAPIKey string
ImageBaseURL string
VideoProvider string
VideoModel string
VideoAPIKey string
VideoBaseURL string
// FallbackModel is the model an app retries on when the main one has
// nothing to give (out of credit, overloaded). With FallbackProvider,
// FallbackAPIKey or FallbackBaseURL set it lives on its own account:
// a request naming FallbackModel is sent there (see media.go).
FallbackProvider string
FallbackModel string
FallbackAPIKey string
FallbackBaseURL string
Timeout int
MaxTokens int
// MaxRetries is how many times a rate-limited or failed request is
// retried (0 = DefaultMaxRetries, negative = never). See retry.go.
MaxRetries int
// PromptCache turns on prompt caching for every request (see
// WithPromptCache). AI_PROMPT_CACHE=true.
PromptCache bool
// Text generation providers
OpenAIKey string
OpenAIBaseURL string
AnthropicKey string
AnthropicBaseURL string
AnthropicAPIURL string
CohereKey string
GeminiKey string
MistralKey string
XAIKey string
// Ollama uses OLLAMA_HOST (default localhost:11434), no key
OllamaHost string
// Embeddings / specialized (for future use)
JinaKey string
VoyageAIKey string
ElevenLabsKey string
// contains filtered or unexported fields
}
Config holds AI plugin configuration. API keys are read from environment variables (see README).
type ContentFilter ¶
type ContentFilter int
ContentFilter is a bitmask for built-in content categories.
const ( FilterNone ContentFilter = 0 FilterHate ContentFilter = 1 << iota FilterViolence FilterSexual FilterSelfHarm FilterPII )
type ContextOption ¶ added in v1.10.0
type ContextOption func(*contextPolicy)
ContextOption configures WithContextLimit.
func KeepRecent ¶ added in v1.10.0
func KeepRecent(n int) ContextOption
KeepRecent keeps at least the last n messages untouched (default 6).
func SummarizeOlder ¶ added in v1.10.0
func SummarizeOlder() ContextOption
SummarizeOlder makes WithContextLimit fold the turns it removes into a short summary (written by the agent's own model) instead of dropping them.
type ConversationRecord ¶
type ConversationRecord struct {
ID uint `gorm:"primarykey"`
Key string `gorm:"index;size:255;not null"`
Messages string `gorm:"type:text;not null"` // JSON-encoded []Message
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
}
ConversationRecord is the GORM model for storing conversation history.
func (ConversationRecord) TableName ¶
func (ConversationRecord) TableName() string
TableName returns the database table name.
type CostConfig ¶
type CostConfig struct {
// MonthlyBudget is the monthly budget in USD. 0 = unlimited.
MonthlyBudget float64
// AlertThresholds are budget percentages that trigger alerts.
// Default: [50, 75, 90, 100].
AlertThresholds []float64
// OnBudgetAlert is called when a threshold is crossed.
OnBudgetAlert func(CostSummary)
// CustomPricing overrides or extends default pricing.
CustomPricing map[string]ModelPricing
}
CostConfig configures cost tracking.
type CostEntry ¶
type CostEntry struct {
Timestamp time.Time `json:"timestamp"`
Provider string `json:"provider"`
Model string `json:"model"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
PromptCost float64 `json:"prompt_cost"`
CompletionCost float64 `json:"completion_cost"`
TotalCost float64 `json:"total_cost"`
}
CostEntry records a single API call's cost.
type CostSummary ¶
type CostSummary struct {
// Totals
TotalCost float64 `json:"total_cost"`
TotalRequests int64 `json:"total_requests"`
TotalTokens int64 `json:"total_tokens"`
MonthlyBudget float64 `json:"monthly_budget"`
BudgetPercent float64 `json:"budget_percent"`
BudgetRemaining float64 `json:"budget_remaining"`
// Per-model breakdown
CostByModel map[string]*ModelCostSummary `json:"cost_by_model"`
// Per-provider breakdown
CostByProvider map[string]*ProviderCostSummary `json:"cost_by_provider"`
// Time-series (hourly buckets for the current day)
HourlyCosts [24]float64 `json:"hourly_costs"`
// Recent entries for detailed view
RecentEntries []CostEntry `json:"recent_entries"`
}
CostSummary is the aggregate cost data for the dashboard.
func GetCostDashboard ¶
func GetCostDashboard() CostSummary
GetCostDashboard returns the current cost summary for dashboard display.
type DatabaseMemoryOption ¶
type DatabaseMemoryOption func(*databaseMemory)
DatabaseMemoryOption configures the database memory backend.
func WithAutoMigrate ¶
func WithAutoMigrate(enabled bool) DatabaseMemoryOption
WithAutoMigrate enables automatic table creation (default: true).
type Decision ¶ added in v1.10.0
type Decision struct {
CallID string
Approved bool
// Reason is told to the model when a call is denied.
Reason string
}
Decision approves or denies one tool call.
type DocQA ¶
type DocQA struct {
// contains filtered or unexported fields
}
DocQA answers questions about a document without a vector store. Best for single-document Q&A where the document fits in context.
func DocumentQA ¶
DocumentQA creates a Q&A interface over a document.
func (*DocQA) SystemPrompt ¶
SystemPrompt overrides the default system prompt.
type Document ¶
type Document struct {
ID string `json:"id"`
Text string `json:"text"`
Vector []float32 `json:"vector,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Score float32 `json:"score,omitempty"` // populated on search results
}
Document represents a stored vector with its metadata and text.
type EmbeddingProvider ¶
type EmbeddingProvider interface {
Embed(ctx context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error)
}
EmbeddingProvider generates vector embeddings.
type EmbeddingRequest ¶
type EmbeddingRequest struct {
Input []string `json:"input"`
Model string `json:"model,omitempty"`
}
EmbeddingRequest asks a provider for vector embeddings.
type EmbeddingResponse ¶
type EmbeddingResponse struct {
Embeddings [][]float32 `json:"embeddings"`
Model string `json:"model"`
Usage *Usage `json:"usage,omitempty"`
}
EmbeddingResponse wraps one or more embedding vectors.
func EmbedBatch ¶
func EmbedBatch(ctx context.Context, texts []string, opts ...GenerateOption) (*EmbeddingResponse, error)
EmbedBatch generates vector embeddings for multiple text inputs.
type EvalCase ¶
type EvalCase struct {
Name string `json:"name"`
Prompt string `json:"prompt"`
System string `json:"system,omitempty"`
Options []GenerateOption `json:"-"`
Checks []EvalCheck `json:"-"`
Metadata map[string]string `json:"metadata,omitempty"`
}
EvalCase is a single test case for model evaluation.
type EvalCheck ¶
EvalCheck is a function that scores an AI response. Returns a score between 0.0 and 1.0, and an explanation.
func CustomCheck ¶
CustomCheck creates an EvalCheck from a custom scoring function.
func ExpectContains ¶
ExpectContains checks that the response contains the expected substring.
func ExpectMaxLength ¶
ExpectMaxLength checks the response is at most n characters.
func ExpectMinLength ¶
ExpectMinLength checks the response is at least n characters.
func ExpectNotContains ¶
ExpectNotContains checks the response does NOT contain.
func ExpectSimilarity ¶
ExpectSimilarity uses the AI model itself to judge response quality. The expected string is compared semantically (costs an extra API call).
type EvalReport ¶
type EvalReport struct {
Suite string `json:"suite"`
Model string `json:"model"`
Provider string `json:"provider"`
Results []EvalResult `json:"results"`
TotalCases int `json:"total_cases"`
Passed int `json:"passed"`
Failed int `json:"failed"`
Errors int `json:"errors"`
AvgScore float64 `json:"avg_score"`
AvgLatency time.Duration `json:"avg_latency"`
TotalCost float64 `json:"total_cost"`
Duration time.Duration `json:"duration"`
Timestamp time.Time `json:"timestamp"`
}
EvalReport is the full report from running a benchmark suite.
func (*EvalReport) Summary ¶
func (r *EvalReport) Summary() string
Summary returns a human-readable summary of the evaluation report.
type EvalResult ¶
type EvalResult struct {
Case string `json:"case"`
Prompt string `json:"prompt"`
Response string `json:"response"`
Model string `json:"model"`
Provider string `json:"provider"`
Scores []EvalScore `json:"scores"`
AvgScore float64 `json:"avg_score"`
Passed bool `json:"passed"`
Latency time.Duration `json:"latency"`
Tokens int `json:"tokens"`
Cost float64 `json:"cost"`
Error string `json:"error,omitempty"`
}
EvalResult is the result of evaluating one case.
type EvalScore ¶
type EvalScore struct {
Name string `json:"name"`
Score float64 `json:"score"` // 0.0 to 1.0
Passed bool `json:"passed"` // true if score >= threshold
Details string `json:"details"` // human-readable explanation
}
EvalScore is the result of one evaluation check.
type EvalSuite ¶
type EvalSuite struct {
// contains filtered or unexported fields
}
EvalSuite is a collection of evaluation cases.
func NewEvalSuite ¶
NewEvalSuite creates a new evaluation suite.
func (*EvalSuite) AddCaseWithSystem ¶
AddCaseWithSystem adds a test case with a system prompt.
func (*EvalSuite) Run ¶
func (s *EvalSuite) Run(ctx context.Context) *EvalReport
Run executes all cases and returns the report.
func (*EvalSuite) WithOptions ¶
func (s *EvalSuite) WithOptions(opts ...GenerateOption) *EvalSuite
WithOptions sets default options for all cases.
type ExtractOption ¶
type ExtractOption func(*extractConfig)
ExtractOption configures the extraction process.
func WithExtractModel ¶
func WithExtractModel(model string) ExtractOption
WithExtractModel sets the model for extraction.
func WithExtractSystem ¶
func WithExtractSystem(system string) ExtractOption
WithExtractSystem overrides the system prompt for extraction.
func WithMaxRetries ¶
func WithMaxRetries(n int) ExtractOption
WithMaxRetries sets the number of retry attempts on malformed JSON.
type FakeProvider ¶ added in v1.10.0
type FakeProvider struct {
// StreamTools makes Stream report tool calls, like the OpenAI provider.
// Without it the fake behaves like providers that do not.
StreamTools bool
// Repeat answers with the last response once the script runs out,
// instead of failing with ErrFakeExhausted.
Repeat bool
// contains filtered or unexported fields
}
FakeProvider is a Provider that answers from a script.
func NewFake ¶ added in v1.10.0
func NewFake(responses ...*GenerateResponse) *FakeProvider
NewFake returns a fake that answers with the given responses in order.
func (*FakeProvider) Client ¶ added in v1.10.0
func (f *FakeProvider) Client() *Client
Client returns a Client backed by the fake.
func (*FakeProvider) Embed ¶ added in v1.10.0
func (f *FakeProvider) Embed(_ context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error)
Embed implements EmbeddingProvider with deterministic bag-of-words vectors: texts that share words are close, so vector search behaves sensibly in tests without a model.
func (*FakeProvider) Generate ¶ added in v1.10.0
func (f *FakeProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate implements Provider.
func (*FakeProvider) Install ¶ added in v1.10.0
func (f *FakeProvider) Install() (restore func())
Install makes the fake the global client (what NewAgent and the package helpers use) and returns a function that restores the previous one.
func (*FakeProvider) Name ¶ added in v1.10.0
func (f *FakeProvider) Name() string
Name implements Provider.
func (*FakeProvider) Remaining ¶ added in v1.10.0
func (f *FakeProvider) Remaining() int
Remaining returns how many scripted responses are left.
func (*FakeProvider) Requests ¶ added in v1.10.0
func (f *FakeProvider) Requests() []GenerateRequest
Requests returns every request the fake received, in order.
func (*FakeProvider) Stream ¶ added in v1.10.0
func (f *FakeProvider) Stream(ctx context.Context, req *GenerateRequest) (*StreamResponse, error)
Stream implements Provider: the scripted text arrives word by word.
func (*FakeProvider) StreamsToolCalls ¶ added in v1.10.0
func (f *FakeProvider) StreamsToolCalls() bool
StreamsToolCalls implements ToolCallStreamer.
type FewShotTemplate ¶
type FewShotTemplate struct {
// contains filtered or unexported fields
}
FewShotTemplate builds a prompt with few-shot examples.
func FewShot ¶
func FewShot(instruction string) *FewShotTemplate
FewShot creates a few-shot prompt builder.
func (*FewShotTemplate) Add ¶
func (f *FewShotTemplate) Add(input, output string) *FewShotTemplate
Add adds a few-shot example.
func (*FewShotTemplate) Format ¶
func (f *FewShotTemplate) Format(input string) string
Format builds the prompt string.
func (*FewShotTemplate) Generate ¶
func (f *FewShotTemplate) Generate(ctx context.Context, input string, opts ...GenerateOption) (*GenerateResponse, error)
Generate formats and generates.
func (*FewShotTemplate) Separator ¶
func (f *FewShotTemplate) Separator(sep string) *FewShotTemplate
Separator sets the separator between examples.
type GenerateOption ¶
type GenerateOption func(*GenerateRequest)
GenerateOption is a functional option applied to GenerateRequest.
func WithFiles ¶ added in v1.10.0
func WithFiles(refs ...string) GenerateOption
WithFiles attaches documents (PDF, text) or images to the current user turn: paths, data: URIs or http(s) URLs. Anthropic and Gemini read PDFs natively (layout, tables, figures); other providers get the extracted text.
func WithImages ¶
func WithImages(images []string) GenerateOption
WithImages attaches image references (data URIs, http(s) URLs, or provider-resolvable paths) to the current user turn. Agent.Prompt moves them onto the user Message so vision-capable providers can send them.
func WithMessages ¶
func WithMessages(msgs []Message) GenerateOption
WithMessages sets the full message list (overrides prompt).
func WithPromptCache ¶ added in v1.10.0
func WithPromptCache() GenerateOption
WithPromptCache caches the stable start of the prompt — system prompt, tools and the conversation so far — so repeated requests pay for it at a fraction of the price. Anthropic needs it asked for; OpenAI and Gemini cache long prompts on their own, and report it in Usage either way.
func WithReasoning ¶ added in v1.10.0
func WithReasoning(effort string) GenerateOption
WithReasoning asks a reasoning model to think first: "low", "medium" or "high" effort. Anthropic and Gemini get a matching thinking budget (2,048 / 8,192 / 24,576 tokens); OpenAI gets reasoning_effort.
func WithSchema ¶
func WithSchema(schema json.RawMessage) GenerateOption
WithSchema sets the JSON schema for structured output.
func WithTemperature ¶
func WithTemperature(t float32) GenerateOption
WithTemperature sets the sampling temperature.
func WithThinkingBudget ¶ added in v1.10.0
func WithThinkingBudget(tokens int) GenerateOption
WithThinkingBudget caps how many tokens the model may spend thinking.
func WithToolChoice ¶ added in v1.10.0
func WithToolChoice(choice string) GenerateOption
WithToolChoice controls tool use: ToolChoiceAuto, ToolChoiceNone, ToolChoiceRequired, or a tool's name to force that tool. In an agent a forcing choice applies to the first step only, so the agent can answer.
func WithTopP ¶
func WithTopP(p float32) GenerateOption
WithTopP sets the nucleus sampling parameter.
type GenerateRequest ¶
type GenerateRequest struct {
Messages []Message `json:"messages"`
Model string `json:"model,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP float32 `json:"top_p,omitempty"`
System string `json:"system,omitempty"`
Tools []ToolSpec `json:"tools,omitempty"`
Schema json.RawMessage `json:"response_format,omitempty"` // JSON schema for structured output
Stop []string `json:"stop,omitempty"`
Stream bool `json:"stream,omitempty"`
// Images carries attachments for the current user turn (data URIs, http(s)
// URLs, or provider-resolvable paths). The Agent moves these onto the
// current user Message; providers serialize them as multimodal content.
Images []string `json:"-"`
// Files carries documents for the current user turn (see WithFiles).
Files []string `json:"-"`
// Cache asks the provider to cache the stable start of the prompt
// (system prompt, tools, conversation so far). See WithPromptCache.
Cache bool `json:"-"`
// Reasoning turns on thinking for reasoning models (see WithReasoning).
Reasoning *Reasoning `json:"-"`
// ToolChoice controls tool use: "" or "auto" (the model decides),
// "none" (no tools), "required" (must call one), or a tool's name.
ToolChoice string `json:"-"`
}
GenerateRequest holds everything needed for a generation call.
type GenerateResponse ¶
type GenerateResponse struct {
Text string `json:"text"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
// Reasoning is the model's visible thinking (Anthropic, Gemini, Ollama,
// DeepSeek-style APIs); OpenAI's reasoning models do not return it.
Reasoning string `json:"reasoning,omitempty"`
ReasoningBlocks []ReasoningBlock `json:"reasoning_blocks,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Model string `json:"model"`
FinishReason string `json:"finish_reason,omitempty"`
// Agent names the agent that produced the response, after handoffs
// (empty for unnamed agents).
Agent string `json:"agent,omitempty"`
}
GenerateResponse is the result of a non-streaming generation.
func FakeText ¶ added in v1.10.0
func FakeText(text string) *GenerateResponse
FakeText is a scripted text answer.
func FakeToolCall ¶ added in v1.10.0
func FakeToolCall(name, argsJSON string) *GenerateResponse
FakeToolCall is a scripted request to call one tool with JSON arguments.
func FakeToolCalls ¶ added in v1.10.0
func FakeToolCalls(calls ...ToolCall) *GenerateResponse
FakeToolCalls is a scripted request to call several tools.
func Generate ¶
func Generate(ctx context.Context, prompt string, opts ...GenerateOption) (*GenerateResponse, error)
Generate is a convenience that uses the global client.
type GuardrailCheck ¶
GuardrailCheck is a custom validation function. Return an error if the output violates the guardrail.
type Guardrails ¶
type Guardrails struct {
// contains filtered or unexported fields
}
Guardrails validates AI outputs against safety and quality rules.
func NewGuardrails ¶
func NewGuardrails() *Guardrails
NewGuardrails creates an empty guardrails configuration.
func (*Guardrails) BlockPatterns ¶
func (g *Guardrails) BlockPatterns(patterns ...string) *Guardrails
BlockPatterns adds regex patterns that must NOT appear in the output.
func (*Guardrails) CustomCheck ¶
func (g *Guardrails) CustomCheck(fn GuardrailCheck) *Guardrails
CustomCheck adds a custom guardrail check.
func (*Guardrails) MaxLength ¶
func (g *Guardrails) MaxLength(n int) *Guardrails
MaxLength sets the maximum allowed output length.
func (*Guardrails) MinLength ¶
func (g *Guardrails) MinLength(n int) *Guardrails
MinLength sets the minimum required output length.
func (*Guardrails) RequireKeywords ¶
func (g *Guardrails) RequireKeywords(keywords ...string) *Guardrails
RequireKeywords ensures the output contains all specified keywords.
func (*Guardrails) SetContentFilter ¶
func (g *Guardrails) SetContentFilter(f ContentFilter) *Guardrails
ContentFilter sets the content safety filter bitmask.
func (*Guardrails) Validate ¶
func (g *Guardrails) Validate(output string) error
Validate checks the output against all configured guardrails. Returns nil if the output passes all checks.
func (*Guardrails) ValidateResponse ¶
func (g *Guardrails) ValidateResponse(resp *GenerateResponse) error
ValidateResponse is a convenience that validates a GenerateResponse.
type ImageBuilder ¶
type ImageBuilder struct {
// contains filtered or unexported fields
}
ImageBuilder provides a fluent API for configuring and generating images.
func (*ImageBuilder) Count ¶
func (b *ImageBuilder) Count(n int) *ImageBuilder
Count sets the number of images to generate.
func (*ImageBuilder) Generate ¶
func (b *ImageBuilder) Generate(ctx context.Context) (*ImageResponse, error)
Generate produces the image(s).
func (*ImageBuilder) Model ¶
func (b *ImageBuilder) Model(model string) *ImageBuilder
Model sets the image generation model.
func (*ImageBuilder) Prompt ¶
func (b *ImageBuilder) Prompt(prompt string) *ImageBuilder
Prompt sets the image description prompt.
func (*ImageBuilder) Size ¶
func (b *ImageBuilder) Size(size string) *ImageBuilder
Size sets the output image size (e.g. "1024x1024", "512x512").
func (*ImageBuilder) Style ¶
func (b *ImageBuilder) Style(style string) *ImageBuilder
Style sets the image style (e.g. "natural", "vivid").
func (*ImageBuilder) WithClient ¶
func (b *ImageBuilder) WithClient(c *Client) *ImageBuilder
WithClient overrides the default client.
type ImageData ¶
type ImageData struct {
URL string `json:"url,omitempty"`
B64JSON string `json:"b64_json,omitempty"`
}
ImageData holds a single generated image.
type ImageProvider ¶
type ImageProvider interface {
GenerateImage(ctx context.Context, req *ImageRequest) (*ImageResponse, error)
}
ImageProvider generates images.
type ImageRequest ¶
type ImageRequest struct {
Prompt string `json:"prompt"`
Model string `json:"model,omitempty"`
N int `json:"n,omitempty"`
Size string `json:"size,omitempty"` // e.g. "1024x1024"
Style string `json:"style,omitempty"`
}
ImageRequest configures an image generation call.
type ImageResponse ¶
ImageResponse wraps the generated image data.
type LegacyStreamProvider ¶
type LegacyStreamProvider interface {
Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
LegacyStream(ctx context.Context, req *GenerateRequest) (<-chan string, <-chan error)
}
LegacyStreamProvider is the original Stream signature.
type LogExporter ¶
type LogExporter struct{}
LogExporter prints spans to the logger (useful for development).
func (*LogExporter) ExportSpan ¶
func (e *LogExporter) ExportSpan(_ context.Context, span Span) error
ExportSpan logs the span details.
type MCPClient ¶ added in v1.10.0
type MCPClient struct {
// contains filtered or unexported fields
}
MCPClient is a connection to one MCP server.
func ConnectMCP ¶ added in v1.10.0
ConnectMCP connects to an MCP server, completes the protocol handshake and lists its tools.
func (*MCPClient) Close ¶ added in v1.10.0
Close ends the connection (and stops a stdio server's process).
func (*MCPClient) ServerName ¶ added in v1.10.0
ServerName is the name the server reported in the handshake.
type MCPOption ¶ added in v1.10.0
type MCPOption func(*mcpConfig)
MCPOption configures ConnectMCP.
func MCPAllowTools ¶ added in v1.10.0
MCPAllowTools keeps only the named tools (names as the server gives them, before any prefix). Give an agent only what it needs.
func MCPApproveDestructive ¶ added in v1.10.0
func MCPApproveDestructive() MCPOption
MCPApproveDestructive makes calls wait for approval for every tool that is not marked read-only and is (per the MCP spec's defaults, possibly) destructive. Servers that annotate their tools carefully make this precise; on others it covers every tool not marked read-only.
func MCPClientName ¶ added in v1.10.0
MCPClientName is the client name sent to the server (default "nimbus").
func MCPPrefix ¶ added in v1.10.0
MCPPrefix prefixes the server's tool names ("github" → "github_search"), so tools of several servers cannot collide.
func MCPRequireApproval ¶ added in v1.10.0
MCPRequireApproval makes calls to the named tools (server names) wait for approval (see Agent.OnApproval and Agent.Resume).
type MCPTransport ¶ added in v1.10.0
type MCPTransport struct {
// contains filtered or unexported fields
}
MCPTransport says how to reach an MCP server (see MCPStdio, MCPHTTP, MCPSSE and MCPInProcess).
func MCPHTTP ¶ added in v1.10.0
func MCPHTTP(url string, headers map[string]string) MCPTransport
MCPHTTP connects to a remote MCP server over streamable HTTP. headers are sent with every request (authentication, usually).
func MCPInProcess ¶ added in v1.10.0
func MCPInProcess(s *mcpserver.MCPServer) MCPTransport
MCPInProcess talks to an mcp-go server in the same process (for tests, or to give an agent the tools of the app's own MCP server).
func MCPSSE ¶ added in v1.10.0
func MCPSSE(url string, headers map[string]string) MCPTransport
MCPSSE connects to a remote MCP server over the older SSE transport.
func MCPStdio ¶ added in v1.10.0
func MCPStdio(command string, args ...string) MCPTransport
MCPStdio runs an MCP server as a child process and talks to it over its stdin and stdout.
func MCPStdioEnv ¶ added in v1.10.0
func MCPStdioEnv(command string, env []string, args ...string) MCPTransport
MCPStdioEnv is MCPStdio with extra environment variables ("KEY=value") for the child process, e.g. API keys the server needs.
type Memory ¶
type Memory interface {
// Load retrieves the conversation history for the given key.
Load(ctx context.Context, key string) ([]Message, error)
// Save persists the conversation history for the given key.
Save(ctx context.Context, key string, messages []Message) error
// Clear removes the conversation history for the given key.
Clear(ctx context.Context, key string) error
}
Memory persists and retrieves conversation history for agents.
func DatabaseMemory ¶
func DatabaseMemory(db *lucid.DB, opts ...DatabaseMemoryOption) Memory
DatabaseMemory creates a database-backed memory store using GORM. Conversation history is persisted in an `ai_conversations` table.
mem := ai.DatabaseMemory(db) agent.WithMemory(mem, "session:user123")
func MemoryStore ¶
func MemoryStore(opts ...MemoryStoreOption) Memory
MemoryStore returns a simple in-memory Memory (lost on restart). Useful for development and testing.
func RedisMemory ¶
func RedisMemory(client *redis.Client, opts ...RedisMemoryOption) Memory
RedisMemory creates a Redis-backed memory store. Conversation history is stored as JSON in Redis keys with configurable TTL and prefix.
rdb := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
mem := ai.RedisMemory(rdb, ai.WithRedisTTL(24*time.Hour))
agent.WithMemory(mem, "session:user123")
func SlidingWindowMemory ¶
SlidingWindowMemory wraps another Memory and keeps only the last N messages (plus the system prompt), preventing unbounded growth.
func SummaryMemory ¶
SummaryMemory wraps another Memory and auto-summarises old messages when the history exceeds the threshold. Uses the AI client itself to produce summaries.
type MemoryStoreOption ¶
type MemoryStoreOption func(*memoryStore)
MemoryStoreOption configures the in-memory store.
func WithMemoryTTL ¶
func WithMemoryTTL(ttl time.Duration) MemoryStoreOption
WithTTL sets the time-to-live for stored conversations. Note: TTL cleanup is lazy (checked on Load).
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Images []string `json:"images,omitempty"`
// Files are documents (PDF, text) or images attached to a user turn:
// paths, data: URIs or URLs. See WithFiles.
Files []string `json:"files,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
// Reasoning is the model's thinking on an assistant turn, kept so it
// can be sent back: Anthropic requires the signed thinking blocks of a
// turn that called tools to accompany the tool results.
Reasoning []ReasoningBlock `json:"reasoning,omitempty"`
}
Message represents a single turn in a conversation. Content is the text payload; ToolCalls and ToolCallID enable the function-calling loop.
type Metrics ¶
type Metrics struct {
TotalRequests int64 `json:"total_requests"`
TotalTokens int64 `json:"total_tokens"`
TotalErrors int64 `json:"total_errors"`
TotalLatency time.Duration `json:"total_latency_ms"`
RequestsByModel sync.Map `json:"-"`
}
Metrics holds aggregate AI usage statistics.
type ModelCostSummary ¶
type ModelCostSummary struct {
Model string `json:"model"`
Requests int64 `json:"requests"`
PromptTokens int64 `json:"prompt_tokens"`
CompletionTokens int64 `json:"completion_tokens"`
TotalCost float64 `json:"total_cost"`
AvgCostPerReq float64 `json:"avg_cost_per_request"`
}
ModelCostSummary tracks costs for a specific model.
type ModelPricing ¶
type ModelPricing struct {
PromptPer1K float64 `json:"prompt_per_1k"`
CompletionPer1K float64 `json:"completion_per_1k"`
// CacheReadPer1K and CacheWritePer1K price prompt-cache hits and
// writes. Zero means half the prompt price for reads (OpenAI's
// discount) and the prompt price for writes.
CacheReadPer1K float64 `json:"cache_read_per_1k,omitempty"`
CacheWritePer1K float64 `json:"cache_write_per_1k,omitempty"`
}
ModelPricing holds per-1K token prices for a model.
type NamedStep ¶
type NamedStep struct {
Name string
Handler StepHandler
}
NamedStep associates a name with a step handler.
func StepFunc ¶
func StepFunc(name string, handler StepHandler) NamedStep
StepFunc creates a NamedStep from a name and handler.
type OTLPExporter ¶
type OTLPExporter struct {
Endpoint string // e.g. "http://localhost:4318/v1/traces"
}
OTLPExporter exports spans to an OpenTelemetry collector via HTTP.
func (*OTLPExporter) ExportSpan ¶
func (e *OTLPExporter) ExportSpan(_ context.Context, span Span) error
ExportSpan sends the span to the OTLP endpoint.
type OutputFormat ¶
type OutputFormat struct {
Name string `json:"name"`
Width int `json:"width"`
Height int `json:"height"`
Aspect string `json:"aspect"` // e.g. "9:16"
}
OutputFormat defines the aspect ratio and sizing for the final render.
type PgvectorOption ¶
type PgvectorOption func(*pgvectorStore)
PgvectorOption configures the pgvector backend.
func WithPgvectorDimension ¶
func WithPgvectorDimension(d int) PgvectorOption
WithPgvectorDimension sets the vector dimension (default: 1536 for OpenAI).
func WithPgvectorTable ¶
func WithPgvectorTable(name string) PgvectorOption
WithPgvectorTable sets the table name (default: "ai_vectors").
type PgvectorRecord ¶
type PgvectorRecord struct {
ID string `gorm:"primarykey;size:255"`
Text string `gorm:"type:text"`
Vector string `gorm:"type:text"` // stored as text representation of float array
Metadata string `gorm:"type:text"` // JSON metadata
}
PgvectorRecord is the GORM model for the vector store table.
type PineconeOption ¶
type PineconeOption func(*pineconeStore)
PineconeOption configures the Pinecone backend.
func WithPineconeNamespace ¶
func WithPineconeNamespace(ns string) PineconeOption
WithPineconeNamespace sets the Pinecone namespace for multi-tenancy.
type Plugin ¶
type Plugin struct {
nimbus.BasePlugin
// contains filtered or unexported fields
}
Plugin integrates the AI SDK with Nimbus.
func (*Plugin) DefaultConfig ¶
DefaultConfig returns the default configuration for the AI plugin.
type PromptChain ¶
type PromptChain struct {
// contains filtered or unexported fields
}
PromptChain composes multiple templates into a single generation call.
func Chain ¶
func Chain(templates ...*PromptTemplate) *PromptChain
Chain creates a prompt chain from one or more templates.
func (*PromptChain) Generate ¶
func (c *PromptChain) Generate(ctx context.Context, vars map[string]any, opts ...GenerateOption) (*GenerateResponse, error)
Generate renders all templates and builds a multi-message request.
type PromptTemplate ¶
type PromptTemplate struct {
// contains filtered or unexported fields
}
PromptTemplate is a reusable prompt with variable interpolation.
func SystemTemplate ¶
func SystemTemplate(s string) *PromptTemplate
SystemTemplate creates a system-role prompt template.
func Template ¶
func Template(s string) *PromptTemplate
Template creates a new prompt template from the given string. Uses Go text/template syntax ({{.varName}}).
func (*PromptTemplate) Format ¶
func (p *PromptTemplate) Format(vars map[string]any) (string, error)
Format renders the template with the given variables.
func (*PromptTemplate) Generate ¶
func (p *PromptTemplate) Generate(ctx context.Context, vars map[string]any, opts ...GenerateOption) (*GenerateResponse, error)
Generate renders the template and sends it to the AI.
func (*PromptTemplate) MustFormat ¶
func (p *PromptTemplate) MustFormat(vars map[string]any) string
MustFormat renders or panics. Useful in init() or tests.
func (*PromptTemplate) Role ¶
func (p *PromptTemplate) Role(role string) *PromptTemplate
Role sets the message role for this template.
type Provider ¶
type Provider interface {
// Name returns the provider identifier (e.g. "openai", "anthropic").
Name() string
// Generate produces a single completion.
Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
// Stream produces a streaming completion. If the provider does not
// support native streaming, the default implementation calls
// Generate and wraps the result in a single-chunk stream.
Stream(ctx context.Context, req *GenerateRequest) (*StreamResponse, error)
}
Provider is the minimum contract every AI backend must satisfy.
type ProviderCostSummary ¶
type ProviderCostSummary struct {
Provider string `json:"provider"`
Requests int64 `json:"requests"`
TotalCost float64 `json:"total_cost"`
}
ProviderCostSummary tracks costs for a specific provider.
type ProviderFactory ¶
ProviderFactory creates a Provider from a Config.
func GetProviderFactory ¶
func GetProviderFactory(name string) (ProviderFactory, bool)
GetProviderFactory returns the factory for the named provider.
type QdrantOption ¶
type QdrantOption func(*qdrantStore)
QdrantOption configures the Qdrant backend.
func WithQdrantAPIKey ¶
func WithQdrantAPIKey(key string) QdrantOption
WithQdrantAPIKey sets the Qdrant API key for cloud deployments.
func WithQdrantDimension ¶
func WithQdrantDimension(d int) QdrantOption
WithQdrantDimension sets the vector dimension (default: 1536).
type RAG ¶
type RAG struct {
// contains filtered or unexported fields
}
RAG is a retrieval-augmented generation engine.
func (*RAG) Ask ¶
func (r *RAG) Ask(ctx context.Context, question string, opts ...GenerateOption) (*RAGResponse, error)
Ask runs the full RAG pipeline: embed → search → augment → generate.
func (*RAG) AskStream ¶
func (r *RAG) AskStream(ctx context.Context, question string, opts ...GenerateOption) (*StreamResponse, []Document, error)
AskStream runs the RAG pipeline but streams the final answer.
func (*RAG) OnPostprocess ¶
OnPostprocess sets a function to transform the answer after generation.
func (*RAG) OnPreprocess ¶
OnPreprocess sets a function to transform the query before embedding.
func (*RAG) SystemPrompt ¶
SystemPrompt overrides the default system prompt.
func (*RAG) WithCitations ¶
WithCitations enables source citation in the response.
func (*RAG) WithClient ¶
WithClient overrides the default global AI client.
func (*RAG) WithReranker ¶ added in v1.10.0
WithReranker reorders the retrieved documents by relevance with a reranking model (see Rerank) and keeps the best keep. Retrieve more than you keep (TopK(20).WithReranker(c, 5)) so the reranker has a choice.
type RAGResponse ¶
type RAGResponse struct {
Answer string `json:"answer"`
Sources []Document `json:"sources"`
Usage *Usage `json:"usage,omitempty"`
}
RAGResponse wraps the generated answer with source documents.
type RawToolFunc ¶ added in v1.10.0
type RawToolFunc func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
RawToolFunc handles a tool call given the model's raw JSON arguments.
type Reasoning ¶ added in v1.10.0
Reasoning asks a reasoning model to think before it answers. Set Effort ("low", "medium", "high") or BudgetTokens (the most tokens to spend thinking); each provider gets whichever it understands.
type ReasoningBlock ¶ added in v1.10.0
type ReasoningBlock struct {
Text string `json:"text,omitempty"`
// Signature verifies the block to the provider (Anthropic).
Signature string `json:"signature,omitempty"`
// Redacted holds encrypted thinking the provider did not show.
Redacted string `json:"redacted,omitempty"`
}
ReasoningBlock is one piece of a model's thinking.
type RedisMemoryOption ¶
type RedisMemoryOption func(*redisMemory)
RedisMemoryOption configures the Redis memory backend.
func WithRedisPrefix ¶
func WithRedisPrefix(prefix string) RedisMemoryOption
WithRedisPrefix sets the key prefix (default "ai:memory:").
func WithRedisTTL ¶
func WithRedisTTL(ttl time.Duration) RedisMemoryOption
WithRedisTTL sets per-key expiration in Redis.
type RequestEvent ¶
type RequestEvent struct {
Provider string `json:"provider"`
Model string `json:"model"`
Prompt string `json:"prompt,omitempty"`
Messages []Message `json:"messages,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Latency time.Duration `json:"latency_ms"`
Error error `json:"error,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
RequestEvent is emitted for every AI API call. Middleware and observability hooks receive this.
type RequestHook ¶
type RequestHook func(RequestEvent)
RequestHook is a callback for AI request events.
type RerankProvider ¶ added in v1.10.0
type RerankProvider interface {
Rerank(ctx context.Context, req *RerankRequest) ([]RerankResult, error)
}
RerankProvider orders documents by relevance to a query.
type RerankRequest ¶ added in v1.10.0
RerankRequest asks a provider to order documents by relevance.
type RerankResult ¶ added in v1.10.0
type RerankResult struct {
Index int // position in the documents passed in
Document string
Score float64 // higher is more relevant (0–1 for Cohere)
}
RerankResult is one document with its relevance to the query.
type Scene ¶
type Scene struct {
Index int `json:"index"`
Prompt string `json:"prompt"`
Camera CameraMove `json:"camera"`
Duration int `json:"duration"` // seconds
KeyframeURL string `json:"keyframe_url,omitempty"`
VideoURL string `json:"video_url,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Scene represents one segment of the planned video.
type ScenePlan ¶
type ScenePlan struct {
OriginalPrompt string `json:"original_prompt"`
ExpandedPrompt string `json:"expanded_prompt"`
GlobalStyle string `json:"global_style"`
Scenes []Scene `json:"scenes"`
}
ScenePlan is the output of the scene planner.
type Skill ¶ added in v1.10.0
Skill is one named set of instructions.
func (Skill) Files ¶ added in v1.10.0
Files lists the resource files shipped in the skill's folder, besides SKILL.md, as paths relative to it. Inline skills have none.
func (Skill) Instructions ¶ added in v1.10.0
Instructions returns the skill's full text (the SKILL.md body).
type SkillSet ¶ added in v1.10.0
type SkillSet struct {
// contains filtered or unexported fields
}
SkillSet is a collection of skills with unique names.
func LoadSkills ¶ added in v1.10.0
LoadSkills reads every skill under dir in fsys: each <dir>/<name>/SKILL.md is a skill whose folder may hold resource files, and each <dir>/<name>.md is a single-file skill. Use it with embed.FS to compile skills into the binary, or with os.DirFS (see LoadSkillsDir).
func LoadSkillsDir ¶ added in v1.10.0
LoadSkillsDir reads skills from a directory on disk.
func MustLoadSkills ¶ added in v1.10.0
MustLoadSkills is LoadSkills that panics, for package-level setup.
func NewSkillSet ¶ added in v1.10.0
NewSkillSet groups skills, rejecting invalid ones and duplicate names.
type SocialPackage ¶
type SocialPackage struct {
Caption string `json:"caption"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
Formats map[string]string `json:"formats"` // format name → video URL
}
SocialPackage holds auto-generated social media assets.
type Span ¶
type Span struct {
TraceID string `json:"trace_id"`
SpanID string `json:"span_id"`
ParentID string `json:"parent_id,omitempty"`
Name string `json:"name"`
Kind string `json:"kind"` // "client", "internal"
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Duration time.Duration `json:"duration"`
Status string `json:"status"` // "ok", "error"
Attributes map[string]string `json:"attributes"`
Events []SpanEvent `json:"events,omitempty"`
Error string `json:"error,omitempty"`
}
Span represents a trace span for AI operations.
func GetTraceSpans ¶
GetTraceSpans returns recent trace spans for inspection.
type SpanEvent ¶
type SpanEvent struct {
Name string `json:"name"`
Timestamp time.Time `json:"timestamp"`
Attributes map[string]string `json:"attributes,omitempty"`
}
SpanEvent is a timestamped annotation on a span.
type SpanExporter ¶
SpanExporter receives completed spans for export.
type SpeakOption ¶ added in v1.10.0
type SpeakOption func(*SpeechRequest)
SpeakOption configures Speak.
func WithAudioFormat ¶ added in v1.10.0
func WithAudioFormat(format string) SpeakOption
WithAudioFormat picks the output format (mp3, wav, opus, aac, flac, pcm).
func WithSpeechInstructions ¶ added in v1.10.0
func WithSpeechInstructions(text string) SpeakOption
WithSpeechInstructions describes tone and delivery ("calm, warm").
func WithSpeechModel ¶ added in v1.10.0
func WithSpeechModel(model string) SpeakOption
WithSpeechModel picks the model (default gpt-4o-mini-tts on OpenAI).
func WithSpeed ¶ added in v1.10.0
func WithSpeed(speed float64) SpeakOption
WithSpeed sets the speaking rate (0.25–4, default 1).
func WithVoice ¶ added in v1.10.0
func WithVoice(voice string) SpeakOption
WithVoice picks the voice (OpenAI: alloy, coral, nova, …; Gemini: Kore, Puck, …).
type SpeechProvider ¶ added in v1.10.0
type SpeechProvider interface {
Speak(ctx context.Context, req *SpeechRequest) (*Speech, error)
}
SpeechProvider turns text into audio.
type SpeechRequest ¶ added in v1.10.0
type SpeechRequest struct {
Text string
Model string
Voice string
Format string // mp3 (default), wav, opus, aac, flac, pcm
Speed float64
Instructions string // tone and delivery, for models that take it
}
SpeechRequest configures Speak.
type StepHandler ¶
type StepHandler func(wc *WorkflowContext) error
StepHandler is a function that executes a workflow step. It receives the accumulated context and should call wc.Set() to contribute results.
type StepResult ¶
type StepResult struct {
Name string `json:"name"`
Duration time.Duration `json:"duration"`
Error error `json:"error,omitempty"`
}
StepResult records the outcome of a single step.
type StitchConfig ¶
type StitchConfig struct {
FadeSeconds float64 `json:"fade_seconds"`
MusicPath string `json:"music_path,omitempty"`
CaptionText string `json:"caption_text,omitempty"`
OutputPath string `json:"output_path"`
ConcatFile string `json:"concat_file"` // path to write the file list
}
StitchCommand generates the FFmpeg command to concatenate scene videos with optional transitions. The caller is responsible for executing it.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps a backend and handles automatic embedding of text.
func VectorStoreInstance ¶
func VectorStoreInstance(name string, backend ...VectorStoreBackend) *Store
VectorStoreInstance creates a new Store for the given namespace. Uses the registered backend or defaults to in-memory.
func (*Store) AddDocument ¶
AddDocument stores a pre-embedded document.
type StreamChunk ¶
type StreamChunk struct {
Text string `json:"text,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
// Reasoning carries completed thinking blocks (with signatures) so they
// can be sent back with tool results.
Reasoning []ReasoningBlock `json:"reasoning,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Done bool `json:"done,omitempty"`
}
StreamChunk is one piece of a streaming response.
type StreamResponse ¶
type StreamResponse struct {
// Chunks delivers text/tool-call chunks until closed.
Chunks <-chan StreamChunk
// Err is buffered (cap=1). A nil send signals clean completion.
Err <-chan error
}
StreamResponse wraps a streaming channel plus a done channel.
func GenerateToStream ¶
func GenerateToStream(ctx context.Context, p Provider, req *GenerateRequest) (*StreamResponse, error)
GenerateToStream wraps a Generate call as a single-chunk StreamResponse. Use inside Stream() implementations for providers that lack native streaming.
func (*StreamResponse) Collect ¶
func (s *StreamResponse) Collect(ctx context.Context) (*GenerateResponse, error)
Collect drains the stream and returns the concatenated text and final usage. Blocks until the stream is finished.
type SummarizeOption ¶
type SummarizeOption func(*summarizeConfig)
SummarizeOption configures summarization.
func SummarizeMaxLength ¶
func SummarizeMaxLength(n int) SummarizeOption
SummarizeMaxLength limits the summary length.
func SummarizeStyle ¶
func SummarizeStyle(s string) SummarizeOption
SummarizeStyle sets the summary style.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
// Run is the handler function. It must have the signature:
// func(ctx context.Context, input T) (U, error)
// where T is the input struct (used to generate JSON schema)
// and U is the output (marshaled to JSON for the model).
Run any `json:"-"`
// Exec is an alternative to Run for tools whose arguments are only known
// as JSON at run time (MCP tools, agents used as tools). It receives the
// model's raw arguments and returns raw JSON. Set Parameters with it.
Exec RawToolFunc `json:"-"`
// Parameters is the tool's JSON Schema. Leave it empty with Run (it is
// generated from the input struct); set it with Exec.
Parameters json.RawMessage `json:"-"`
// NeedsApproval marks a tool whose calls must be approved before they
// run (see Agent.OnApproval).
NeedsApproval bool `json:"-"`
// contains filtered or unexported fields
}
Tool represents a callable function that an AI agent can invoke.
func NewRawTool ¶ added in v1.10.0
func NewRawTool(name, description string, schema json.RawMessage, fn RawToolFunc) (*Tool, error)
NewRawTool builds a tool from a JSON Schema and a raw handler, for tools whose shape is only known at run time.
func (*Tool) Execute ¶
func (t *Tool) Execute(ctx context.Context, argsJSON json.RawMessage) (json.RawMessage, error)
Execute invokes the tool handler with JSON arguments.
func (*Tool) Schema ¶
func (t *Tool) Schema() json.RawMessage
Schema returns the JSON-Schema representation of the tool's input parameters, suitable for sending to model APIs.
type ToolBuilder ¶
type ToolBuilder struct {
// contains filtered or unexported fields
}
ToolBuilder provides a fluent API for constructing tools.
func NewTool ¶
func NewTool(name string) *ToolBuilder
NewTool starts building a tool with the given name.
func (*ToolBuilder) Build ¶
func (b *ToolBuilder) Build() (*Tool, error)
Build validates and returns the tool.
func (*ToolBuilder) Desc ¶
func (b *ToolBuilder) Desc(desc string) *ToolBuilder
Desc sets the tool description.
func (*ToolBuilder) Handler ¶
func (b *ToolBuilder) Handler(fn any) *ToolBuilder
Handler sets the typed handler function.
func (*ToolBuilder) Register ¶
func (b *ToolBuilder) Register() error
Register validates and registers the tool globally.
func (*ToolBuilder) RequireApproval ¶ added in v1.10.0
func (b *ToolBuilder) RequireApproval() *ToolBuilder
RequireApproval marks the tool's calls as needing approval before they run (see Agent.OnApproval).
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Args json.RawMessage `json:"arguments"`
// Signature is a provider token that must accompany the call when it is
// sent back (Gemini's thought signature with thinking on).
Signature string `json:"signature,omitempty"`
}
ToolCall represents a function call requested by the model.
type ToolCallStreamer ¶ added in v1.10.0
type ToolCallStreamer interface {
StreamsToolCalls() bool
}
ToolCallStreamer is implemented by providers whose Stream reports the model's tool calls (in StreamChunk.ToolCalls). Agents stream every step on such providers; on others they stream only tool-free turns.
type ToolSpec ¶
type ToolSpec struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters json.RawMessage `json:"parameters"` // JSON Schema
}
ToolSpec describes a tool the model may call. Mirrors the OpenAI function-calling schema so providers can translate as needed.
type TraceContext ¶
TraceContext holds trace propagation info.
func GetTraceContext ¶
func GetTraceContext(ctx context.Context) (TraceContext, bool)
GetTraceContext retrieves trace context from a Go context.
type TracingConfig ¶
type TracingConfig struct {
// ServiceName is the service name for the tracer (default: "nimbus-ai").
ServiceName string
// Enabled turns tracing on/off (default: true when EnableTracing called).
Enabled bool
// RecordPrompts controls whether prompt text is recorded in span
// attributes. Disable in production for privacy (default: false).
RecordPrompts bool
// RecordResponses controls whether response text is recorded.
// Disable for privacy (default: false).
RecordResponses bool
}
TracingConfig configures OpenTelemetry tracing for the AI SDK.
type TranscribeOption ¶ added in v1.10.0
type TranscribeOption func(*TranscriptionRequest)
TranscribeOption configures Transcribe.
func WithLanguage ¶ added in v1.10.0
func WithLanguage(lang string) TranscribeOption
WithLanguage hints the spoken language (ISO-639-1).
func WithTranscriptionModel ¶ added in v1.10.0
func WithTranscriptionModel(model string) TranscribeOption
WithTranscriptionModel picks the model (default whisper-1 on OpenAI).
func WithTranscriptionPrompt ¶ added in v1.10.0
func WithTranscriptionPrompt(prompt string) TranscribeOption
WithTranscriptionPrompt passes vocabulary or context that steers spelling.
type TranscriptSegment ¶ added in v1.10.0
TranscriptSegment is a timed piece of a transcription.
type Transcription ¶ added in v1.10.0
type Transcription struct {
Text string
Language string
Duration float64 // seconds, when the provider reports it
Segments []TranscriptSegment
}
Transcription is speech turned into text.
func Transcribe ¶ added in v1.10.0
func Transcribe(ctx context.Context, audio string, opts ...TranscribeOption) (*Transcription, error)
Transcribe uses the global client.
type TranscriptionProvider ¶ added in v1.10.0
type TranscriptionProvider interface {
Transcribe(ctx context.Context, req *TranscriptionRequest) (*Transcription, error)
}
TranscriptionProvider turns audio into text.
type TranscriptionRequest ¶ added in v1.10.0
type TranscriptionRequest struct {
Audio Attachment
Model string
Language string // ISO-639-1 hint, e.g. "en"
Prompt string // vocabulary or context to steer spelling
}
TranscriptionRequest configures Transcribe.
type Usage ¶
type Usage struct {
// PromptTokens counts every input token, cached or not.
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
// CacheReadTokens are input tokens served from the provider's prompt
// cache (billed at a discount); CacheWriteTokens were written to it
// (Anthropic bills these at a premium). Both are part of PromptTokens.
CacheReadTokens int `json:"cache_read_tokens,omitempty"`
CacheWriteTokens int `json:"cache_write_tokens,omitempty"`
// ReasoningTokens are output tokens spent thinking (part of
// CompletionTokens), when the provider reports them.
ReasoningTokens int `json:"reasoning_tokens,omitempty"`
}
Usage holds token usage information.
type VectorStoreBackend ¶
type VectorStoreBackend interface {
// Add stores a document with its embedding vector.
Add(ctx context.Context, doc Document) error
// AddBatch stores multiple documents.
AddBatch(ctx context.Context, docs []Document) error
// Search finds the top-k most similar documents to the query vector.
Search(ctx context.Context, vector []float32, topK int) ([]Document, error)
// Delete removes a document by ID.
Delete(ctx context.Context, id string) error
// Count returns the total number of documents.
Count(ctx context.Context) (int, error)
}
VectorStoreBackend is the interface for vector storage backends.
func NewMemoryVectorStore ¶
func NewMemoryVectorStore() VectorStoreBackend
NewMemoryVectorStore creates an in-memory vector store for development and testing. Not suitable for production.
func NewPgvectorStore ¶
func NewPgvectorStore(db *lucid.DB, opts ...PgvectorOption) VectorStoreBackend
NewPgvectorStore creates a pgvector-backed VectorStoreBackend. Requires the `pgvector` extension on PostgreSQL.
db, _ := lucid.Open(postgres.Open(dsn), &lucid.Config{})
backend := ai.NewPgvectorStore(db)
store := ai.VectorStoreInstance("docs", backend)
func NewPineconeStore ¶
func NewPineconeStore(host, apiKey string, opts ...PineconeOption) VectorStoreBackend
NewPineconeStore creates a Pinecone-backed VectorStoreBackend.
backend := ai.NewPineconeStore(
"https://my-index-xxx.svc.xxx.pinecone.io",
"your-api-key",
)
store := ai.VectorStoreInstance("knowledge", backend)
func NewQdrantStore ¶
func NewQdrantStore(baseURL, collection string, opts ...QdrantOption) VectorStoreBackend
NewQdrantStore creates a Qdrant-backed VectorStoreBackend.
backend := ai.NewQdrantStore("http://localhost:6333", "documents")
store := ai.VectorStoreInstance("knowledge", backend)
type VideoBuilder ¶
type VideoBuilder struct {
// contains filtered or unexported fields
}
VideoBuilder provides a fluent API for video generation.
func (*VideoBuilder) Duration ¶
func (b *VideoBuilder) Duration(seconds int) *VideoBuilder
Duration sets the video duration in seconds.
func (*VideoBuilder) FPS ¶
func (b *VideoBuilder) FPS(fps int) *VideoBuilder
FPS sets the frames per second.
func (*VideoBuilder) FromImage ¶
func (b *VideoBuilder) FromImage(url string) *VideoBuilder
FromImage sets a source image for image-to-video generation.
func (*VideoBuilder) Generate ¶
func (b *VideoBuilder) Generate(ctx context.Context) (*VideoResponse, error)
Generate produces the video.
func (*VideoBuilder) Model ¶
func (b *VideoBuilder) Model(model string) *VideoBuilder
Model sets the video generation model.
func (*VideoBuilder) Prompt ¶
func (b *VideoBuilder) Prompt(prompt string) *VideoBuilder
Prompt sets the video description.
func (*VideoBuilder) Size ¶
func (b *VideoBuilder) Size(size string) *VideoBuilder
Size sets the output resolution.
func (*VideoBuilder) WithClient ¶
func (b *VideoBuilder) WithClient(c *Client) *VideoBuilder
WithClient overrides the default client.
type VideoPipeline ¶
type VideoPipeline struct {
// contains filtered or unexported fields
}
VideoPipeline orchestrates the full video production flow.
func NewVideoPipeline ¶
func NewVideoPipeline() *VideoPipeline
NewVideoPipeline creates a new pipeline with sensible defaults.
func (*VideoPipeline) ConcurrentScenes ¶
func (p *VideoPipeline) ConcurrentScenes(n int) *VideoPipeline
ConcurrentScenes sets parallelism for scene rendering.
func (*VideoPipeline) DefaultDuration ¶
func (p *VideoPipeline) DefaultDuration(seconds int) *VideoPipeline
DefaultDuration sets the per-scene duration in seconds.
func (*VideoPipeline) DraftMode ¶
func (p *VideoPipeline) DraftMode(draft bool) *VideoPipeline
DraftMode enables shorter preview clips for cost optimization.
func (*VideoPipeline) ExpanderModel ¶
func (p *VideoPipeline) ExpanderModel(model string) *VideoPipeline
ExpanderModel sets the LLM used for prompt expansion.
func (*VideoPipeline) Generate ¶
func (p *VideoPipeline) Generate(ctx context.Context, prompt string) (*VideoProject, error)
Generate runs the entire video production pipeline: expand → plan → keyframes → videos → stitch.
func (*VideoPipeline) GenerateWithSocial ¶
func (p *VideoPipeline) GenerateWithSocial(ctx context.Context, prompt string) (*VideoProject, error)
GenerateWithSocial runs the pipeline and also generates social media packaging.
func (*VideoPipeline) GlobalStyle ¶
func (p *VideoPipeline) GlobalStyle(style string) *VideoPipeline
GlobalStyle sets the style prompt appended to every scene.
func (*VideoPipeline) ImageModel ¶
func (p *VideoPipeline) ImageModel(model string) *VideoPipeline
ImageModel sets the model for keyframe image generation.
func (*VideoPipeline) MaxScenes ¶
func (p *VideoPipeline) MaxScenes(n int) *VideoPipeline
MaxScenes limits the number of scenes generated.
func (*VideoPipeline) OnScene ¶
func (p *VideoPipeline) OnScene(fn func(scene Scene, stage string)) *VideoPipeline
OnScene registers a progress callback fired at each pipeline stage.
func (*VideoPipeline) OutputFmt ¶
func (p *VideoPipeline) OutputFmt(format OutputFormat) *VideoPipeline
OutputFmt sets the output video format/aspect ratio.
func (*VideoPipeline) PlannerModel ¶
func (p *VideoPipeline) PlannerModel(model string) *VideoPipeline
PlannerModel sets the LLM used for scene planning.
func (*VideoPipeline) SeedVariants ¶
func (p *VideoPipeline) SeedVariants(n int) *VideoPipeline
SeedVariants sets how many keyframe variants to generate per scene.
func (*VideoPipeline) VideoModel ¶
func (p *VideoPipeline) VideoModel(model string) *VideoPipeline
VideoModel sets the model for video synthesis.
func (*VideoPipeline) WithClient ¶
func (p *VideoPipeline) WithClient(c *Client) *VideoPipeline
WithClient overrides the default AI client.
type VideoPipelineConfig ¶
type VideoPipelineConfig struct {
ImageModel string `json:"image_model"`
VideoModel string `json:"video_model"`
PlannerModel string `json:"planner_model"` // LLM for scene planning
ExpanderModel string `json:"expander_model"` // LLM for prompt expansion
GlobalStyle string `json:"global_style"`
MaxScenes int `json:"max_scenes"`
DefaultDuration int `json:"default_duration"` // per-scene seconds
DraftMode bool `json:"draft_mode"` // shorter preview clips
Format OutputFormat `json:"format"`
Parallelism int `json:"parallelism"` // concurrent scene renders
Seeds int `json:"seeds"` // keyframe seed variants
OnScene func(scene Scene, stage string) // progress callback
}
VideoPipelineConfig holds all settings for the video pipeline.
type VideoProject ¶
type VideoProject struct {
ID string `json:"id"`
Prompt string `json:"prompt"`
Plan *ScenePlan `json:"plan"`
Scenes []Scene `json:"scenes"`
FinalVideoURL string `json:"final_video_url,omitempty"`
Format OutputFormat `json:"format"`
Duration time.Duration `json:"duration"`
Social *SocialPackage `json:"social,omitempty"`
RenderDuration time.Duration `json:"render_duration"`
}
VideoProject is the output of a full pipeline run.
type VideoProvider ¶
type VideoProvider interface {
GenerateVideo(ctx context.Context, req *VideoRequest) (*VideoResponse, error)
}
VideoProvider is the capability interface for video generation.
type VideoRequest ¶
type VideoRequest struct {
Prompt string `json:"prompt"`
Model string `json:"model,omitempty"`
ImageURL string `json:"image_url,omitempty"` // for image-to-video
Duration int `json:"duration,omitempty"` // seconds
FPS int `json:"fps,omitempty"`
Size string `json:"size,omitempty"` // e.g. "1920x1080"
}
VideoRequest configures a video generation call.
type VideoResponse ¶
type VideoResponse struct {
URL string `json:"url"`
Model string `json:"model"`
Duration int `json:"duration"`
}
VideoResponse wraps the generated video.
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow is a named multi-step AI pipeline.
func (*Workflow) Branch ¶
func (w *Workflow) Branch(name string, selector func(wc *WorkflowContext) string, branches map[string]StepHandler) *Workflow
Branch adds a conditional branching step.
func (*Workflow) OnStep ¶
func (w *Workflow) OnStep(h WorkflowHook) *Workflow
OnStep registers a hook for step lifecycle events.
func (*Workflow) Run ¶
func (w *Workflow) Run(ctx context.Context, input WorkflowInput) (*WorkflowResult, error)
Run executes the workflow with the given input and returns the result.
type WorkflowContext ¶
WorkflowContext carries accumulated state through the pipeline.
func (*WorkflowContext) All ¶
func (wc *WorkflowContext) All() map[string]any
All returns a copy of all data.
func (*WorkflowContext) Get ¶
func (wc *WorkflowContext) Get(key string) any
Get retrieves a value from the workflow context.
func (*WorkflowContext) GetString ¶
func (wc *WorkflowContext) GetString(key string) string
GetString retrieves a string value.
func (*WorkflowContext) Set ¶
func (wc *WorkflowContext) Set(key string, value any)
Set stores a value in the workflow context.
type WorkflowHook ¶
type WorkflowHook func(step string, event string, wc *WorkflowContext)
WorkflowHook is called before/after steps.
type WorkflowInput ¶
WorkflowInput is the initial data map passed to a workflow.
type WorkflowResult ¶
type WorkflowResult struct {
Data map[string]any `json:"data"`
Duration time.Duration `json:"duration"`
Steps []StepResult `json:"steps"`
}
WorkflowResult is the final output of a workflow run.
Source Files
¶
- adapter.go
- agent_v2.go
- anthropic.go
- approval.go
- attachment.go
- client_v2.go
- cohere.go
- config.go
- context_window.go
- cost.go
- document.go
- embed.go
- eval.go
- extract.go
- fake.go
- gemini.go
- gemini_image.go
- guardrails.go
- image.go
- mcp.go
- media.go
- memory.go
- memory_redis.go
- middleware.go
- mistral.go
- multiagent.go
- ollama.go
- openai.go
- plugin.go
- providers.go
- rag.go
- rerank.go
- retry.go
- skill.go
- speech.go
- template.go
- tool.go
- tracing.go
- types.go
- vectorstore.go
- vectorstore_pgvector.go
- vectorstore_pinecone.go
- vectorstore_qdrant.go
- video.go
- video_pipeline.go
- workflow.go
- xai.go