mirror of
https://github.com/vxcontrol/langchaingo.git
synced 2026-08-25 11:10:02 -04:00
064f09155c
- Raised the `go` directive from 1.24.1 to 1.26.5 to satisfy pgx/v5 and ollama's minimum Go version requirements and to pick up 15 patched standard library CVEs. - Updated `pgx/v5`, `otel`/`otel/sdk`/`otlptracehttp`, `x/net`, and the AWS `eventstream` protocol package to their latest requested versions. - Remediated govulncheck-flagged CVEs in `grpc`, `x/text`, `x/crypto`, `antchfx/xpath`, AWS SDK `bedrock*`/`s3` services, `etcd/server`, and `mongo-driver` v1/v2. - Fixed ollama's `MainGPU` API type change (`int` -> `*int`) in `llms/ollama/options.go` without breaking the public `WithRunnerMainGPU` signature.
Bedrock Provider Example
This example demonstrates how to use the Bedrock LLM with different model providers, including support for Nova models and inference profiles.
Features
- Automatic provider detection from model ID
- Explicit provider specification for edge cases
- Support for Nova models (e.g.,
amazon.nova-lite-v1:0) - Support for inference profiles (e.g.,
us.amazon.nova-lite-v1:0)
Prerequisites
- AWS credentials configured (via environment variables or AWS credentials file)
- Access to the Bedrock models you want to use
Usage
# Using default Titan model
go run main.go
# Using Nova model
go run main.go -model "amazon.nova-lite-v1:0"
# Using inference profile
go run main.go -model "us.amazon.nova-lite-v1:0"
# Using Anthropic model with explicit provider (for edge cases)
go run main.go -model "us.anthropic.claude-3-7-sonnet-20250219-v1:0" -provider "anthropic"
# Custom prompt
go run main.go -prompt "What is the capital of France?"
# Verbose output
go run main.go -verbose
Environment Variables
Set these environment variables before running:
export AWS_ACCESS_KEY_ID=your_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=us-east-1
Supported Providers
The Bedrock integration automatically detects the provider from the model ID:
- Nova: Models containing
.nova-(e.g.,amazon.nova-lite-v1:0,us.amazon.nova-pro-v1:0) - Anthropic: Models containing
anthropic(e.g.,anthropic.claude-3-sonnet-20240229-v1:0) - Amazon: Models containing
amazon(excluding Nova) - Meta: Models containing
meta(e.g.,meta.llama3-1-405b-instruct-v1:0) - Cohere: Models containing
cohere(e.g.,cohere.command-r-plus-v1:0) - AI21: Models containing
ai21(e.g.,ai21.jamba-1-5-large-v1:0)
Model Provider Option
For cases where automatic detection doesn't work correctly (e.g., custom inference endpoints), you can explicitly specify the provider:
llm, err := bedrock.New(
bedrock.WithModel("custom.endpoint.model-id"),
bedrock.WithModelProvider("anthropic"), // Explicitly set provider
)