utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: BSD-2-Clause Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package utils holds the helper the flows examples share, which keeps them focused on the flow itself.

CreateLLM builds the LLM service an example runs, chosen by LLM_PROVIDER:

  • openai: OpenAI Chat Completions, needs OPENAI_API_KEY.
  • openai_responses: OpenAI Responses, needs OPENAI_API_KEY. The default.
  • anthropic: needs ANTHROPIC_API_KEY.
  • google: Gemini, needs GOOGLE_API_KEY.
  • aws: Bedrock, through the default AWS credential chain (SSO, environment variables or IAM roles). AWS_REGION picks the region, us-west-2 by default.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedProvider reports an LLM_PROVIDER no service is configured
	// for.
	ErrUnsupportedProvider = errors.New("unsupported LLM provider")
	// ErrMissingAPIKey reports a provider whose API key is not set.
	ErrMissingAPIKey = errors.New("missing API key")
)

Functions

This section is empty.

Types

type LLM

type LLM interface {
	processor.Processor
	flows.Inferencer
	RegisterFunction(name string, h llm.FunctionCallHandler, opts ...llm.RegisterOption)
}

LLM is what the examples need of the service CreateLLM builds: a pipeline processor, somewhere to register tools, and a one-shot inference for the flow's conversation summaries.

func CreateLLM

func CreateLLM(ctx context.Context, provider, model string) (LLM, error)

CreateLLM builds an LLM service from the environment.

provider names the provider; empty reads LLM_PROVIDER, which defaults to openai_responses. model names the model; empty uses the provider's default.

model, err := utils.CreateLLM(ctx, "", "")            // LLM_PROVIDER, or OpenAI Responses
model, err := utils.CreateLLM(ctx, "anthropic", "")   // a specific provider
model, err := utils.CreateLLM(ctx, "openai", "gpt-6") // a specific provider and model

Jump to

Keyboard shortcuts

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