localagi

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfig

type AgentConfig struct {
	Name            string   `json:"name"`
	Actions         []string `json:"actions,omitempty"`
	Connectors      []string `json:"connectors,omitempty"`
	PromptBlocks    []string `json:"prompt_blocks,omitempty"`
	InitialPrompt   string   `json:"initial_prompt,omitempty"`
	Parallel        bool     `json:"parallel,omitempty"`
	EnableReasoning bool     `json:"enable_reasoning,omitempty"`
}

AgentConfig represents the configuration for an agent

type AgentStatus

type AgentStatus struct {
	Status string `json:"status"`
}

AgentStatus represents the status of an agent

type ChatResponse

type ChatResponse struct {
	Response string `json:"response"`
}

ChatResponse represents a response from the agent

type Client

type Client struct {
	BaseURL    string
	APIKey     string
	HTTPClient *http.Client
}

Client represents a client for the LocalAGI API

func NewClient

func NewClient(baseURL string, apiKey string, timeout time.Duration) *Client

NewClient creates a new LocalAGI client

func (*Client) ChatAIResponse

func (c *Client) ChatAIResponse(agentName string, messages []InputMessage) (string, error)

ChatAIResponse sends chat messages to the AI model

func (*Client) CreateAgent

func (c *Client) CreateAgent(config *AgentConfig) error

CreateAgent creates a new agent with the given configuration

func (*Client) DeleteAgent

func (c *Client) DeleteAgent(name string) error

DeleteAgent removes an agent

func (*Client) ExportAgent

func (c *Client) ExportAgent(name string) (*AgentConfig, error)

ExportAgent exports an agent configuration

func (*Client) GetAIResponse

func (c *Client) GetAIResponse(request *RequestBody) (*ResponseBody, error)

GetAIResponse sends a request to the AI model and returns the response

func (*Client) GetAgentConfig

func (c *Client) GetAgentConfig(name string) (*AgentConfig, error)

GetAgentConfig retrieves the configuration for a specific agent

func (*Client) ListAgents

func (c *Client) ListAgents() ([]string, error)

ListAgents returns a list of all agents

func (*Client) Notify

func (c *Client) Notify(agentName, message string) error

Notify sends a notification to an agent

func (*Client) PauseAgent

func (c *Client) PauseAgent(name string) error

PauseAgent pauses an agent

func (*Client) SendMessage

func (c *Client) SendMessage(agentName, message string) error

SendMessage sends a message to an agent

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration)

SetTimeout sets the HTTP client timeout

func (*Client) SimpleAIResponse

func (c *Client) SimpleAIResponse(agentName, input string) (string, error)

SimpleAIResponse is a helper function to get a simple text response from the AI

func (*Client) StartAgent

func (c *Client) StartAgent(name string) error

StartAgent starts a paused agent

func (*Client) UpdateAgentConfig

func (c *Client) UpdateAgentConfig(name string, config *AgentConfig) error

UpdateAgentConfig updates the configuration for an existing agent

type ContentItem

type ContentItem struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
}

ContentItem represents an item in a content array

type InputFunctionToolCallOutput

type InputFunctionToolCallOutput struct {
	CallID string `json:"call_id"`
	Output string `json:"output"`
	Type   string `json:"type"`
	ID     string `json:"id"`
	Status string `json:"status"`
}

type InputMessage

type InputMessage struct {
	Type    string `json:"type"`
	Role    string `json:"role"`
	Content any    `json:"content"`
}

InputMessage represents a user input message

type Message

type Message struct {
	Message string `json:"message"`
}

Message represents a chat message

type MessageContentItem

type MessageContentItem struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

MessageContentItem represents a content item in a message

type RequestBody

type RequestBody struct {
	Model       string      `json:"model"`
	Input       any         `json:"input"`
	Temperature *float64    `json:"temperature,omitempty"`
	Tools       []Tool      `json:"tools,omitempty"`
	ToolChoice  *ToolChoice `json:"tool_choice"`
	MaxTokens   *int        `json:"max_output_tokens,omitempty"`
}

RequestBody represents the message request to the AI model

type ResponseBase

type ResponseBase json.RawMessage

func (*ResponseBase) ToFunctionToolCall

func (r *ResponseBase) ToFunctionToolCall() (msg ResponseFunctionToolCall, err error)

func (*ResponseBase) ToMessage

func (r *ResponseBase) ToMessage() (msg ResponseMessage, err error)

func (*ResponseBase) UnmarshalJSON

func (r *ResponseBase) UnmarshalJSON(data []byte) error

type ResponseBody

type ResponseBody struct {
	CreatedAt int64          `json:"created_at"`
	Status    string         `json:"status"`
	Error     any            `json:"error,omitempty"`
	Output    []ResponseBase `json:"output"`
	Tools     []Tool         `json:"tools"`
}

ResponseBody represents the response from the AI model

type ResponseFunctionToolCall

type ResponseFunctionToolCall struct {
	Arguments string `json:"arguments"`
	CallID    string `json:"call_id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	ID        string `json:"id"`
	Status    string `json:"status"`
}

type ResponseMessage

type ResponseMessage struct {
	Type    string               `json:"type"`
	Status  string               `json:"status"`
	Role    string               `json:"role"`
	Content []MessageContentItem `json:"content"`
}

ResponseMessage represents a message in the response

type ResponseType

type ResponseType string
const (
	ResponseTypeFunctionToolCall ResponseType = "function_call"
	ResponseTypeMessage          ResponseType = "message"
)

type Tool

type Tool struct {
	Type string `json:"type"`

	// Function tool fields (used when type == "function")
	Name        *string                `json:"name,omitempty"`
	Description *string                `json:"description,omitempty"`
	Parameters  *jsonschema.Definition `json:"parameters,omitempty"`

	// Web search tool fields (used when type == "web_search_preview" etc.)
	SearchContextSize *string       `json:"search_context_size,omitempty"`
	UserLocation      *UserLocation `json:"user_location,omitempty"`
}

type ToolChoice

type ToolChoice struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type UserLocation

type UserLocation struct {
	Type     string  `json:"type"`
	City     *string `json:"city,omitempty"`
	Country  *string `json:"country,omitempty"`
	Region   *string `json:"region,omitempty"`
	Timezone *string `json:"timezone,omitempty"`
}

UserLocation represents the user's location for web search

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL