Module: PatientLLM::Presets
- Defined in:
- lib/patient_llm/presets.rb
Overview
Built-in provider presets bundling the vendor-specific details needed to talk to the major LLM APIs: base URL, serializer format, authentication header name, and how the API key is formatted into that header.
Presets are pure defaults. Every value can be overridden with the normal keyword arguments to Configuration#provider, so a stale preset never blocks anyone.
Constant Summary collapse
- TABLE =
{ openai: { url: "https://api.openai.com", serializer: :open_responses, auth_header: "authorization", auth_format: "Bearer %s" }, anthropic: { url: "https://api.anthropic.com", serializer: :messages, auth_header: "x-api-key", auth_format: "%s", headers: {"anthropic-version" => ANTHROPIC_VERSION} }, gemini: { url: "https://generativelanguage.googleapis.com", serializer: :gemini, auth_header: "x-goog-api-key", auth_format: "%s" }, # Bedrock's bearer auth is for Amazon Bedrock API keys; SigV4 signing is # available instead via the :aws_sigv4 preprocessor (see AwsRequestSigner). bedrock_runtime: { url: "https://bedrock-runtime.%{region}.amazonaws.com", serializer: :converse, auth_header: "authorization", auth_format: "Bearer %s", requires_region: true } }.freeze
Class Method Summary collapse
-
.fetch(name) ⇒ Hash
Fetch a preset by name.
-
.url(preset, region: nil) ⇒ String?
Resolve a preset's base URL, filling in the region placeholder when the preset requires one.
Class Method Details
.fetch(name) ⇒ Hash
Fetch a preset by name.
55 56 57 |
# File 'lib/patient_llm/presets.rb', line 55 def fetch(name) TABLE[name.to_sym] || raise(ArgumentError, "Unknown preset: #{name.inspect}. Valid presets: #{TABLE.keys.map(&:inspect).join(", ")}") end |
.url(preset, region: nil) ⇒ String?
Resolve a preset's base URL, filling in the region placeholder when the preset requires one.
65 66 67 68 69 70 71 72 73 |
# File 'lib/patient_llm/presets.rb', line 65 def url(preset, region: nil) if preset[:requires_region] return nil if region.nil? format(preset[:url], region: region) else preset[:url] end end |