Class: PatientLLM::Configuration
- Inherits:
-
Object
- Object
- PatientLLM::Configuration
- Defined in:
- lib/patient_llm/configuration.rb
Overview
Configuration for provider registry.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#lookup(name) ⇒ Hash?
Look up a registered provider by name.
-
#provider(name, url:, headers: {}, serializer: :chat_completion, path: nil, completion_path: nil, params: {}) ⇒ void
Register a provider with a base URL and default headers.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 |
# File 'lib/patient_llm/configuration.rb', line 19 def initialize @providers = {} end |
Instance Method Details
#lookup(name) ⇒ Hash?
Look up a registered provider by name.
59 60 61 |
# File 'lib/patient_llm/configuration.rb', line 59 def lookup(name) @providers[name&.to_s] end |
#provider(name, url:, headers: {}, serializer: :chat_completion, path: nil, completion_path: nil, params: {}) ⇒ void
This method returns an undefined value.
Register a provider with a base URL and default headers.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/patient_llm/configuration.rb', line 33 def provider(name, url:, headers: {}, serializer: :chat_completion, path: nil, completion_path: nil, params: {}) if completion_path warn "PatientLLM::Configuration#provider: the `completion_path:` argument is deprecated; use `path:` instead", uplevel: 1 path ||= completion_path end sym = serializer.to_sym unless PatientLLM::VALID_SERIALIZERS.include?(sym) raise ArgumentError, "Unknown serializer: #{sym.inspect}. Valid options: #{PatientLLM::VALID_SERIALIZERS.map(&:inspect).join(", ")}" end ensure_auth_headers_use_secrets!(headers) @providers[name.to_s] = { url: url, headers: headers, serializer: sym, path: path, params: params } end |