Class: LaunchDarkly::Server::AI::AIConfig
- Inherits:
-
Object
- Object
- LaunchDarkly::Server::AI::AIConfig
- Defined in:
- lib/server/ai/client.rb
Overview
The AIConfig class represents an AI configuration returned by the SDK.
Instances are created by Client#completion_config and always carry a tracker factory; see #create_tracker. Do not instantiate directly. For application-supplied fallback values, use AIConfigDefault.
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
-
#create_tracker ⇒ AIConfigTracker
Creates a new tracker for a fresh AI run.
-
#initialize(tracker_factory:, enabled: nil, model: nil, messages: nil, provider: nil) ⇒ AIConfig
constructor
A new instance of AIConfig.
- #to_h ⇒ Object
Constructor Details
#initialize(tracker_factory:, enabled: nil, model: nil, messages: nil, provider: nil) ⇒ AIConfig
Returns a new instance of AIConfig.
157 158 159 160 161 162 163 |
# File 'lib/server/ai/client.rb', line 157 def initialize(tracker_factory:, enabled: nil, model: nil, messages: nil, provider: nil) @enabled = enabled @messages = @model = model @provider = provider @tracker_factory = tracker_factory end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
155 156 157 |
# File 'lib/server/ai/client.rb', line 155 def enabled @enabled end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
155 156 157 |
# File 'lib/server/ai/client.rb', line 155 def @messages end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
155 156 157 |
# File 'lib/server/ai/client.rb', line 155 def model @model end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
155 156 157 |
# File 'lib/server/ai/client.rb', line 155 def provider @provider end |
Instance Method Details
#create_tracker ⇒ AIConfigTracker
Creates a new tracker for a fresh AI run. Each call mints a new runId (a UUIDv4) that LaunchDarkly uses to correlate the tracker’s events in metrics views. Call this once per AI run; metrics from different runIds cannot be combined.
184 185 186 |
# File 'lib/server/ai/client.rb', line 184 def create_tracker @tracker_factory.call end |
#to_h ⇒ Object
165 166 167 168 169 170 171 172 173 174 |
# File 'lib/server/ai/client.rb', line 165 def to_h { _ldMeta: { enabled: @enabled || false, }, messages: @messages.is_a?(Array) ? @messages.map { |msg| msg&.to_h } : nil, model: @model&.to_h, provider: @provider&.to_h, } end |