Documentation
¶
Overview ¶
Package summarize asks a configured model for a cited upgrade-risk summary of a digest and keeps only the claims that cite entry IDs it was sent.
Index ¶
- Constants
- Variables
- func LoadAWSConfig(ctx context.Context, profile string, transport http.RoundTripper, ...) (aws.Config, error)
- func MantleAPI(api, model string) string
- func MantleBaseURL(region, api string) string
- func Timeout(c config.LLM) (time.Duration, error)
- func WithBedrockAPIKey(key string) func(*bedrockruntime.Options)
- type Anthropic
- type Bedrock
- type Env
- type Mantle
- type MantleOptions
- type OpenAI
- type Options
- type Prompt
- type Provider
- type Result
Constants ¶
const ( // AnthropicBaseURL is the Anthropic API when llm.base_url is empty. AnthropicBaseURL = "https://api.anthropic.com" // AnthropicKeyEnv holds the API key when llm.api_key_env is empty. AnthropicKeyEnv = "ANTHROPIC_API_KEY" )
const ( APIMessages = "messages" APIChatCompletions = "chat-completions" )
The wire APIs of the bedrock-mantle endpoint, the values of llm.api.
const ( ProviderOpenAI = "openai-compatible" ProviderAnthropic = "anthropic" ProviderBedrock = "bedrock" ProviderMantle = "bedrock-mantle" )
Provider names, the values of llm.provider.
const MaxTimeout = 2 * time.Minute
MaxTimeout caps llm.timeout: it is the longest single attempt httpx allows.
Variables ¶
var ErrNotConfigured = errors.New("llm not configured")
ErrNotConfigured means the llm config can't make a call. The caller warns and prints the report without a summary.
Functions ¶
func LoadAWSConfig ¶
func LoadAWSConfig( ctx context.Context, profile string, transport http.RoundTripper, logger *slog.Logger, ) (aws.Config, error)
LoadAWSConfig reads the shared AWS config and credentials for profile (empty means the default chain). It makes no request; credentials are fetched on the first call. A non-nil transport carries every request, and the SDK logs to logger.
func MantleAPI ¶
MantleAPI returns api, or for an empty api, messages for Anthropic model IDs and chat-completions for the rest.
func MantleBaseURL ¶
MantleBaseURL returns the regional base URL that api is served under.
func Timeout ¶
Timeout returns llm.timeout, capped at MaxTimeout.
func WithBedrockAPIKey ¶
func WithBedrockAPIKey(key string) func(*bedrockruntime.Options)
WithBedrockAPIKey makes the client send key, an Amazon Bedrock API key, as a bearer token instead of signing with SigV4.
Types ¶
type Anthropic ¶
type Anthropic struct {
// contains filtered or unexported fields
}
Anthropic calls the Anthropic Messages API.
func NewAnthropic ¶
NewAnthropic returns a provider that posts to baseURL + "/v1/messages".
type Bedrock ¶
type Bedrock struct {
// contains filtered or unexported fields
}
Bedrock calls the Amazon Bedrock Converse API.
func NewBedrock ¶
NewBedrock returns a provider for cfg; optFns change the client, such as its endpoint in tests.
type Env ¶
type Env struct {
Lookup func(string) (string, bool)
Transport http.RoundTripper // nil means the network
Logger *slog.Logger
UserAgent string
}
Env is what New takes from the outside world.
type Mantle ¶
type Mantle struct {
// contains filtered or unexported fields
}
Mantle calls the bedrock-mantle endpoint of Amazon Bedrock with the Anthropic Messages or the OpenAI Chat Completions API.
type MantleOptions ¶
type MantleOptions struct {
Model string
API string // APIMessages or APIChatCompletions; empty picks by model ID, see [MantleAPI]
BaseURL string // empty means [MantleBaseURL]
Region string
APIKey string // an Amazon Bedrock API key; empty signs with SigV4
Credentials aws.CredentialsProvider // for SigV4
Now func() time.Time // nil means time.Now
}
MantleOptions configures NewMantle.
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
OpenAI calls the chat completions endpoint of an OpenAI-compatible API, such as OpenAI, LiteLLM, Ollama or vLLM.
type Result ¶
type Result struct {
Summary *report.Summary // nil when no claim survived the check
Warnings []string
}
Result is a summary and the warnings the caller prints.