Documentation
¶
Index ¶
- type AgentTaskServiceInterface
- type CollectionRef
- type DataStore
- type DeleteOption
- type DeleteOptions
- type Document
- type Embedder
- type GenerateOption
- type GenerateOptions
- type GetMessagesOption
- type GetMessagesOptions
- type Guardrails
- type JSONSchema
- type LLM
- type LLMConfig
- type MCPServer
- type MCPTool
- type MCPToolResponse
- type Memory
- type Message
- type ParameterSpec
- type QueryOption
- type QueryOptions
- type ResponseFormat
- type ResponseFormatType
- type RetryPolicy
- type SearchOption
- type SearchOptions
- type SearchResult
- type Span
- type StoreOption
- type StoreOptions
- type TaskExecutor
- type TaskOptions
- type TaskPlanner
- type TaskResult
- type TaskService
- type Tool
- type ToolRegistry
- type Tracer
- type Transaction
- type VectorStore
- type VectorStoreConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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
type DeleteOptions ¶
type DeleteOptions struct {
// Class is the class/collection name to delete from
Class 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 GenerateOption ¶
type GenerateOption func(options *GenerateOptions)
GenerateOption represents options for text generation
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
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)
}
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 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)
// Name returns the name of the LLM provider
Name() string
}
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 (none, minimal, comprehensive) to control explanation detail
}
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)
// Close closes the connection to the MCP server
Close() error
}
MCPServer represents a connection to an MCP server
type MCPToolResponse ¶ added in v0.0.13
type MCPToolResponse struct {
Content interface{}
IsError bool
}
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 (e.g., "user", "assistant", "system")
Role string
// Content is the content of the message
Content string
// Metadata contains additional information about the message
Metadata map[string]interface{}
}
Message represents a message in a conversation
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 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
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
}
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{})
}
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
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
}
StoreOptions contains options for storing documents
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 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 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 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)
}
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 stores documents in the vector store
Store(ctx context.Context, documents []Document, options ...StoreOption) error
// Search searches for similar documents
Search(ctx context.Context, query string, limit int, options ...SearchOption) ([]SearchResult, error)
// SearchByVector searches for similar documents using a vector
SearchByVector(ctx context.Context, vector []float32, limit int, options ...SearchOption) ([]SearchResult, error)
// Delete removes documents from the vector store
Delete(ctx context.Context, ids []string, options ...DeleteOption) error
// Get retrieves documents by their IDs
Get(ctx context.Context, ids []string) ([]Document, error)
}
VectorStore represents a vector database for storing and retrieving embeddings
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