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 ¶
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 ¶
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