manager

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithOutputDimensionality

func WithOutputDimensionality(dim uint) opt.Opt

WithOutputDimensionality sets the output dimensionality for embedding requests

func WithTaskType

func WithTaskType(taskType string) opt.Opt

WithTaskType sets the task type for embedding requests

func WithTitle

func WithTitle(title string) opt.Opt

WithTitle sets the title for the agent, which may be used in embedding requests

Types

type ConnectorFactory

type ConnectorFactory func(ctx context.Context, url string, extraOpts ...client.ClientOpt) (llm.Connector, error)

ConnectorFactory creates an llm.Connector for the given URL. The factory owns its static options (tracing, timeout, etc.). extraOpts are appended at call time and are used for per-URL dynamic options such as bearer token injection from a credential store.

func MCPConnectorFactory

func MCPConnectorFactory(name, version string, staticOpts ...mcpclient.Opt) ConnectorFactory

MCPConnectorFactory returns a ConnectorFactory that creates MCP clients. The client auto-detects the transport (Streamable HTTP, falling back to SSE). name and version are reported to the server during the MCP initialisation handshake. staticOpts are captured at construction time and applied to every connector created.

type Manager

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

func NewManager

func NewManager(name, ver string, opts ...Opt) (*Manager, error)

func (*Manager) Ask

func (m *Manager) Ask(ctx context.Context, request schema.AskRequest, fn opt.StreamFn) (response *schema.AskResponse, err error)

Ask processes a message and returns a response, outside of a session context (stateless). If fn is non-nil, text chunks are streamed to the callback as they arrive.

func (*Manager) CallTool

func (m *Manager) CallTool(ctx context.Context, name string, input json.RawMessage) (result *schema.CallToolResponse, err error)

CallTool executes a tool by name with the given input and returns the result.

func (*Manager) Chat

func (m *Manager) Chat(ctx context.Context, request schema.ChatRequest, fn opt.StreamFn) (response *schema.ChatResponse, err error)

Chat processes a message within a session context (stateful). If fn is non-nil, text chunks are streamed to the callback as they arrive.

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) CreateAgent

func (m *Manager) CreateAgent(ctx context.Context, meta schema.AgentMeta) (result *schema.Agent, err error)

CreateAgent creates a new agent from the given metadata.

func (*Manager) CreateAgentSession

func (m *Manager) CreateAgentSession(ctx context.Context, id string, request schema.CreateAgentSessionRequest) (result *schema.CreateAgentSessionResponse, err error)

CreateAgentSession resolves an agent by ID or name, validates input against the agent's schema, executes the agent's template, and creates a new session with merged GeneratorMeta and agent labels. If Parent is provided, the parent session's GeneratorMeta is used as defaults (agent fields take precedence). The returned response contains the session ID, rendered text, and tools, which the caller can pass to Chat.

func (*Manager) CreateConnector

func (m *Manager) CreateConnector(ctx context.Context, insert schema.ConnectorInsert) (result *schema.Connector, err error)

CreateConnector registers a new MCP connector and persists its metadata. When a connector factory is configured and the connector supports probing, the server state (name, version, capabilities) is fetched synchronously and persisted before returning. Subsequent reconnects update the state asynchronously via the background session.

func (*Manager) CreateSession

func (m *Manager) CreateSession(ctx context.Context, meta schema.SessionMeta) (result *schema.Session, err error)

CreateSession creates a new session for the given model.

func (*Manager) DeleteAgent

func (m *Manager) DeleteAgent(ctx context.Context, id string) (result *schema.Agent, err error)

DeleteAgent deletes an agent by ID or name and returns it.

func (*Manager) DeleteConnector

func (m *Manager) DeleteConnector(ctx context.Context, rawURL string) (err error)

DeleteConnector removes the connector for the given URL.

func (*Manager) DeleteModel

func (m *Manager) DeleteModel(ctx context.Context, req schema.DeleteModelRequest) (err error)

func (*Manager) DeleteSession

func (m *Manager) DeleteSession(ctx context.Context, session string) (result *schema.Session, err error)

DeleteSession deletes a session by ID and returns it.

func (*Manager) DownloadModel

func (m *Manager) DownloadModel(ctx context.Context, req schema.DownloadModelRequest, opts ...opt.Opt) (result *schema.Model, err error)

func (*Manager) Embedding

