Skip to content

Commit 3f7089d

Browse files
authored
refactor!: rename _ldMeta.versionKey to variationKey (#62)
This renames `_ldMeta.versionKey` field to `variationKey` following the latest spec changes.
1 parent 562a2c6 commit 3f7089d

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

pkgs/sdk/server-ai/src/Config/LdAiConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ internal LdAiConfig(bool enabled, IEnumerable<Message> messages, Meta meta, Mode
222222
Model = new ModelConfiguration(model?.Id ?? "", model?.Parameters ?? new Dictionary<string, LdValue>(),
223223
model?.Custom ?? new Dictionary<string, LdValue>());
224224
Messages = messages?.ToList() ?? new List<Message>();
225-
VersionKey = meta?.VersionKey ?? "";
225+
VariationKey = meta?.VariationKey ?? "";
226226
Enabled = enabled;
227227
Provider = new ModelProvider(provider?.Id ?? "");
228228
}
@@ -233,7 +233,7 @@ internal LdValue ToLdValue()
233233
{ "_ldMeta", LdValue.ObjectFrom(
234234
new Dictionary<string, LdValue>
235235
{
236-
{ "versionKey", LdValue.Of(VersionKey) },
236+
{ "variationKey", LdValue.Of(VariationKey) },
237237
{ "enabled", LdValue.Of(Enabled) }
238238
}) },
239239
{ "messages", LdValue.ArrayFrom(Messages.Select(m => LdValue.ObjectFrom(new Dictionary<string, LdValue>
@@ -269,7 +269,7 @@ internal LdValue ToLdValue()
269269
/// <summary>
270270
/// This field meant for internal LaunchDarkly usage.
271271
/// </summary>
272-
public string VersionKey { get; }
272+
public string VariationKey { get; }
273273

274274
/// <summary>
275275
/// Convenient helper that returns a disabled LdAiConfig.

pkgs/sdk/server-ai/src/DataModel/DataModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public enum Role
2828
public class Meta
2929
{
3030
/// <summary>
31-
/// The version key.
31+
/// The variation key.
3232
/// </summary>
33-
[JsonPropertyName("versionKey")]
34-
public string VersionKey { get; set; }
33+
[JsonPropertyName("variationKey")]
34+
public string VariationKey { get; set; }
3535

3636
/// <summary>
3737
/// If the config is enabled.

pkgs/sdk/server-ai/src/LdAiConfigTracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public LdAiConfigTracker(ILaunchDarklyClient client, string configKey, LdAiConfi
4141
_context = context;
4242
_trackData = LdValue.ObjectFrom(new Dictionary<string, LdValue>
4343
{
44-
{ "versionKey", LdValue.Of(Config.VersionKey)},
44+
{ "variationKey", LdValue.Of(config.VariationKey)},
4545
{ "configKey" , LdValue.Of(configKey ?? throw new ArgumentNullException(nameof(configKey))) }
4646
});
4747
}

pkgs/sdk/server-ai/test/InterpolationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private string Eval(string prompt, Context context, IReadOnlyDictionary<string,
2121
// The replacement is done this way because to use string.Format, we'd need to escape the curly braces.
2222
var configJson = """
2323
{
24-
"_ldMeta": {"versionKey": "1", "enabled": true},
24+
"_ldMeta": {"variationKey": "1", "enabled": true},
2525
"model": {},
2626
"messages": [
2727
{
@@ -126,7 +126,7 @@ public void TestInterpolationMalformed()
126126

127127
const string configJson = """
128128
{
129-
"_ldMeta": {"versionKey": "1", "enabled": true},
129+
"_ldMeta": {"variationKey": "1", "enabled": true},
130130
"model": {},
131131
"messages": [
132132
{

pkgs/sdk/server-ai/test/LdAiClientTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public void ReturnsDefaultConfigWhenGivenInvalidVariation()
5151

5252
private const string MetaDisabledExplicitly = """
5353
{
54-
"_ldMeta": {"versionKey": "1", "enabled": false},
54+
"_ldMeta": {"variationKey": "1", "enabled": false},
5555
"model": {},
5656
"messages": []
5757
}
5858
""";
5959

6060
private const string MetaDisabledImplicitly = """
6161
{
62-
"_ldMeta": {"versionKey": "1"},
62+
"_ldMeta": {"variationKey": "1"},
6363
"model": {},
6464
"messages": []
6565
}
@@ -146,7 +146,7 @@ public void ConfigEnabledReturnsInstance()
146146

147147
const string json = """
148148
{
149-
"_ldMeta": {"versionKey": "1", "enabled": true},
149+
"_ldMeta": {"variationKey": "1", "enabled": true},
150150
"messages": [{"content": "Hello!", "role": "system"}]
151151
}
152152
""";
@@ -187,7 +187,7 @@ public void ModelParametersAreParsed()
187187

188188
const string json = """
189189
{
190-
"_ldMeta": {"versionKey": "1", "enabled": true},
190+
"_ldMeta": {"variationKey": "1", "enabled": true},
191191
"model" : {
192192
"id": "model-foo",
193193
"parameters": {
@@ -232,7 +232,7 @@ public void ProviderConfigIsParsed()
232232

233233
const string json = """
234234
{
235-
"_ldMeta": {"versionKey": "1", "enabled": true},
235+
"_ldMeta": {"variationKey": "1", "enabled": true},
236236
"provider": {
237237
"id": "amazing-provider"
238238
}

pkgs/sdk/server-ai/test/LdAiConfigTrackerTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void CanTrackDuration()
4242
var config = LdAiConfig.Disabled;
4343
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
4444
{
45-
{ "versionKey", LdValue.Of(config.VersionKey) },
45+
{ "variationKey", LdValue.Of(config.VariationKey) },
4646
{ "configKey", LdValue.Of(flagKey) }
4747
});
4848
var tracker = new LdAiConfigTracker(mockClient.Object, flagKey, config, context);
@@ -61,7 +61,7 @@ public void CanTrackSuccess()
6161
var config = LdAiConfig.Disabled;
6262
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
6363
{
64-
{ "versionKey", LdValue.Of(config.VersionKey) },
64+
{ "variationKey", LdValue.Of(config.VariationKey) },
6565
{ "configKey", LdValue.Of(flagKey) }
6666
});
6767

@@ -80,7 +80,7 @@ public async void CanTrackDurationOfTask()
8080
var config = LdAiConfig.Disabled;
8181
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
8282
{
83-
{ "versionKey", LdValue.Of(config.VersionKey) },
83+
{ "variationKey", LdValue.Of(config.VariationKey) },
8484
{ "configKey", LdValue.Of(flagKey) }
8585
});
8686

@@ -114,7 +114,7 @@ public void CanTrackFeedback()
114114
var config = LdAiConfig.Disabled;
115115
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
116116
{
117-
{ "versionKey", LdValue.Of(config.VersionKey) },
117+
{ "variationKey", LdValue.Of(config.VariationKey) },
118118
{ "configKey", LdValue.Of(flagKey) }
119119
});
120120

@@ -135,7 +135,7 @@ public void CanTrackTokens()
135135
var config = LdAiConfig.Disabled;
136136
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
137137
{
138-
{ "versionKey", LdValue.Of(config.VersionKey) },
138+
{ "variationKey", LdValue.Of(config.VariationKey) },
139139
{ "configKey", LdValue.Of(flagKey) }
140140
});
141141

@@ -163,7 +163,7 @@ public void CanTrackResponseWithSpecificLatency()
163163
var config = LdAiConfig.Disabled;
164164
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
165165
{
166-
{ "versionKey", LdValue.Of(config.VersionKey) },
166+
{ "variationKey", LdValue.Of(config.VariationKey) },
167167
{ "configKey", LdValue.Of(flagKey) }
168168
});
169169

@@ -204,7 +204,7 @@ public void CanTrackResponseWithPartialData()
204204
var config = LdAiConfig.Disabled;
205205
var data = LdValue.ObjectFrom(new Dictionary<string, LdValue>
206206
{
207-
{ "versionKey", LdValue.Of(config.VersionKey) },
207+
{ "variationKey", LdValue.Of(config.VariationKey) },
208208
{ "configKey", LdValue.Of(flagKey) }
209209
});
210210

0 commit comments

Comments
 (0)