Class: Agentic::LlmConfig
- Inherits:
-
Object
- Object
- Agentic::LlmConfig
- Defined in:
- lib/agentic/llm_config.rb
Overview
Configuration object for LLM API calls
Instance Attribute Summary collapse
-
#additional_options ⇒ Hash
Additional options to pass to the API.
-
#frequency_penalty ⇒ Integer
The frequency penalty.
-
#max_tokens ⇒ Integer
The maximum number of tokens to generate.
-
#model ⇒ String
The model to use for LLM requests.
-
#presence_penalty ⇒ Integer
The presence penalty.
-
#temperature ⇒ Float
The temperature parameter (controls randomness).
-
#top_p ⇒ Float
The top_p parameter (nucleus sampling).
Instance Method Summary collapse
-
#initialize(model: "gpt-4o-2024-08-06", max_tokens: nil, temperature: 0.7, top_p: 1.0, frequency_penalty: 0.0, presence_penalty: 0.0, additional_options: {}) ⇒ LlmConfig
constructor
Initializes a new LLM configuration.
-
#to_api_parameters(base_params = {}) ⇒ Hash
Returns a hash of parameters for the API call.
Constructor Details
#initialize(model: "gpt-4o-2024-08-06", max_tokens: nil, temperature: 0.7, top_p: 1.0, frequency_penalty: 0.0, presence_penalty: 0.0, additional_options: {}) ⇒ LlmConfig
Initializes a new LLM configuration
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/agentic/llm_config.rb', line 35 def initialize( model: "gpt-4o-2024-08-06", max_tokens: nil, temperature: 0.7, top_p: 1.0, frequency_penalty: 0.0, presence_penalty: 0.0, additional_options: {} ) @model = model @max_tokens = max_tokens @temperature = temperature @top_p = top_p @frequency_penalty = frequency_penalty @presence_penalty = presence_penalty @additional_options = end |
Instance Attribute Details
#additional_options ⇒ Hash
Returns Additional options to pass to the API.
25 26 27 |
# File 'lib/agentic/llm_config.rb', line 25 def @additional_options end |
#frequency_penalty ⇒ Integer
Returns The frequency penalty.
19 20 21 |
# File 'lib/agentic/llm_config.rb', line 19 def frequency_penalty @frequency_penalty end |
#max_tokens ⇒ Integer
Returns The maximum number of tokens to generate.
10 11 12 |
# File 'lib/agentic/llm_config.rb', line 10 def max_tokens @max_tokens end |
#model ⇒ String
Returns The model to use for LLM requests.
7 8 9 |
# File 'lib/agentic/llm_config.rb', line 7 def model @model end |
#presence_penalty ⇒ Integer
Returns The presence penalty.
22 23 24 |
# File 'lib/agentic/llm_config.rb', line 22 def presence_penalty @presence_penalty end |
#temperature ⇒ Float
Returns The temperature parameter (controls randomness).
13 14 15 |
# File 'lib/agentic/llm_config.rb', line 13 def temperature @temperature end |
#top_p ⇒ Float
Returns The top_p parameter (nucleus sampling).
16 17 18 |
# File 'lib/agentic/llm_config.rb', line 16 def top_p @top_p end |
Instance Method Details
#to_api_parameters(base_params = {}) ⇒ Hash
Returns a hash of parameters for the API call
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/agentic/llm_config.rb', line 56 def to_api_parameters(base_params = {}) params = { model: @model, temperature: @temperature, top_p: @top_p, frequency_penalty: @frequency_penalty, presence_penalty: @presence_penalty } # Add max_tokens if specified params[:max_tokens] = @max_tokens if @max_tokens # Merge any additional options params.merge!(@additional_options) # Merge with base parameters base_params.merge(params) end |