Skip to content

Commit 7531228

Browse files
atornsiiclaude
andcommitted
Read modelKey/modelVersion from _ldMeta, matching gonfalon PR 67230
Gonfalon moved these two fields from the payload's model object to _ldMeta (launchdarkly/gonfalon#67230) to avoid modelVersion reading as the underlying LLM's own version. Field names are unchanged; only the JSON location moves. ModelConfig's public accessors and the tracker's stamped event fields are untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent e6ae12d commit 7531228

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

lib/server/ai/client.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,15 @@ def _completion_config(key:, context:, default:, variables: nil)
285285
provider_config = ProviderConfig.new(provider_config.fetch(:name, ''))
286286
end
287287

288-
tracked_model_version = 1
288+
tracked_model_version = (variation.dig(:_ldMeta, :modelVersion) || 1).to_i
289289
if (model = variation[:model]) && model.is_a?(Hash)
290290
parameters = variation[:model][:parameters]
291291
custom = variation[:model][:custom]
292-
tracked_model_version = (variation[:model][:modelVersion] || 1).to_i
293292
model = ModelConfig.new(
294293
name: variation[:model][:name],
295294
parameters: parameters,
296295
custom: custom,
297-
model_key: variation[:model][:modelKey],
296+
model_key: variation.dig(:_ldMeta, :modelKey),
298297
model_version: tracked_model_version
299298
)
300299
end

spec/server/ai/client_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@
9393
{
9494
model: {
9595
name: 'gpt-4',
96-
modelKey: 'my-model',
97-
modelVersion: 2,
9896
},
9997
provider: { name: 'openai' },
10098
messages: [],
101-
_ldMeta: { enabled: true, variationKey: 'v1', version: 1 },
99+
_ldMeta: { enabled: true, variationKey: 'v1', version: 1, modelKey: 'my-model', modelVersion: 2 },
102100
}
103101
)
104102
.variation_for_all(0))
@@ -487,10 +485,10 @@
487485
td.update(td.flag('model-config-version-only')
488486
.variations(
489487
{
490-
model: { name: 'gpt-4', modelVersion: 3 },
488+
model: { name: 'gpt-4' },
491489
provider: { name: 'openai' },
492490
messages: [],
493-
_ldMeta: { enabled: true, variationKey: 'v1', version: 1 },
491+
_ldMeta: { enabled: true, variationKey: 'v1', version: 1, modelVersion: 3 },
494492
}
495493
)
496494
.variation_for_all(0))

0 commit comments

Comments
 (0)