launchdarkly-server-sdk-ai 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4eca8fb4b72e683402ec14537df6b5570c2587004f9fbcd17d8cc9f7038dd46d
4
- data.tar.gz: 0df3584ec493ea24d3d05e867be8243a1b336b94a72943b56f78e1cec6c524d2
3
+ metadata.gz: e994fc537562707ea07e7f4ae42b1bcc067e6973e94de8ed4aaa3f6f88f381dc
4
+ data.tar.gz: 6ce57d443507383befc30d4ebdc0b4c06d53064409f0e6667fd45627bc230975
5
5
  SHA512:
6
- metadata.gz: 28792c2f4453c076312b8d9aa6cc56ce8b4fcadb2ad599ff73d0d6853bd037287b5d19ee38afffe0f98790fe7fe197c024ba863a719c1188d28efc041e9c8a6d
7
- data.tar.gz: d116af21d8ecf7e40182d688d8eb1cf29780c15356d31e7fefcdb7ecbef4f2929b76586cf6906f5ac17e1cc807c7e359f546325aba0f48767791ea24c5b524bb
6
+ metadata.gz: f1b764660139b8804b404b8b0f30b92f99676fa3da7d7af321d9149e03c1ebdd1577d9bc0760d5b0e851388979f2b0069df4992736164d2d63343a82793e6e71
7
+ data.tar.gz: 4e09545e4aef19e24b145d5b42153f2ceeac02c5b9e4c4fb00b3a6dbb3aea4fbe87efb714183a120958dc510a971b281bc7f2bfb0589ec763370bcf90dc4dc20
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0](https://github.com/launchdarkly/ruby-server-sdk-ai/compare/0.1.0...0.2.0) (2025-07-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * added provider and model to ai tracker ([5922fe9](https://github.com/launchdarkly/ruby-server-sdk-ai/commit/5922fe931ad227caa187b46153e8cee77b978032))
9
+ * Update AI tracker to include model & provider name for metrics generation ([#11](https://github.com/launchdarkly/ruby-server-sdk-ai/issues/11)) ([ce176e4](https://github.com/launchdarkly/ruby-server-sdk-ai/commit/ce176e42c311857fd6fda30864b8b7cc7b402c20))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * Remove deprecated track generation event ([#10](https://github.com/launchdarkly/ruby-server-sdk-ai/issues/10)) ([dc13cfb](https://github.com/launchdarkly/ruby-server-sdk-ai/commit/dc13cfb0121e613ccbbfe8f9fda8868b9590e356))
15
+ * Remove unused instance variable ([#13](https://github.com/launchdarkly/ruby-server-sdk-ai/issues/13)) ([6a04b8b](https://github.com/launchdarkly/ruby-server-sdk-ai/commit/6a04b8ba6c85922856e3236d3d31393cd9d17180))
16
+
3
17
  ## [0.1.0](https://github.com/launchdarkly/ruby-server-sdk-ai/compare/0.0.0...0.1.0) (2025-06-18)
4
18
 
5
19
 
data/PROVENANCE.md CHANGED
@@ -9,7 +9,7 @@ To verify SLSA provenance attestations, we recommend using [slsa-verifier](https
9
9
  <!-- x-release-please-start-version -->
10
10
  ```
11
11
  # Set the version of the SDK to verify
12
- VERSION=0.1.0
12
+ VERSION=0.2.0
13
13
  ```
14
14
  <!-- x-release-please-end -->
15
15
 
data/README.md CHANGED
@@ -1,6 +1,45 @@
1
- LaunchDarkly Server-side AI library for Ruby
1
+ LaunchDarkly Server SDK AI library for Ruby
2
2
  ==============================================
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/launchdarkly-server-sdk-ai.svg)](http://badge.fury.io/rb/launchdarkly-server-sdk-ai)
5
+
6
+ [![Quality Control](https://github.com/launchdarkly/ruby-server-sdk-ai/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/ruby-server-sdk-ai/actions/workflows/ci.yml)
7
+ [![RubyDoc](https://img.shields.io/static/v1?label=docs+-+all+versions&message=reference&color=00add8)](https://www.rubydoc.info/gems/launchdarkly-server-sdk-ai)
8
+ [![GitHub Pages](https://img.shields.io/static/v1?label=docs+-+latest&message=reference&color=00add8)](https://launchdarkly.github.io/ruby-server-sdk-ai)
9
+
10
+ LaunchDarkly overview
11
+ -------------------------
12
+ [LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
13
+
14
+ [![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
15
+
16
+ Supported Ruby versions
17
+ -----------------------
18
+
19
+ This version of the library has a minimum Ruby version of 3.0.0, or 9.4.0 for JRuby.
20
+
21
+ Getting started
22
+ -----------
23
+
24
+ Install the gem and add to the application's Gemfile by executing:
25
+
26
+ $ bundle add launchdarkly-server-sdk-ai
27
+
28
+ If bundler is not being used to manage dependencies, install the gem by executing:
29
+
30
+ $ gem install launchdarkly-server-sdk-ai
31
+
32
+ The provided AI `Client` can be setup as shown below:
33
+
34
+ ```ruby
35
+ require 'launchdarkly-server-sdk'
36
+ require 'launchdarkly-server-sdk-ai'
37
+
38
+ sdk_key = ENV['LAUNCHDARKLY_SDK_KEY']
39
+ ld_client = LaunchDarkly::LDClient.new(sdk_key)
40
+ ai_client = LaunchDarkly::Server::AI::Client.new(ld_client)
41
+ ```
42
+
4
43
  Learn more
5
44
  -----------
6
45
 
@@ -42,13 +42,26 @@ module LaunchDarkly
42
42
  # The AIConfigTracker class is used to track AI configuration usage.
43
43
  #
44
44
  class AIConfigTracker
45
- attr_reader :ld_client, :config_key, :context, :variation_key, :version, :summary
45
+ attr_reader :ld_client, :config_key, :context, :variation_key, :version, :summary, :model_name, :provider_name
46
46
 
47
- def initialize(ld_client:, variation_key:, config_key:, version:, context:)
47
+ #
48
+ # Initialize a new AIConfigTracker instance.
49
+ #
50
+ # @param ld_client [LDClient] The LaunchDarkly client instance
51
+ # @param variation_key [String] The variation key from the flag evaluation
52
+ # @param config_key [String] The configuration key
53
+ # @param version [Integer] The version number
54
+ # @param model_name [String] The name of the AI model being used
55
+ # @param provider_name [String] The name of the AI provider
56
+ # @param context [LDContext] The context used for the flag evaluation
57
+ #
58
+ def initialize(ld_client:, variation_key:, config_key:, version:, model_name:, provider_name:, context:)
48
59
  @ld_client = ld_client
49
60
  @variation_key = variation_key
50
61
  @config_key = config_key
51
62
  @version = version
63
+ @model_name = model_name
64
+ @provider_name = provider_name
52
65
  @context = context
53
66
  @summary = MetricSummary.new
54
67
  end
@@ -118,12 +131,6 @@ module LaunchDarkly
118
131
  #
119
132
  def track_success
120
133
  @summary.success = true
121
- @ld_client.track(
122
- '$ld:ai:generation',
123
- @context,
124
- flag_data,
125
- 1
126
- )
127
134
  @ld_client.track(
128
135
  '$ld:ai:generation:success',
129
136
  @context,
@@ -137,12 +144,6 @@ module LaunchDarkly
137
144
  #
138
145
  def track_error
139
146
  @summary.success = false
140
- @ld_client.track(
141
- '$ld:ai:generation',
142
- @context,
143
- flag_data,
144
- 1
145
- )
146
147
  @ld_client.track(
147
148
  '$ld:ai:generation:error',
148
149
  @context,
@@ -221,7 +222,13 @@ module LaunchDarkly
221
222
  end
222
223
 
223
224
  private def flag_data
224
- { variationKey: @variation_key, configKey: @config_key, version: @version }
225
+ {
226
+ variationKey: @variation_key,
227
+ configKey: @config_key,
228
+ version: @version,
229
+ modelName: @model_name,
230
+ providerName: @provider_name,
231
+ }
225
232
  end
226
233
 
227
234
  private def openai_to_token_usage(usage)
@@ -102,7 +102,7 @@ module LaunchDarkly
102
102
  # The AIConfig class represents an AI configuration.
103
103
  #
104
104
  class AIConfig
105
- attr_reader :enabled, :messages, :variables, :tracker, :model, :provider
105
+ attr_reader :enabled, :messages, :tracker, :model, :provider
106
106
 
107
107
  def initialize(enabled: nil, model: nil, messages: nil, tracker: nil, provider: nil)
108
108
  @enabled = enabled
@@ -188,6 +188,8 @@ module LaunchDarkly
188
188
  variation_key: variation.dig(:_ldMeta, :variationKey) || '',
189
189
  config_key: config_key,
190
190
  version: variation.dig(:_ldMeta, :version) || 1,
191
+ model_name: model&.name || '',
192
+ provider_name: provider_config&.name || '',
191
193
  context: context
192
194
  )
193
195
 
@@ -3,7 +3,7 @@
3
3
  module LaunchDarkly
4
4
  module Server
5
5
  module AI
6
- VERSION = '0.1.0' # x-release-please-version
6
+ VERSION = '0.2.0' # x-release-please-version
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchdarkly-server-sdk-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.6.7
192
+ rubygems_version: 3.6.9
193
193
  specification_version: 4
194
194
  summary: LaunchDarkly AI SDK for Ruby
195
195
  test_files: []