func (m *Manager) Embedding(ctx context.Context, request *schema.EmbeddingRequest) (response *schema.EmbeddingResponse, err error)

func (*Manager) GetAgent

func (m *Manager) GetAgent(ctx context.Context, id string) (result *schema.Agent, err error)

GetAgent retrieves an agent by ID or name.

func (*Manager) GetConnector

func (m *Manager) GetConnector(ctx context.Context, rawURL string) (result *schema.Connector, err error)

GetConnector returns the connector for the given URL.

func (*Manager) GetModel

func (m *Manager) GetModel(ctx context.Context, req schema.GetModelRequest) (result *schema.Model, err error)

func (*Manager) GetSession

func (m *Manager) GetSession(ctx context.Context, session string) (result *schema.Session, err error)

GetSession retrieves a session by ID.

func (*Manager) GetTool

func (m *Manager) GetTool(ctx context.Context, name string) (result *schema.ToolMeta, err error)

GetTool returns tool metadata by name.

func (*Manager) ListAgents

func (m *Manager) ListAgents(ctx context.Context, req schema.ListAgentRequest) (result *schema.ListAgentResponse, err error)

ListAgents returns agents with pagination support.

func (*Manager) ListConnectors

func (m *Manager) ListConnectors(ctx context.Context, req schema.ConnectorListRequest) (result *schema.ConnectorList, err error)

ListConnectors returns connectors matching the request filters.

func (*Manager) ListModels

func (m *Manager) ListModels(ctx context.Context, req schema.ModelListRequest) (result *schema.ModelList, err error)

func (*Manager) ListSessions

func (m *Manager) ListSessions(ctx context.Context, req schema.SessionListRequest) (result *schema.SessionList, err error)

ListSessions returns sessions with pagination support.

func (*Manager) ListTools

func (m *Manager) ListTools(ctx context.Context, req schema.ToolListRequest) (result *schema.ToolList, err error)

ListTools returns paginated tool metadata.

func (*Manager) UpdateAgent

func (m *Manager) UpdateAgent(ctx context.Context, id string, meta schema.AgentMeta) (result *schema.Agent, err error)

UpdateAgent updates an agent's metadata and creates a new version. If Model or Provider are changed, they are validated against the registered providers first.

func (*Manager) UpdateConnector

func (m *Manager) UpdateConnector(ctx context.Context, rawURL string, meta schema.ConnectorMeta) (result *schema.Connector, err error)

UpdateConnector updates the user-editable metadata for an existing connector.

func (*Manager) UpdateSession

func (m *Manager) UpdateSession(ctx context.Context, id string, meta schema.SessionMeta) (result *schema.Session, err error)

UpdateSession updates a session's metadata. If Model or Provider are changed, they are validated against the registered providers first.

type Opt

type Opt func(*Manager) error

Opt is a functional option for configuring an agent

func WithAgentStore

func WithAgentStore(store schema.AgentStore) Opt

WithAgentStore sets the agent storage backend for the manager. If not set, an in-memory store is used by default.

func WithClient

func WithClient(client llm.Client) Opt

WithClient adds an LLM client to the agent

func WithConnectorFactory

func WithConnectorFactory(factory ConnectorFactory) Opt

WithConnectorFactory sets the factory used to create MCP connectors. When set, CreateConnector probes the server before registering it. Use MCPConnectorFactory to get the standard MCP SSE implementation.

func WithConnectorStore

func WithConnectorStore(store schema.ConnectorStore) Opt

WithConnectorStore sets the MCP connector storage backend for the manager. If not set, an in-memory store is used by default.

func WithLogger

func WithLogger(l *slog.Logger) Opt

WithLogger sets the logger used for connector state and diagnostic messages. If l is nil, slog.Default() is used.

func WithSessionStore

func WithSessionStore(store schema.SessionStore) Opt

WithSessionStore sets the session storage backend for the manager. If not set, an in-memory store is used by default.

func WithTool

func WithTool(t llm.Tool) Opt

WithTool registers a single tool with the manager's toolkit.

func WithTools

func WithTools(tools ...llm.Tool) Opt

WithTools registers one or more tools with the manager's toolkit.

func WithTracer

func WithTracer(tracer trace.Tracer) Opt

WithTracer sets the OpenTelemetry tracer for distributed tracing.

Jump to

Keyboard shortcuts

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