Class: Ollama::Client::Configuration::Config
- Inherits:
-
Object
- Object
- Ollama::Client::Configuration::Config
- Extended by:
- JSONLoader
- Includes:
- DTO
- Defined in:
- lib/ollama/client/configuration/config.rb
Overview
A class that encapsulates configuration settings for Ollama clients.
This class provides a structured way to define and manage various configuration options that can be used when initializing Ollama client instances. It includes properties for setting the base URL, output stream, and timeout values.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
The api_key attribute allows setting and retrieving the API key for Ollama API authentication.
-
#base_url ⇒ Object
The base_url attribute accessor allows reading and setting the base URL of the Ollama API endpoint.
-
#connect_timeout ⇒ Object
The connect_timeout attribute accessor allows reading and setting the connection timeout value.
-
#debug ⇒ Object
The debug attribute accessor allows reading and setting the debug flag.
-
#output ⇒ Object
The output attribute accessor allows reading and setting the output stream used for handling responses and messages.
-
#read_timeout ⇒ Object
The read_timeout attribute accessor allows reading and setting the read timeout value.
-
#user_agent ⇒ Object
The user_agent attribute accessor allows reading and setting the user agent string used for making requests to the Ollama API.
-
#write_timeout ⇒ Object
The write_timeout attribute accessor allows reading and setting the write timeout value.
Class Method Summary collapse
-
.[](value) ⇒ self
The [] method creates a new instance of the class using a hash of attributes.
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ Ollama::Client::Configuration::Config
constructor
The initialize method sets up a new configuration instance with the specified attributes.
Methods included from JSONLoader
Methods included from DTO
#==, #as_array, #as_array_of_hashes, #as_hash, #as_json, #empty?, #to_json
Constructor Details
#initialize(**attributes) ⇒ Ollama::Client::Configuration::Config
The initialize method sets up a new configuration instance with the specified attributes.
This method is responsible for initializing a new Ollama::Client::Configuration::Config instance by processing various configuration options. It iterates through the provided attributes and assigns them to corresponding setter methods, then ensures that the output stream is set to $stdout if no output was specified.
53 54 55 56 |
# File 'lib/ollama/client/configuration/config.rb', line 53 def initialize(**attributes) attributes.each { |k, v| send("#{k}=", v) } self.output ||= $stdout end |
Instance Attribute Details
#api_key ⇒ Object
The api_key attribute allows setting and retrieving the API key for Ollama API authentication.
84 85 86 |
# File 'lib/ollama/client/configuration/config.rb', line 84 def api_key @api_key end |
#base_url ⇒ Object
The base_url attribute accessor allows reading and setting the base URL of the Ollama API endpoint.
78 79 80 |
# File 'lib/ollama/client/configuration/config.rb', line 78 def base_url @base_url end |
#connect_timeout ⇒ Object
The connect_timeout attribute accessor allows reading and setting the connection timeout value.
96 97 98 |
# File 'lib/ollama/client/configuration/config.rb', line 96 def connect_timeout @connect_timeout end |
#debug ⇒ Object
The debug attribute accessor allows reading and setting the debug flag.
113 114 115 |
# File 'lib/ollama/client/configuration/config.rb', line 113 def debug @debug end |
#output ⇒ Object
The output attribute accessor allows reading and setting the output stream used for handling responses and messages.
90 91 92 |
# File 'lib/ollama/client/configuration/config.rb', line 90 def output @output end |
#read_timeout ⇒ Object
The read_timeout attribute accessor allows reading and setting the read timeout value.
102 103 104 |
# File 'lib/ollama/client/configuration/config.rb', line 102 def read_timeout @read_timeout end |
#user_agent ⇒ Object
The user_agent attribute accessor allows reading and setting the user agent string used for making requests to the Ollama API.
119 120 121 |
# File 'lib/ollama/client/configuration/config.rb', line 119 def user_agent @user_agent end |
#write_timeout ⇒ Object
The write_timeout attribute accessor allows reading and setting the write timeout value.
108 109 110 |
# File 'lib/ollama/client/configuration/config.rb', line 108 def write_timeout @write_timeout end |
Class Method Details
.[](value) ⇒ self
The [] method creates a new instance of the class using a hash of attributes.
This class method provides a convenient way to instantiate an object by passing a hash containing the desired attribute values. It converts the hash keys to symbols and forwards them as keyword arguments to the constructor.
70 71 72 |
# File 'lib/ollama/client/configuration/config.rb', line 70 def self.[](value) new(**value.to_h) end |