llmcontext

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder builds contexts for LLM requests

func NewLLMContextBuilder

func NewLLMContextBuilder(
	pluginAPI *pluginapi.Client,
	toolProvider ToolProvider,
	mcpToolProvider MCPToolProvider,
	configProvider ConfigProvider,
) *Builder

NewLLMContextBuilder creates a new LLM context builder

func (*Builder) BuildLLMContextUserRequest

func (b *Builder) BuildLLMContextUserRequest(bot *bots.Bot, requestingUser *model.User, channel *model.Channel, opts ...llm.ContextOption) *llm.Context

BuildLLMContextUserRequest is a helper function to collect the required context for a user request.

func (*Builder) SetMCPDynamicToolTelemetry

func (b *Builder) SetMCPDynamicToolTelemetry(telemetry llm.MCPDynamicToolTelemetry)

func (*Builder) WithLLMContextBot

func (b *Builder) WithLLMContextBot(bot *bots.Bot) llm.ContextOption

func (*Builder) WithLLMContextChannel

func (b *Builder) WithLLMContextChannel(channel *model.Channel) llm.ContextOption

func (*Builder) WithLLMContextConcreteTools

func (b *Builder) WithLLMContextConcreteTools(ctx stdcontext.Context, bot *bots.Bot) llm.ContextOption

WithLLMContextConcreteTools adds the requester's tools but forces concrete MCP tools instead of dynamic-loading meta-tools. Bridge catalog APIs need the full concrete MCP tool list regardless of the bot's dynamic-loading setting.

func (*Builder) WithLLMContextDefaultTools

func (b *Builder) WithLLMContextDefaultTools(ctx stdcontext.Context, bot *bots.Bot) llm.ContextOption

WithLLMContextDefaultTools adds default tools to the LLM context for the requesting user

func (*Builder) WithLLMContextDisabledMCPServers

func (b *Builder) WithLLMContextDisabledMCPServers(origins []string) llm.ContextOption

func (*Builder) WithLLMContextInteractive

func (b *Builder) WithLLMContextInteractive() llm.ContextOption

WithLLMContextInteractive marks the requesting user as interactively present and able to answer pending tool approvals. User-interaction tools (llm.Tool.UserInteraction) are only cataloged when this is applied, so it must be configured before default tools are built. Automated invokers (bots, webhooks, bridge API, evals) must never set this.

func (*Builder) WithLLMContextMCPToolFilter

func (b *Builder) WithLLMContextMCPToolFilter(keep func(llm.Tool) bool) llm.ContextOption

func (*Builder) WithLLMContextNoTools

func (b *Builder) WithLLMContextNoTools() llm.ContextOption

WithLLMContextNoTools explicitly disables tools for this context session only, overriding the bot's DisableTools configuration. This allows inter-plugin requests to work with tool-enabled bots by bypassing tools for non-streaming calls.

func (*Builder) WithLLMContextParameters

func (b *Builder) WithLLMContextParameters(params map[string]interface{}) llm.ContextOption

func (*Builder) WithLLMContextPreloadedMCPTools

func (b *Builder) WithLLMContextPreloadedMCPTools(tools []llm.EnabledMCPTool) llm.ContextOption

WithLLMContextPreloadedMCPTools requests exact-or-bare MCP tools for internal predefined flows. The selected tools are still constrained by the normal authorized MCP catalog and must be configured before default tools are built.

func (*Builder) WithLLMContextRequestingUser

func (b *Builder) WithLLMContextRequestingUser(user *model.User) llm.ContextOption

func (*Builder) WithLLMContextServerInfo

func (b *Builder) WithLLMContextServerInfo() llm.ContextOption

func (*Builder) WithLLMContextTools

func (b *Builder) WithLLMContextTools(ctx stdcontext.Context, bot *bots.Bot) llm.ContextOption

WithLLMContextTools adds tools to the LLM context the requester can access. Tools are always added for LLM awareness; execution is controlled via WithToolsDisabled() based on the context (e.g., DM vs channel).

type ConfigProvider

type ConfigProvider interface {
	GetServiceByID(id string) (llm.ServiceConfig, bool)
}

ConfigProvider provides configuration access

type MCPToolProvider

type MCPToolProvider interface {
	GetToolsForUser(ctx stdcontext.Context, userID string) ([]llm.Tool, *mcp.Errors)
}

MCPToolProvider provides MCP tools for a user

type MCPToolRetrievalOverrideProvider

type MCPToolRetrievalOverrideProvider interface {
	GetToolRetrievalOverrides() map[string]mcp.ToolRetrievalOverride
}

type ToolProvider

type ToolProvider interface {
	GetTools(bot *bots.Bot, llmContext *llm.Context) []llm.Tool
}

ToolProvider provides built-in tools for a bot and context

Jump to

Keyboard shortcuts

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