Documentation
¶
Overview ¶
Package inferable provides a client for interacting with the Inferable API.
Index ¶
- Constants
- Variables
- type Agent
- type Agents
- type ContextInput
- type HandleCustomAuthInput
- type Inferable
- type InferableOptions
- type Interrupt
- type LLM
- type Logger
- type OnStatusChangeInput
- type ReactAgentConfig
- type StructuredInput
- type Tool
- type VALID_INTERRUPT_TYPES
- type Workflow
- type WorkflowConfig
- type WorkflowContext
- type WorkflowInput
- type WorkflowTool
- type WorkflowTools
- type WorkflowVersionBuilder
- type Workflows
Constants ¶
const ( MaxConsecutivePollFailures = 50 DefaultRetryAfter = 10 )
const (
// DefaultAPIEndpoint is the default endpoint for the Inferable API.
DefaultAPIEndpoint = "https://api.inferable.ai"
)
const Version = "0.1.44"
Version of the inferable package
Variables ¶
var Helpers = struct { // StructuredPrompt creates a structured prompt with facts and goals StructuredPrompt func(params struct { Facts []string Goals []string }) string }{ StructuredPrompt: func(params struct { Facts []string Goals []string }) string { result := "# Facts\n" for _, fact := range params.Facts { result += "- " + fact + "\n" } result += "# Your goals\n" for _, goal := range params.Goals { result += "- GOAL: " + goal + "\n" } return result }, }
Helpers provides helper functions for workflows
Functions ¶
This section is empty.
Types ¶
type Agent ¶ added in v0.1.44
type Agent struct {
// contains filtered or unexported fields
}
Agent represents an AI agent that can interact with users and perform tasks. It provides methods for sending messages and receiving responses.
func (*Agent) SendMessage ¶ added in v0.1.44
SendMessage sends a message to the agent and waits for a response. It enables bidirectional communication with the agent.
type Agents ¶ added in v0.1.44
type Agents struct {
// contains filtered or unexported fields
}
Agents provides functionality for creating and managing AI agents within workflows. It enables workflows to create agents that can perform tasks and interact with users.
func (*Agents) React ¶ added in v0.1.44
func (a *Agents) React(config ReactAgentConfig) (interface{}, *Interrupt, error)
React creates a React agent with the provided configuration. It initializes the agent and returns its result along with any interrupts. If interrupt is not nil, you must return it as the result of the workflow handler.
result, interrupt, err := ctx.Agents.React(ReactAgentConfig{ Name: "my-agent", Instructions: "You are a helpful assistant", Input: "Hello, how are you?", Schema: struct { Result string `json:"result"` }{}, }) if err != nil { // Handle error } if interrupt != nil { return interrupt, nil }
return result, nil
type ContextInput ¶ added in v0.1.34
type ContextInput struct { AuthContext interface{} `json:"authContext,omitempty"` RunContext interface{} `json:"runContext,omitempty"` Approved bool `json:"approved"` }
type HandleCustomAuthInput ¶ added in v0.1.31
type HandleCustomAuthInput struct {
Token string `json:"token"`
}
Input object for handleCustomAuth functions https://docs.inferable.ai/pages/custom-auth
type Inferable ¶
type Inferable struct { // Tools provides access to tool registration and management. Tools *pollingAgent // Workflows provides access to workflow creation and management. Workflows *Workflows // contains filtered or unexported fields }
Inferable is the main client for interacting with the Inferable platform. It provides access to tools, workflows, and other Inferable services. Use the New function to create a new instance of Inferable.
func New ¶
func New(options InferableOptions) (*Inferable, error)
type InferableOptions ¶
type Interrupt ¶ added in v0.1.37
type Interrupt struct { // Type specifies the kind of interrupt. Type VALID_INTERRUPT_TYPES `json:"type"` // Message provides additional context about the interrupt. Message string `json:"message,omitempty"` }
Interrupt represents an interruption in the normal flow of a workflow execution. Interrupts can be used to pause execution for approval or to handle exceptional conditions.
func ApprovalInterrupt ¶ added in v0.1.37
ApprovalInterrupt creates a new approval interrupt with the specified message. Approval interrupts are used when user approval is required to continue execution.
func GeneralInterrupt ¶ added in v0.1.44
GeneralInterrupt creates a new general interrupt with the specified message. General interrupts can be used for various purposes that require interrupting workflow execution.
func NewInterrupt ¶ added in v0.1.37
func NewInterrupt(typ VALID_INTERRUPT_TYPES, message string) *Interrupt
NewInterrupt creates a new Interrupt with the specified type and message. This is a general constructor for creating interrupts.
type LLM ¶ added in v0.1.44
type LLM struct {
// contains filtered or unexported fields
}
LLM provides LLM (Large Language Model) functionality for workflows. It enables workflows to interact with language models for text generation and processing.
func (*LLM) Structured ¶ added in v0.1.44
func (l *LLM) Structured(input StructuredInput) (interface{}, error)
Structured generates structured output from the LLM based on the provided input. It sends the input to the LLM and returns the structured response according to the schema.
result, err := ctx.LLM.Structured(StructuredInput{ Input: "Hello, how are you?", Schema: struct { Result string `json:"result"` }{}, }) if err != nil { // Handle error } return result, nil
type Logger ¶ added in v0.1.44
type Logger interface { // Info logs an informational message with associated metadata. Info(message string, meta map[string]interface{}) // Error logs an error message with associated metadata. Error(message string, meta map[string]interface{}) }
Logger interface for workflow logging. Implementations of this interface can be used to log workflow events.
type OnStatusChangeInput ¶
type OnStatusChangeInput struct { Status string `json:"status"` RunId string `json:"runId"` Result interface{} `json:"result"` Tags interface{} `json:"tags"` }
Input object for onStatusChange functions https://docs.inferable.ai/pages/runs#onstatuschange
type ReactAgentConfig ¶ added in v0.1.44
type ReactAgentConfig struct { // Name of the agent Name string // Instructions for the agent Instructions string // Input for the agent Input string // Schema for the agent result Schema interface{} // Tools for the agent Tools []string }
ReactAgentConfig holds the configuration for a React agent. It defines the agent's name, instructions, input, schema, and available tools.
type StructuredInput ¶ added in v0.1.44
type StructuredInput struct { // Input is the text prompt for the LLM. Input string `json:"input"` // Schema defines the expected structure of the LLM output. Schema interface{} `json:"schema"` }
StructuredInput represents input for structured LLM generation. It includes the input text and a schema defining the expected output structure.
type VALID_INTERRUPT_TYPES ¶ added in v0.1.37
type VALID_INTERRUPT_TYPES string
VALID_INTERRUPT_TYPES defines the valid types of interrupts that can occur during workflow execution.
const ( // APPROVAL indicates an interrupt that requires user approval to continue. APPROVAL VALID_INTERRUPT_TYPES = "approval" // GENERAL indicates a general interrupt that can be used for various purposes. GENERAL VALID_INTERRUPT_TYPES = "general" )
type Workflow ¶ added in v0.1.44
type Workflow struct { Tools *WorkflowTools // contains filtered or unexported fields }
Workflow represents a workflow in the Inferable system. It contains the workflow's configuration, handlers, and tools.
func (*Workflow) Listen ¶ added in v0.1.44
Listen starts listening for workflow executions. It registers the workflow and its tools with the Inferable service and begins processing incoming workflow execution requests.
func (*Workflow) Unlisten ¶ added in v0.1.44
Unlisten stops listening for workflow executions. It unregisters the workflow from the Inferable service and stops processing incoming workflow execution requests.
func (*Workflow) Version ¶ added in v0.1.44
func (w *Workflow) Version(version int) *WorkflowVersionBuilder
Version sets the version for the workflow. It returns a WorkflowVersionBuilder that can be used to define the handler for this version.
type WorkflowConfig ¶ added in v0.1.44
type WorkflowConfig struct { // Name is the unique identifier for the workflow. Name string // Description provides a human-readable explanation of the workflow's purpose. Description string // InputSchema defines the expected structure of the workflow input. InputSchema interface{} // Logger is used for logging workflow events. Logger Logger }
WorkflowConfig holds the configuration for a workflow. It defines the workflow's name, description, input schema, and logger.
type WorkflowContext ¶ added in v0.1.44
type WorkflowContext struct { // Input for the workflow Input interface{} // Approved indicates if the workflow is approved Approved bool // LLM functionality for the workflow LLM *LLM // Memo caches results for the workflow. It provides a way to store and retrieve // computation results across workflow executions. The function takes a name to // identify the cached result and a function that computes the result if not cached. // If a result with the given name exists in the cache, it is returned without // executing the function. Otherwise, the function is executed and its result is // stored in the cache before being returned. Memo func(name string, fn func() (interface{}, error)) (interface{}, error) // Log logs information for the workflow. It records a status message and associated // metadata for the current workflow execution. This information can be used for // monitoring, debugging, and auditing workflow executions. The status parameter // indicates the current state or event being logged, and the meta parameter provides // additional context or data related to the status. Log func(status string, meta map[string]interface{}) error // Agents provides agent functionality for the workflow Agents *Agents }
WorkflowContext provides context for workflow execution. It contains all the necessary information and functionality for a workflow to execute.
type WorkflowInput ¶ added in v0.1.44
type WorkflowInput struct {
ExecutionID string `json:"executionId"`
}
WorkflowInput is the base input type for all workflows. It contains the execution ID which uniquely identifies a workflow execution.
type WorkflowTool ¶ added in v0.1.44
type WorkflowTool struct { // Name is the unique identifier for the tool. Name string // Description provides a human-readable explanation of the tool's purpose. Description string // InputSchema defines the expected structure of the tool input. InputSchema interface{} // Func is the function that implements the tool's functionality. Func interface{} // Config provides additional configuration for the tool. Config interface{} }
WorkflowTool represents a tool that can be used within a workflow. Tools provide additional functionality that can be invoked during workflow execution.
type WorkflowTools ¶ added in v0.1.44
type WorkflowTools struct {
// contains filtered or unexported fields
}
WorkflowTools provides tool registration functionality for workflows. It allows registering custom tools that can be used within a workflow.
func (*WorkflowTools) Register ¶ added in v0.1.44
func (t *WorkflowTools) Register(tool WorkflowTool)
Register registers a tool for the workflow. The tool will be available for use within the workflow execution.
type WorkflowVersionBuilder ¶ added in v0.1.44
type WorkflowVersionBuilder struct {
// contains filtered or unexported fields
}
WorkflowVersionBuilder builds a workflow version. It provides methods for defining the handler for a specific workflow version.
func (*WorkflowVersionBuilder) Define ¶ added in v0.1.44
func (b *WorkflowVersionBuilder) Define(handler interface{})
Define defines the handler for the workflow version. The handler is a function that will be called when the workflow is executed.
type Workflows ¶ added in v0.1.44
type Workflows struct {
// contains filtered or unexported fields
}
Workflows provides workflow management functionality. It allows creating and triggering workflows.
func (*Workflows) Create ¶ added in v0.1.44
func (w *Workflows) Create(config WorkflowConfig) *Workflow
Create creates a new workflow with the provided configuration. It initializes the workflow with the given name, description, input schema, and logger. Returns a new Workflow instance that can be further configured.