agent

package
v0.0.0-...-90d9bda Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefinedTool

type DefinedTool interface {
	// contains filtered or unexported methods
}

type OpenAICompatibleLLMProviderArgs

type OpenAICompatibleLLMProviderArgs struct {
	// Name is the name of the provider.
	// This will be used as a prefix for model names (e.g., "myprovider/model-name").
	Name string

	// APIKey is the API key to use with the provider.
	APIKey string `json:"-"`

	// BaseURL is the base URL to use with the provider.
	BaseURL string
}

type OpenAICompatibleLLMProviderOpt

type OpenAICompatibleLLMProviderOpt func(*oai.OpenAICompatible)

func OpenAIWithHTTPClient

func OpenAIWithHTTPClient(client *http.Client) OpenAICompatibleLLMProviderOpt

OpenAIWithHTTPClient sets the HTTP client to use with the provider.

type Provider

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

Provider allows defining various LLM providers.

type ReadSessionParams

type ReadSessionParams = internal.ReadSessionParams

type ReadSessionResult

type ReadSessionResult = internal.ReadSessionResult

type RunParams

type RunParams = internal.RunParams

func NewTextRunParams

func NewTextRunParams(userID, sessionID, text string) RunParams

NewTextRunParams returns parameters for a single user text message.

type RunResult

type RunResult = internal.RunResult

type Runner

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

func NewRunner

func NewRunner(args RunnerArgs, opts ...RunnerOpt) (*Runner, error)

func (*Runner) ReadSession

func (r *Runner) ReadSession(ctx context.Context, params ReadSessionParams) (*ReadSessionResult, error)

ReadSession reads the events for a session from the configured session service.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, params RunParams) (*RunResult, error)

type RunnerArgs

type RunnerArgs struct {
	// Providers is a list of providers to use for the runner.
	// Must include at least one provider.
	Providers []*Provider
}

type RunnerOpt

type RunnerOpt func(*runnerOpts)

func WithDefaultModel

func WithDefaultModel(model string) RunnerOpt

WithDefaultModel sets the default model to use for the runner. If caller does not set a model, the runner will use the default model.

func WithFileSystemStorage

func WithFileSystemStorage(baseDir string) RunnerOpt

WithFileSystemStorage configures the runner to persist state under baseDir on disk. The directory is created if it does not exist. When this option is omitted, storage is in-memory only. If WithFileSystemStorage is passed multiple times, the last call wins.

func WithLogger

func WithLogger(logger *slog.Logger) RunnerOpt

WithLogger sets the logger to use for the runner.

func WithSystemPromptFragments

func WithSystemPromptFragments(fragments ...SystemPromptFragment) RunnerOpt

WithSystemPromptFragments appends extra system prompt sections after the base template and the default assistant instruction fragment. Multiple calls append in order.

func WithToolsRegistry

func WithToolsRegistry(reg *ToolsRegistry) RunnerOpt

WithToolsRegistry sets an optional tools registry. When non-nil, Genkit tool stubs are registered on the runner's Genkit instance and ADK tools are supplied from the registry.

type SystemPromptFragment

type SystemPromptFragment = internal.SystemPromptFragment

SystemPromptFragment is an extra section appended after the runtime base system prompt.

type ToolContext

type ToolContext struct {
	context.Context
	// contains filtered or unexported fields
}

ToolContext is the invocation context passed to agent tool handlers. It is created only inside this package (ADK bridge or test-only helpers). It embeds context.Context so a *ToolContext may be passed where a context.Context is required. ADK-specific state is not exposed on the public type.

type ToolDef

type ToolDef[TArgs, TResults any] struct {
	Name        string
	Description string
	Handler     func(ctx *ToolContext, input TArgs) (TResults, error)
	// contains filtered or unexported fields
}

ToolDef is a generic tool definition for LLM agents with typed args and results.

func NewToolDef

func NewToolDef[TArgs, TResults any](
	name, description string,
	handler func(ctx *ToolContext, input TArgs) (TResults, error),
) ToolDef[TArgs, TResults]

func (ToolDef[TArgs, TResults]) WithOutputSchema

func (t ToolDef[TArgs, TResults]) WithOutputSchema(schemaJSON []byte) ToolDef[TArgs, TResults]

WithOutputSchema returns a copy of the tool definition with a custom output schema provided as raw JSON bytes. Use this when the output type cannot be inferred automatically (e.g., recursive types that would cause cycle-detection errors).

type ToolsRegistry

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

ToolsRegistry allows to register tools available to the agent.

func NewToolsRegistry

func NewToolsRegistry() *ToolsRegistry

NewToolsRegistry creates a new ToolsRegistry.

func (*ToolsRegistry) AddTools

func (r *ToolsRegistry) AddTools(tools ...DefinedTool)

Jump to

Keyboard shortcuts

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