remote

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent represents a remote chat agent that communicates with a server agent via HTTP

func NewAgent

func NewAgent(
	ctx context.Context,
	agentConfig agents.Config,
	baseURL string,
	opts ...RemoteAgentOption,
) (*Agent, error)

NewAgent creates a new remote chat agent

func (*Agent) AddMessage

func (agent *Agent) AddMessage(role roles.Role, content string)

AddMessage adds a message to the conversation history Note: This is a no-op for remote agent as messages are managed server-side

func (*Agent) AddMessages added in v1.0.4

func (agent *Agent) AddMessages(msgs []messages.Message)

AddMessages adds multiple messages to the conversation history Note: This is a no-op for remote agent as messages are managed server-side

func (*Agent) CancelOperation

func (agent *Agent) CancelOperation(operationID string) error

CancelOperation cancels a pending tool call operation on the server

func (*Agent) ExportMessagesToJSON

func (agent *Agent) ExportMessagesToJSON() (string, error)

ExportMessagesToJSON exports the conversation history to JSON

func (*Agent) GenerateCompletion

func (agent *Agent) GenerateCompletion(userMessages []messages.Message) (*CompletionResult, error)

GenerateCompletion sends messages and returns the completion result

func (*Agent) GenerateCompletionWithReasoning

func (agent *Agent) GenerateCompletionWithReasoning(userMessages []messages.Message) (*ReasoningResult, error)

GenerateCompletionWithReasoning sends messages and returns the completion result with reasoning Note: Reasoning is not yet supported by the server API

func (*Agent) GenerateStreamCompletion

func (agent *Agent) GenerateStreamCompletion(
	userMessages []messages.Message,
	callback StreamCallback,
) (*CompletionResult, error)

GenerateStreamCompletion sends messages and streams the response via callback

func (*Agent) GenerateStreamCompletionWithReasoning

func (agent *Agent) GenerateStreamCompletionWithReasoning(
	userMessages []messages.Message,
	reasoningCallback StreamCallback,
	responseCallback StreamCallback,
) (*ReasoningResult, error)

GenerateStreamCompletionWithReasoning sends messages and streams both reasoning and response Note: The server doesn't support separate reasoning streams yet

func (*Agent) GetContext added in v1.2.2

func (agent *Agent) GetContext() context.Context

GetContext returns the remote agent's context

func (*Agent) GetContextSize

func (agent *Agent) GetContextSize() int

GetContextSize returns the approximate size of the current context from the server

func (*Agent) GetHealth

func (agent *Agent) GetHealth() (*HealthStatus, error)

GetHealth checks if the server is healthy and reachable

func (*Agent) GetMessages

func (agent *Agent) GetMessages() []messages.Message

GetMessages returns all conversation messages from the server

func (*Agent) GetModelID

func (agent *Agent) GetModelID() string

GetModelID returns the model ID from the server

func (*Agent) GetModelsInfo

func (agent *Agent) GetModelsInfo() (*ModelsInfo, error)

GetModelsInfo returns detailed information about all models used by the server

func (*Agent) GetName

func (agent *Agent) GetName() string

GetName returns the agent name

func (*Agent) IsHealthy

func (agent *Agent) IsHealthy() bool

IsHealthy is a convenience method that returns true if the server is healthy

func (*Agent) Kind

func (agent *Agent) Kind() agents.Kind

Kind returns the agent type

func (*Agent) ResetMessages

func (agent *Agent) ResetMessages()

ResetMessages clears all messages except the system instruction

func (*Agent) ResetOperations

func (agent *Agent) ResetOperations() error

ResetOperations cancels all pending tool call operations on the server

func (*Agent) SetContext added in v1.2.2

func (agent *Agent) SetContext(ctx context.Context)

SetContext updates the remote agent's context

func (*Agent) SetToolCallCallback

func (agent *Agent) SetToolCallCallback(callback ToolCallCallback)

SetToolCallCallback sets the callback for tool call notifications

func (*Agent) StopStream

func (agent *Agent) StopStream()

StopStream interrupts the current streaming operation

func (*Agent) ValidateOperation

func (agent *Agent) ValidateOperation(operationID string) error

ValidateOperation validates a pending tool call operation on the server

type CompletionResult

type CompletionResult struct {
	Response     string
	FinishReason string
}

CompletionResult represents the result of a chat completion

type HealthStatus

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

HealthStatus contains the health status of the server

type ModelsInfo

type ModelsInfo struct {
	Status          string `json:"status"`
	ChatModel       string `json:"chat_model"`
	EmbeddingsModel string `json:"embeddings_model"`
	ToolsModel      string `json:"tools_model"`
}

ModelsInfo contains information about the models used by the server

type ReasoningResult

type ReasoningResult struct {
	Response     string
	Reasoning    string
	FinishReason string
}

ReasoningResult represents the result of a chat completion with reasoning

type RemoteAgentOption added in v1.2.9

type RemoteAgentOption func(*Agent)

RemoteAgentOption is a functional option for configuring an Agent during creation

func AfterCompletion added in v1.2.9

func AfterCompletion(fn func(*Agent)) RemoteAgentOption

AfterCompletion sets a hook that is called after each completion (standard and streaming)

func BeforeCompletion added in v1.2.9

func BeforeCompletion(fn func(*Agent)) RemoteAgentOption

BeforeCompletion sets a hook that is called before each completion (standard and streaming)

type StreamCallback

type StreamCallback func(chunk string, finishReason string) error

StreamCallback is a function called for each chunk of streaming response

type ToolCallCallback

type ToolCallCallback func(operationID string, message string) error

ToolCallCallback is a function called when a tool call is detected

Jump to

Keyboard shortcuts

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