Documentation
¶
Index ¶
- Variables
- func WithIncludeIntermediateMessages(include bool) func(*StreamConfig)
- type AdminConversationMemory
- type AgentEventType
- type AgentResponse
- type AgentStreamEvent
- type AgentTaskServiceInterface
- type CollectionRef
- type ConversationMemory
- type DataStore
- type DeleteOption
- type DeleteOptions
- type Document
- type Embedder
- type ExecutionSummary
- type GenerateOption
- func WithFrequencyPenalty(frequencyPenalty float64) GenerateOption
- func WithMaxIterations(maxIterations int) GenerateOption
- func WithMemory(memory Memory) GenerateOption
- func WithPresencePenalty(presencePenalty float64) GenerateOption
- func WithReasoning(enabled bool, budget ...int) GenerateOption
- func WithResponseFormat(format ResponseFormat) GenerateOption
- func WithStopSequences(stopSequences []string) GenerateOption
- func WithStreamConfig(config StreamConfig) GenerateOption
- func WithSystemMessage(systemMessage string) GenerateOption
- func WithTemperature(temperature float64) GenerateOption
- func WithTopP(topP float64) GenerateOption
- type GenerateOptions
- type GetMessagesOption
- type GetMessagesOptions
- type Guardrails
- type InternalTool
- type JSONSchema
- type LLM
- type LLMConfig
- type LLMResponse
- type MCPContent
- type MCPMessage
- type MCPModelHint
- type MCPModelPreferences
- type MCPPrompt
- type MCPPromptArgument
- type MCPPromptCapabilities
- type MCPPromptMessage
- type MCPPromptResult
- type MCPResource
- type MCPResourceCapabilities
- type MCPResourceContent
- type MCPResourceType
- type MCPResourceUpdate
- type MCPResourceUpdateType
- type MCPSamplingRequest
- type MCPSamplingResponse
- type MCPServer
- type MCPServerCapabilities
- type MCPServerInfo
- type MCPTokenUsage
- type MCPTool
- type MCPToolCapabilities
- type MCPToolResponse
- type Memory
- type Message
- type MessageRole
- type ParameterSpec
- type QueryOption
- type QueryOptions
- type ResponseFormat
- type ResponseFormatType
- type RetryPolicy
- type SearchOption
- func WithBM25(useBM25 bool) SearchOption
- func WithEmbedding(useEmbedding bool) SearchOption
- func WithFields(fields ...string) SearchOption
- func WithFilters(filters map[string]interface{}) SearchOption
- func WithKeyword(useKeyword bool) SearchOption
- func WithMinScore(score float32) SearchOption
- func WithNearText(useNearText bool) SearchOption
- func WithTenantSearch(tenant string) SearchOption
- type SearchOptions
- type SearchResult
- type Span
- type StoreOption
- type StoreOptions
- type StreamConfig
- type StreamEvent
- type StreamEventType
- type StreamForwarder
- type StreamingAgent
- type StreamingLLM
- type TaskExecutor
- type TaskOptions
- type TaskPlanner
- type TaskResult
- type TaskService
- type TokenUsage
- type Tool
- type ToolCall
- type ToolCallEvent
- type ToolRegistry
- type ToolWithDisplayName
- type Tracer
- type Transaction
- type VectorStore
- type VectorStoreConfig
Constants ¶
This section is empty.
Variables ¶
var StreamForwarderKey = streamForwarderContextKey{}
StreamForwarderKey is the exported context key for stream forwarders
Functions ¶
func WithIncludeIntermediateMessages ¶ added in v0.0.46
func WithIncludeIntermediateMessages(include bool) func(*StreamConfig)
WithIncludeIntermediateMessages returns a StreamConfig option to include intermediate messages
Types ¶
type AdminConversationMemory ¶ added in v0.1.7
type AdminConversationMemory interface {
ConversationMemory
// GetAllConversationsAcrossOrgs returns all conversation IDs from all organizations
GetAllConversationsAcrossOrgs() (map[string][]string, error) // map[orgID][]conversationID
// GetConversationMessagesAcrossOrgs finds conversation in any org and returns messages
GetConversationMessagesAcrossOrgs(conversationID string) ([]Message, string, error) // messages, orgID, error
// GetMemoryStatisticsAcrossOrgs returns memory statistics across all organizations
GetMemoryStatisticsAcrossOrgs() (totalConversations, totalMessages int, err error)
}
AdminConversationMemory extends ConversationMemory with cross-org operations
type AgentEventType ¶ added in v0.0.34
type AgentEventType string
AgentEventType represents the type of agent streaming event
const ( AgentEventContent AgentEventType = "content" AgentEventThinking AgentEventType = "thinking" AgentEventToolCall AgentEventType = "tool_call" AgentEventToolResult AgentEventType = "tool_result" AgentEventError AgentEventType = "error" AgentEventComplete AgentEventType = "complete" )
type AgentResponse ¶ added in v0.1.13
type AgentResponse struct {
Content string
Usage *TokenUsage
AgentName string
Model string
ExecutionSummary ExecutionSummary
Metadata map[string]interface{}
}
type AgentStreamEvent ¶ added in v0.0.34
type AgentStreamEvent struct {
Type AgentEventType `json:"type"`
Content string `json:"content,omitempty"`
ToolCall *ToolCallEvent `json:"tool_call,omitempty"`
ThinkingStep string `json:"thinking_step,omitempty"`
Error error `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
AgentStreamEvent represents a streaming event from an agent
type AgentTaskServiceInterface ¶ added in v0.0.3
type AgentTaskServiceInterface[AgentTask any, AgentCreateRequest any, AgentApproveRequest any, AgentTaskUpdate any] interface { // CreateTask creates a new task CreateTask(ctx context.Context, req AgentCreateRequest) (AgentTask, error) // GetTask gets a task by ID GetTask(ctx context.Context, taskID string) (AgentTask, error) // ListTasks returns all tasks for a user ListTasks(ctx context.Context, userID string) ([]AgentTask, error) // ApproveTaskPlan approves or rejects a task plan ApproveTaskPlan(ctx context.Context, taskID string, req AgentApproveRequest) (AgentTask, error) // UpdateTask updates an existing task with new steps or modifications UpdateTask(ctx context.Context, taskID string, conversationID string, updates []AgentTaskUpdate) (AgentTask, error) // AddTaskLog adds a log entry to a task AddTaskLog(ctx context.Context, taskID string, message string, level string) error }
AgentTaskServiceInterface is a generic interface for agent task services
type CollectionRef ¶
type CollectionRef interface {
// Insert inserts a document into the collection
Insert(ctx context.Context, data map[string]interface{}) (string, error)
// Get retrieves a document by ID
Get(ctx context.Context, id string) (map[string]interface{}, error)
// Update updates a document by ID
Update(ctx context.Context, id string, data map[string]interface{}) error
// Delete deletes a document by ID
Delete(ctx context.Context, id string) error
// Query queries documents in the collection
Query(ctx context.Context, filter map[string]interface{}, options ...QueryOption) ([]map[string]interface{}, error)
}
CollectionRef represents a reference to a collection/table
type ConversationMemory ¶ added in v0.1.7
type ConversationMemory interface {
Memory
// GetAllConversations returns all conversation IDs for current org
GetAllConversations(ctx context.Context) ([]string, error)
// GetConversationMessages gets all messages for a specific conversation in current org
GetConversationMessages(ctx context.Context, conversationID string) ([]Message, error)
// GetMemoryStatistics returns basic memory statistics for current org
GetMemoryStatistics(ctx context.Context) (totalConversations, totalMessages int, err error)
}
ConversationMemory extends Memory interface with conversation-level operations
type DataStore ¶
type DataStore interface {
// Collection returns a reference to a specific collection/table
Collection(name string) CollectionRef
// Transaction executes multiple operations in a transaction
Transaction(ctx context.Context, fn func(tx Transaction) error) error
// Close closes the database connection
Close() error
}
DataStore represents a database for storing structured data
type DeleteOption ¶
type DeleteOption func(*DeleteOptions)
DeleteOption represents an option for deleting documents
func WithTenantDelete ¶ added in v0.0.24
func WithTenantDelete(tenant string) DeleteOption
WithTenantDelete sets the tenant for native multi-tenancy delete operations
type DeleteOptions ¶
type DeleteOptions struct {
// Class is the class/collection name to delete from
Class string
// Tenant is the tenant name for native multi-tenancy
Tenant string
}
DeleteOptions contains options for deleting documents
type Document ¶
type Document struct {
// ID is the unique identifier for the document
ID string
// Content is the text content of the document
Content string
// Vector is the embedding vector for the document
// If nil, the vector store will generate it
Vector []float32
// Metadata contains additional information about the document
Metadata map[string]interface{}
}
Document represents a document to be stored in a vector store
type Embedder ¶ added in v0.0.2
type Embedder interface {
// Embed generates an embedding for the given text
Embed(ctx context.Context, text string) ([]float32, error)
// EmbedBatch generates embeddings for multiple texts
EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
// CalculateSimilarity calculates the similarity between two embeddings
CalculateSimilarity(vec1, vec2 []float32, metric string) (float32, error)
}
Embedder represents a service that can convert text into embeddings
type ExecutionSummary ¶ added in v0.1.13
type GenerateOption ¶
type GenerateOption func(options *GenerateOptions)
GenerateOption represents options for text generation
func WithFrequencyPenalty ¶ added in v0.0.43
func WithFrequencyPenalty(frequencyPenalty float64) GenerateOption
WithFrequencyPenalty creates a GenerateOption to set the frequency penalty
func WithMaxIterations ¶ added in v0.0.19
func WithMaxIterations(maxIterations int) GenerateOption
WithMaxIterations creates a GenerateOption to set the maximum number of tool-calling iterations
func WithMemory ¶ added in v0.0.30
func WithMemory(memory Memory) GenerateOption
WithMemory creates a GenerateOption to set the memory for storing tool calls and results
func WithPresencePenalty ¶ added in v0.0.43
func WithPresencePenalty(presencePenalty float64) GenerateOption
WithPresencePenalty creates a GenerateOption to set the presence penalty
func WithReasoning ¶ added in v0.0.34
func WithReasoning(enabled bool, budget ...int) GenerateOption
WithReasoning creates a GenerateOption to enable native reasoning tokens
func WithResponseFormat ¶ added in v0.0.43
func WithResponseFormat(format ResponseFormat) GenerateOption
WithResponseFormat creates a GenerateOption to set the response format
func WithStopSequences ¶ added in v0.0.43
func WithStopSequences(stopSequences []string) GenerateOption
WithStopSequences creates a GenerateOption to set the stop sequences
func WithStreamConfig ¶ added in v0.0.34
func WithStreamConfig(config StreamConfig) GenerateOption
WithStreamConfig creates a GenerateOption to set the streaming configuration
func WithSystemMessage ¶ added in v0.0.43
func WithSystemMessage(systemMessage string) GenerateOption
WithSystemMessage creates a GenerateOption to set the system message
func WithTemperature ¶ added in v0.0.43
func WithTemperature(temperature float64) GenerateOption
WithTemperature creates a GenerateOption to set the temperature
func WithTopP ¶ added in v0.0.43
func WithTopP(topP float64) GenerateOption
WithTopP creates a GenerateOption to set the top_p
type GenerateOptions ¶
type GenerateOptions struct {
LLMConfig *LLMConfig // LLM config for the generation
OrgID string // For multi-tenancy
SystemMessage string // System message for chat models
ResponseFormat *ResponseFormat // Optional expected response format
MaxIterations int // Maximum number of tool-calling iterations (0 = use default)
Memory Memory // Optional memory for storing tool calls and results
StreamConfig *StreamConfig // Optional streaming configuration
}
GenerateOptions contains configuration for text generation
type GetMessagesOption ¶
type GetMessagesOption func(*GetMessagesOptions)
GetMessagesOption represents an option for retrieving messages
func WithLimit ¶
func WithLimit(limit int) GetMessagesOption
WithLimit sets the maximum number of messages to retrieve
func WithQuery ¶
func WithQuery(query string) GetMessagesOption
WithQuery sets a search query for relevant messages
func WithRoles ¶
func WithRoles(roles ...string) GetMessagesOption
WithRoles filters messages by role
type GetMessagesOptions ¶
type GetMessagesOptions struct {
// Limit is the maximum number of messages to retrieve
Limit int
// Roles filters messages by role
Roles []string
// Query is a search query for relevant messages
Query string
}
GetMessagesOptions contains options for retrieving messages
type Guardrails ¶
type Guardrails interface {
// ProcessInput processes user input before sending to the LLM
ProcessInput(ctx context.Context, input string) (string, error)
// ProcessOutput processes LLM output before returning to the user
ProcessOutput(ctx context.Context, output string) (string, error)
}
Guardrails represents a system for ensuring safe and appropriate responses
type InternalTool ¶ added in v0.0.53
type InternalTool interface {
// Internal returns true if this tool's usage should be hidden from users
// This can be used to filter tool calls in OnToolCall or other display contexts
Internal() bool
}
InternalTool is an optional interface that tools can implement to indicate they should be hidden from users
type JSONSchema ¶ added in v0.0.4
type JSONSchema map[string]interface{}
func (JSONSchema) MarshalJSON ¶ added in v0.0.4
func (s JSONSchema) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
type LLM ¶
type LLM interface {
// Generate generates text based on the provided prompt
Generate(ctx context.Context, prompt string, options ...GenerateOption) (string, error)
// GenerateWithTools generates text and can use tools
GenerateWithTools(ctx context.Context, prompt string, tools []Tool, options ...GenerateOption) (string, error)
// GenerateDetailed generates text and returns detailed response information including token usage
GenerateDetailed(ctx context.Context, prompt string, options ...GenerateOption) (*LLMResponse, error)
// GenerateWithToolsDetailed generates text with tools and returns detailed response information including token usage
GenerateWithToolsDetailed(ctx context.Context, prompt string, tools []Tool, options ...GenerateOption) (*LLMResponse, error)
// Name returns the name of the LLM provider
Name() string
// SupportsStreaming returns true if this LLM supports streaming
SupportsStreaming() bool
}
LLM represents a large language model provider
type LLMConfig ¶ added in v0.0.11
type LLMConfig struct {
Temperature float64 // Temperature for the generation
TopP float64 // Top P for the generation
FrequencyPenalty float64 // Frequency penalty for the generation
PresencePenalty float64 // Presence penalty for the generation
StopSequences []string // Stop sequences for the generation
Reasoning string // Reasoning mode (minimal, low, medium, high) to control reasoning effort
EnableReasoning bool // Enable native reasoning tokens (Anthropic thinking/OpenAI o1)
ReasoningBudget int // Optional token budget for reasoning (Anthropic only), minimum 1024
}
type LLMResponse ¶ added in v0.1.13
type LLMResponse struct {
// Content is the generated text response
Content string
// Usage contains token usage information (nil if not available)
Usage *TokenUsage
// Model indicates which model was used for generation
Model string
// StopReason indicates why the generation stopped (optional)
StopReason string
// Metadata contains provider-specific additional information
Metadata map[string]interface{}
}
LLMResponse represents the detailed response from an LLM generation request
type MCPContent ¶ added in v0.1.14
type MCPContent struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"` // base64 encoded for images/audio
MimeType string `json:"mimeType,omitempty"`
}
MCPContent represents different types of content
type MCPMessage ¶ added in v0.1.14
type MCPMessage struct {
Role string `json:"role"`
Content MCPContent `json:"content"`
Name string `json:"name,omitempty"`
}
MCPMessage represents a message in the conversation
type MCPModelHint ¶ added in v0.1.14
type MCPModelHint struct {
Name string `json:"name"`
}
MCPModelHint represents a model hint
type MCPModelPreferences ¶ added in v0.1.14
type MCPModelPreferences struct {
// Model hints (optional suggestions)
Hints []MCPModelHint `json:"hints,omitempty"`
// Priority values (0.0 to 1.0)
CostPriority float64 `json:"costPriority,omitempty"`
SpeedPriority float64 `json:"speedPriority,omitempty"`
IntelligencePriority float64 `json:"intelligencePriority,omitempty"`
}
MCPModelPreferences represents preferences for model selection
type MCPPrompt ¶ added in v0.1.14
type MCPPrompt struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Arguments []MCPPromptArgument `json:"arguments,omitempty"`
Schema map[string]interface{} `json:"schema,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
MCPPrompt represents a prompt template available on an MCP server
type MCPPromptArgument ¶ added in v0.1.14
type MCPPromptArgument struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Type string `json:"type,omitempty"`
Default interface{} `json:"default,omitempty"`
}
MCPPromptArgument represents an argument for a prompt template
type MCPPromptCapabilities ¶ added in v0.1.14
type MCPPromptCapabilities struct {
ListChanged bool `json:"listChanged,omitempty"`
}
MCPPromptCapabilities represents prompt-related capabilities
type MCPPromptMessage ¶ added in v0.1.14
type MCPPromptMessage struct {
Role string `json:"role"`
Content string `json:"content"`
Name string `json:"name,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
MCPPromptMessage represents a message in a prompt result
type MCPPromptResult ¶ added in v0.1.14
type MCPPromptResult struct {
Prompt string `json:"prompt"`
Messages []MCPPromptMessage `json:"messages,omitempty"`
Variables map[string]interface{} `json:"variables,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
MCPPromptResult represents the result of getting a prompt with variables
type MCPResource ¶ added in v0.1.14
type MCPResource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
MCPResource represents a resource available on an MCP server
type MCPResourceCapabilities ¶ added in v0.1.14
type MCPResourceCapabilities struct {
Subscribe bool `json:"subscribe,omitempty"`
ListChanged bool `json:"listChanged,omitempty"`
}
MCPResourceCapabilities represents resource-related capabilities
type MCPResourceContent ¶ added in v0.1.14
type MCPResourceContent struct {
URI string `json:"uri"`
MimeType string `json:"mimeType"`
Text string `json:"text,omitempty"`
Blob []byte `json:"blob,omitempty"`
Reader io.Reader `json:"-"` // For streaming content
Metadata map[string]string `json:"metadata,omitempty"`
}
MCPResourceContent represents the content of a resource
type MCPResourceType ¶ added in v0.1.14
type MCPResourceType string
MCPResourceType represents the type of MCP resource
const ( MCPResourceTypeText MCPResourceType = "text" MCPResourceTypeBinary MCPResourceType = "binary" MCPResourceTypeJSON MCPResourceType = "json" )
type MCPResourceUpdate ¶ added in v0.1.14
type MCPResourceUpdate struct {
URI string `json:"uri"`
Type MCPResourceUpdateType `json:"type"`
Content *MCPResourceContent `json:"content,omitempty"`
Timestamp time.Time `json:"timestamp"`
Error error `json:"error,omitempty"`
}
MCPResourceUpdate represents an update to a watched resource
type MCPResourceUpdateType ¶ added in v0.1.14
type MCPResourceUpdateType string
MCPResourceUpdateType represents the type of resource update
const ( MCPResourceUpdateTypeChanged MCPResourceUpdateType = "changed" MCPResourceUpdateTypeDeleted MCPResourceUpdateType = "deleted" MCPResourceUpdateTypeError MCPResourceUpdateType = "error" )
type MCPSamplingRequest ¶ added in v0.1.14
type MCPSamplingRequest struct {
Messages []MCPMessage `json:"messages"`
ModelPreferences *MCPModelPreferences `json:"modelPreferences,omitempty"`
SystemPrompt string `json:"systemPrompt,omitempty"`
IncludeContext string `json:"includeContext,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"maxTokens,omitempty"`
StopSequences []string `json:"stopSequences,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
MCPSamplingRequest represents a request for LLM sampling
type MCPSamplingResponse ¶ added in v0.1.14
type MCPSamplingResponse struct {
Role string `json:"role"`
Content MCPContent `json:"content"`
Model string `json:"model"`
StopReason string `json:"stopReason,omitempty"`
Usage *MCPTokenUsage `json:"usage,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
MCPSamplingResponse represents the response from LLM sampling
type MCPServer ¶ added in v0.0.13
type MCPServer interface {
// Initialize initializes the connection to the MCP server
Initialize(ctx context.Context) error
// ListTools lists the tools available on the MCP server
ListTools(ctx context.Context) ([]MCPTool, error)
// CallTool calls a tool on the MCP server
CallTool(ctx context.Context, name string, args interface{}) (*MCPToolResponse, error)
// ListResources lists the resources available on the MCP server
ListResources(ctx context.Context) ([]MCPResource, error)
// GetResource retrieves a specific resource by URI
GetResource(ctx context.Context, uri string) (*MCPResourceContent, error)
// WatchResource watches for changes to a resource (if supported)
WatchResource(ctx context.Context, uri string) (<-chan MCPResourceUpdate, error)
// ListPrompts lists the prompts available on the MCP server
ListPrompts(ctx context.Context) ([]MCPPrompt, error)
// GetPrompt retrieves a specific prompt with variables
GetPrompt(ctx context.Context, name string, variables map[string]interface{}) (*MCPPromptResult, error)
// Sampling Methods (if supported by client)
// CreateMessage requests the client to generate a completion using its LLM
CreateMessage(ctx context.Context, request *MCPSamplingRequest) (*MCPSamplingResponse, error)
// Metadata discovery methods
// GetServerInfo returns the server metadata discovered during initialization
GetServerInfo() (*MCPServerInfo, error)
// GetCapabilities returns the server capabilities discovered during initialization
GetCapabilities() (*MCPServerCapabilities, error)
// Close closes the connection to the MCP server
Close() error
}
MCPServer represents a connection to an MCP server
type MCPServerCapabilities ¶ added in v0.1.14
type MCPServerCapabilities struct {
Tools *MCPToolCapabilities `json:"tools,omitempty"`
Resources *MCPResourceCapabilities `json:"resources,omitempty"`
Prompts *MCPPromptCapabilities `json:"prompts,omitempty"`
}
MCPServerCapabilities represents server capabilities discovered during initialization
type MCPServerInfo ¶ added in v0.1.14
type MCPServerInfo struct {
Name string `json:"name"` // Required: server identifier
Title string `json:"title,omitempty"` // Optional: human-readable title
Version string `json:"version,omitempty"` // Optional: server version
}
MCPServerInfo represents server metadata discovered during initialization
type MCPTokenUsage ¶ added in v0.1.14
type MCPTokenUsage struct {
PromptTokens int `json:"promptTokens,omitempty"`
CompletionTokens int `json:"completionTokens,omitempty"`
TotalTokens int `json:"totalTokens,omitempty"`
}
MCPTokenUsage represents token usage information
type MCPTool ¶ added in v0.0.13
type MCPTool struct {
Name string `json:"name"`
Description string `json:"description"`
Schema interface{} `json:"inputSchema,omitempty"`
OutputSchema interface{} `json:"outputSchema,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
MCPTool represents a tool available on an MCP server
type MCPToolCapabilities ¶ added in v0.1.14
type MCPToolCapabilities struct {
ListChanged bool `json:"listChanged,omitempty"`
}
MCPToolCapabilities represents tool-related capabilities
type MCPToolResponse ¶ added in v0.0.13
type MCPToolResponse struct {
Content interface{} `json:"content,omitempty"`
StructuredContent interface{} `json:"structuredContent,omitempty"`
IsError bool `json:"isError,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
MCPToolResponse represents a response from a tool call
type Memory ¶
type Memory interface {
// AddMessage adds a message to memory
AddMessage(ctx context.Context, message Message) error
// GetMessages retrieves messages from memory
GetMessages(ctx context.Context, options ...GetMessagesOption) ([]Message, error)
// Clear clears the memory
Clear(ctx context.Context) error
}
Memory represents a memory store for agent conversations
type Message ¶
type Message struct {
// Role is the role of the message sender
Role MessageRole
// Content is the content of the message
Content string
// Metadata contains additional information about the message
Metadata map[string]interface{}
// ToolCallID is used for tool messages to reference the tool call
ToolCallID string
// ToolCalls contains tool call information for assistant messages
ToolCalls []ToolCall
}
Message represents a message in a conversation
type MessageRole ¶ added in v0.0.58
type MessageRole string
MessageRole represents the role of a message sender
const ( // MessageRoleUser represents a user message MessageRoleUser MessageRole = "user" // MessageRoleAssistant represents an assistant message MessageRoleAssistant MessageRole = "assistant" // MessageRoleSystem represents a system message MessageRoleSystem MessageRole = "system" // MessageRoleTool represents a tool response message MessageRoleTool MessageRole = "tool" )
type ParameterSpec ¶
type ParameterSpec struct {
// Type is the data type of the parameter (string, number, boolean, etc.)
Type string
// Description describes what the parameter is for
Description string
// Required indicates if the parameter is required
Required bool
// Default is the default value for the parameter
Default interface{}
// Enum is a list of possible values for the parameter
Enum []interface{}
// Items is the type of the items in the parameter
Items *ParameterSpec
}
ParameterSpec defines the specification for a tool parameter
type QueryOption ¶
type QueryOption func(*QueryOptions)
QueryOption represents an option for querying documents
func QueryWithLimit ¶
func QueryWithLimit(limit int) QueryOption
QueryWithLimit sets the maximum number of documents to return
func QueryWithOffset ¶
func QueryWithOffset(offset int) QueryOption
QueryWithOffset sets the number of documents to skip
func QueryWithOrderBy ¶
func QueryWithOrderBy(field string, direction string) QueryOption
QueryWithOrderBy sets the field to order by and the direction
type QueryOptions ¶
type QueryOptions struct {
// Limit is the maximum number of documents to return
Limit int
// Offset is the number of documents to skip
Offset int
// OrderBy specifies the field to order by
OrderBy string
// OrderDirection specifies the order direction (asc or desc)
OrderDirection string
}
QueryOptions contains options for querying documents
type ResponseFormat ¶ added in v0.0.4
type ResponseFormat struct {
Type ResponseFormatType
Name string // The name of the struct/object to be returned
Schema JSONSchema // JSON schema representation of the struct
}
ResponseFormat defines the format of the response from the LLM
type ResponseFormatType ¶ added in v0.0.4
type ResponseFormatType string
const ( ResponseFormatJSON ResponseFormatType = "json_object" ResponseFormatText ResponseFormatType = "text" )
type RetryPolicy ¶ added in v0.0.2
type RetryPolicy struct {
// MaxRetries is the maximum number of retries
MaxRetries int
// InitialBackoff is the initial backoff duration
InitialBackoff time.Duration
// MaxBackoff is the maximum backoff duration
MaxBackoff time.Duration
// BackoffMultiplier is the multiplier for backoff duration after each retry
BackoffMultiplier float64
}
RetryPolicy defines how tasks should be retried
type SearchOption ¶
type SearchOption func(*SearchOptions)
SearchOption represents an option for searching documents
func WithEmbedding ¶
func WithEmbedding(useEmbedding bool) SearchOption
WithEmbedding sets whether to use embedding for the search
func WithFields ¶ added in v0.0.24
func WithFields(fields ...string) SearchOption
WithFields sets the specific fields to retrieve in search results
func WithFilters ¶
func WithFilters(filters map[string]interface{}) SearchOption
WithFilters sets metadata filters
func WithKeyword ¶
func WithKeyword(useKeyword bool) SearchOption
WithKeyword sets whether to use keyword search
func WithMinScore ¶
func WithMinScore(score float32) SearchOption
WithMinScore sets the minimum similarity score
func WithNearText ¶
func WithNearText(useNearText bool) SearchOption
WithNearText sets whether to use nearText search
func WithTenantSearch ¶ added in v0.0.24
func WithTenantSearch(tenant string) SearchOption
WithTenantSearch sets the tenant for native multi-tenancy search operations
type SearchOptions ¶
type SearchOptions struct {
// MinScore is the minimum similarity score (0-1)
MinScore float32
// Filters are metadata filters to apply to the search
Filters map[string]interface{}
// Class is the class/collection name to search in
Class string
// UseEmbedding indicates whether to use embedding for the search
UseEmbedding bool
// UseBM25 indicates whether to use BM25 search instead of vector search
UseBM25 bool
// UseNearText indicates whether to use nearText search
UseNearText bool
// UseKeyword indicates whether to use keyword search
UseKeyword bool
// Tenant is the tenant name for native multi-tenancy
Tenant string
// Fields specifies which fields to retrieve. If empty, all fields will be retrieved dynamically
Fields []string
}
SearchOptions contains options for searching documents
type SearchResult ¶
type SearchResult struct {
// Document is the found document
Document Document
// Score is the similarity score (0-1, higher is more similar)
Score float32
}
SearchResult represents a document found in a search
type Span ¶
type Span interface {
// End ends the span
End()
// AddEvent adds an event to the span
AddEvent(name string, attributes map[string]interface{})
// SetAttribute sets an attribute on the span
SetAttribute(key string, value interface{})
RecordError(err error)
}
Span represents a span in a trace
type StoreOption ¶
type StoreOption func(*StoreOptions)
StoreOption represents an option for storing documents
func WithBatchSize ¶
func WithBatchSize(size int) StoreOption
WithBatchSize sets the batch size for storing documents
func WithGenerateVectors ¶
func WithGenerateVectors(generate bool) StoreOption
WithGenerateVectors sets whether to generate vectors
func WithTenant ¶ added in v0.0.24
func WithTenant(tenant string) StoreOption
WithTenant sets the tenant for native multi-tenancy operations
type StoreOptions ¶
type StoreOptions struct {
// BatchSize is the number of documents to store in each batch
BatchSize int
// GenerateVectors indicates whether to generate vectors for documents
GenerateVectors bool
// Class is the class/collection name to store documents in
Class string
// Tenant is the tenant name for native multi-tenancy
Tenant string
}
StoreOptions contains options for storing documents
type StreamConfig ¶ added in v0.0.34
type StreamConfig struct {
// BufferSize determines the channel buffer size
BufferSize int
// IncludeThinking whether to include thinking events
IncludeThinking bool
// IncludeToolProgress whether to include tool execution progress
IncludeToolProgress bool
// IncludeIntermediateMessages whether to include intermediate messages between tool iterations
IncludeIntermediateMessages bool
}
StreamConfig contains configuration for streaming behavior
func DefaultStreamConfig ¶ added in v0.0.34
func DefaultStreamConfig() StreamConfig
DefaultStreamConfig returns default streaming configuration
type StreamEvent ¶ added in v0.0.34
type StreamEvent struct {
Type StreamEventType `json:"type"`
Content string `json:"content,omitempty"`
ToolCall *ToolCall `json:"tool_call,omitempty"`
Error error `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
StreamEvent represents a single event in a stream
type StreamEventType ¶ added in v0.0.34
type StreamEventType string
StreamEventType represents the type of streaming event
const ( // Core streaming events StreamEventMessageStart StreamEventType = "message_start" StreamEventContentDelta StreamEventType = "content_delta" StreamEventContentComplete StreamEventType = "content_complete" StreamEventMessageStop StreamEventType = "message_stop" StreamEventError StreamEventType = "error" // Tool-related events StreamEventToolUse StreamEventType = "tool_use" StreamEventToolResult StreamEventType = "tool_result" // Thinking/reasoning events StreamEventThinking StreamEventType = "thinking" )
type StreamForwarder ¶ added in v0.2.3
type StreamForwarder func(event AgentStreamEvent)
StreamForwarder is a function that forwards stream events to a parent stream This is used to enable nested streaming from sub-agents to parent agents
type StreamingAgent ¶ added in v0.0.34
type StreamingAgent interface {
// RunStream executes the agent with streaming response
RunStream(ctx context.Context, input string) (<-chan AgentStreamEvent, error)
}
StreamingAgent represents an agent with streaming capabilities
type StreamingLLM ¶ added in v0.0.34
type StreamingLLM interface {
LLM
// GenerateStream generates text with streaming response
GenerateStream(ctx context.Context, prompt string, options ...GenerateOption) (<-chan StreamEvent, error)
// GenerateWithToolsStream generates text with tools and streaming response
GenerateWithToolsStream(ctx context.Context, prompt string, tools []Tool, options ...GenerateOption) (<-chan StreamEvent, error)
}
StreamingLLM extends LLM with streaming capabilities
type TaskExecutor ¶ added in v0.0.2
type TaskExecutor interface {
// ExecuteSync executes a task synchronously
ExecuteSync(ctx context.Context, taskName string, params interface{}, opts *TaskOptions) (*TaskResult, error)
// ExecuteAsync executes a task asynchronously and returns a channel for the result
ExecuteAsync(ctx context.Context, taskName string, params interface{}, opts *TaskOptions) (<-chan *TaskResult, error)
// ExecuteWorkflow initiates a temporal workflow
ExecuteWorkflow(ctx context.Context, workflowName string, params interface{}, opts *TaskOptions) (*TaskResult, error)
// ExecuteWorkflowAsync initiates a temporal workflow asynchronously
ExecuteWorkflowAsync(ctx context.Context, workflowName string, params interface{}, opts *TaskOptions) (<-chan *TaskResult, error)
// CancelTask cancels a running task
CancelTask(ctx context.Context, taskID string) error
// GetTaskStatus gets the status of a task
GetTaskStatus(ctx context.Context, taskID string) (string, error)
// ExecuteStep executes a single step in a task's plan
ExecuteStep(ctx context.Context, task interface{}, step interface{}) error
// ExecuteTask executes all steps in a task's plan
ExecuteTask(ctx context.Context, task interface{}) error
}
TaskExecutor is the interface for executing tasks
type TaskOptions ¶ added in v0.0.2
type TaskOptions struct {
// Timeout specifies the maximum duration for task execution
Timeout *time.Duration
// RetryPolicy specifies the retry policy for the task
RetryPolicy *RetryPolicy
// Metadata contains additional information for the task execution
Metadata map[string]interface{}
}
TaskOptions represents options for task execution
type TaskPlanner ¶ added in v0.0.3
type TaskPlanner interface {
// CreatePlan creates a plan for a task
CreatePlan(ctx context.Context, task interface{}) (string, error)
}
TaskPlanner defines the interface for planning a task
type TaskResult ¶ added in v0.0.2
type TaskResult struct {
// Data contains the result data
Data interface{}
// Error contains any error that occurred during task execution
Error error
// Metadata contains additional information about the task execution
Metadata map[string]interface{}
}
TaskResult represents the result of a task execution
type TaskService ¶ added in v0.0.3
type TaskService interface {
// CreateTask creates a new task
CreateTask(ctx context.Context, req interface{}) (interface{}, error)
// GetTask gets a task by ID
GetTask(ctx context.Context, taskID string) (interface{}, error)
// ListTasks returns tasks filtered by the provided criteria
ListTasks(ctx context.Context, filter interface{}) ([]interface{}, error)
// ApproveTaskPlan approves or rejects a task plan
ApproveTaskPlan(ctx context.Context, taskID string, req interface{}) (interface{}, error)
// UpdateTask updates an existing task with new steps or modifications
UpdateTask(ctx context.Context, taskID string, updates interface{}) (interface{}, error)
// AddTaskLog adds a log entry to a task
AddTaskLog(ctx context.Context, taskID string, message string, level string) error
}
TaskService defines the interface for task management This is a unified interface combining task and core.Service
type TokenUsage ¶ added in v0.1.13
type TokenUsage struct {
// InputTokens is the number of tokens in the input/prompt
InputTokens int
// OutputTokens is the number of tokens in the generated response
OutputTokens int
// TotalTokens is the total number of tokens used (input + output)
TotalTokens int
// ReasoningTokens is the number of tokens used for reasoning (optional, for models that support it)
ReasoningTokens int
}
TokenUsage represents token usage information for an LLM request
type Tool ¶
type Tool interface {
// Name returns the name of the tool
Name() string
// Description returns a description of what the tool does
Description() string
// Run executes the tool with the given input
Run(ctx context.Context, input string) (string, error)
// Parameters returns the parameters that the tool accepts
Parameters() map[string]ParameterSpec
// Execute executes the tool with the given arguments
Execute(ctx context.Context, args string) (string, error)
}
Tool represents a tool that can be used by an agent
type ToolCall ¶ added in v0.0.30
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
Internal bool `json:"internal,omitempty"`
Arguments string `json:"arguments"`
}
ToolCall represents a tool call made by the assistant
type ToolCallEvent ¶ added in v0.0.34
type ToolCallEvent struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
Internal bool `json:"internal,omitempty"`
Arguments string `json:"arguments,omitempty"`
Result string `json:"result,omitempty"`
Status string `json:"status"` // "starting", "executing", "completed", "error"
}
ToolCallEvent represents a tool call in streaming context
type ToolRegistry ¶
type ToolRegistry interface {
// Register registers a tool with the registry
Register(tool Tool)
// Get returns a tool by name
Get(name string) (Tool, bool)
// List returns all registered tools
List() []Tool
}
ToolRegistry is a registry of available tools
type ToolWithDisplayName ¶ added in v0.0.53
type ToolWithDisplayName interface {
// DisplayName returns a human-friendly name for the tool
DisplayName() string
}
ToolWithDisplayName is an optional interface that tools can implement to provide a human-friendly display name
type Tracer ¶
type Tracer interface {
// StartSpan starts a new span and returns a new context containing the span
StartSpan(ctx context.Context, name string) (context.Context, Span)
// StartTraceSession starts a root trace session for a request with the given contextID
// This creates a root span that will group all subsequent operations under the same trace
StartTraceSession(ctx context.Context, contextID string) (context.Context, Span)
}
Tracer represents a tracing system for observability
type Transaction ¶
type Transaction interface {
// Collection returns a reference to a specific collection/table within the transaction
Collection(name string) CollectionRef
// Commit commits the transaction
Commit() error
// Rollback rolls back the transaction
Rollback() error
}
Transaction represents a database transaction
type VectorStore ¶
type VectorStore interface {
Store(ctx context.Context, documents []Document, options ...StoreOption) error
Get(ctx context.Context, id string, options ...StoreOption) (*Document, error)
Search(ctx context.Context, query string, limit int, options ...SearchOption) ([]SearchResult, error)
SearchByVector(ctx context.Context, vector []float32, limit int, options ...SearchOption) ([]SearchResult, error)
Delete(ctx context.Context, ids []string, options ...DeleteOption) error
// Global operations for shared data (no tenant context)
GlobalStore(ctx context.Context, documents []Document, options ...StoreOption) error
GlobalSearch(ctx context.Context, query string, limit int, options ...SearchOption) ([]SearchResult, error)
GlobalSearchByVector(ctx context.Context, vector []float32, limit int, options ...SearchOption) ([]SearchResult, error)
GlobalDelete(ctx context.Context, ids []string, options ...DeleteOption) error
// Tenant management for native multi-tenancy
CreateTenant(ctx context.Context, tenantName string) error
DeleteTenant(ctx context.Context, tenantName string) error
ListTenants(ctx context.Context) ([]string, error)
}
VectorStore interface defines operations for vector storage and retrieval
type VectorStoreConfig ¶
type VectorStoreConfig struct {
// Host is the hostname of the vector store server
Host string
// APIKey is the authentication key for the vector store
APIKey string
// Scheme is the URL scheme (http or https)
Scheme string
// ClassPrefix is the default prefix for class/collection names
ClassPrefix string
// DistanceMetric is the similarity metric to use (e.g., "cosine", "euclidean", "dot")
DistanceMetric string
}
VectorStoreConfig contains configuration for vector stores