Skip to content

Commit

Permalink
fix: rename ModelConfig method to Config
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Nov 22, 2024
1 parent 3541236 commit 6f65972
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkgs/sdk/server-ai/src/Config/LdAiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal ModelConfiguration(string id, IReadOnlyDictionary<string, LdValue> para

/// <summary>
/// Builder for constructing an LdAiConfig instance, which can be passed as the default
/// value to the AI Client's <see cref="LdAiClient.ModelConfig"/> method.
/// value to the AI Client's <see cref="LdAiClient.Config"/> method.
/// </summary>
public class Builder
{
Expand Down
2 changes: 1 addition & 1 deletion pkgs/sdk/server-ai/src/Interfaces/ILdAiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public interface ILdAiClient
/// <param name="defaultValue">the default config, if unable to retrieve from LaunchDarkly</param>
/// <param name="variables">the list of variables used when interpolating the prompt</param>
/// <returns>an AI config tracker</returns>
public ILdAiConfigTracker ModelConfig(string key, Context context, LdAiConfig defaultValue,
public ILdAiConfigTracker Config(string key, Context context, LdAiConfig defaultValue,
IReadOnlyDictionary<string, object> variables = null);
}
2 changes: 1 addition & 1 deletion pkgs/sdk/server-ai/src/LdAiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public LdAiClient(ILaunchDarklyClient client)
private const string LdContextVariable = "ldctx";

/// <inheritdoc/>
public ILdAiConfigTracker ModelConfig(string key, Context context, LdAiConfig defaultValue,
public ILdAiConfigTracker Config(string key, Context context, LdAiConfig defaultValue,
IReadOnlyDictionary<string, object> variables = null)
{

Expand Down
4 changes: 2 additions & 2 deletions pkgs/sdk/server-ai/test/InterpolationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private string Eval(string prompt, Context context, IReadOnlyDictionary<string,
mockClient.Setup(x => x.GetLogger()).Returns(mockLogger.Object);

var client = new LdAiClient(mockClient.Object);
var tracker = client.ModelConfig("foo", context, LdAiConfig.Disabled, variables);
var tracker = client.Config("foo", context, LdAiConfig.Disabled, variables);

return tracker.Config.Messages[0].Content;
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public void TestInterpolationMalformed()
mockLogger.Setup(x => x.Error(It.IsAny<string>()));

var client = new LdAiClient(mockClient.Object);
var tracker = client.ModelConfig("foo", Context.New("key"), LdAiConfig.Disabled);
var tracker = client.Config("foo", Context.New("key"), LdAiConfig.Disabled);
Assert.False(tracker.Config.Enabled);
}

Expand Down
14 changes: 7 additions & 7 deletions pkgs/sdk/server-ai/test/LdAiClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void CanInstantiateWithServerSideClient()
{
var client = new LdClientAdapter(new LdClient(Configuration.Builder("key").Offline(true).Build()));
var aiClient = new LdAiClient(client);
var result= aiClient.ModelConfig("foo", Context.New("key"), LdAiConfig.Disabled);
var result= aiClient.Config("foo", Context.New("key"), LdAiConfig.Disabled);
Assert.False(result.Config.Enabled);
}

Expand Down Expand Up @@ -44,7 +44,7 @@ public void ReturnsDefaultConfigWhenGivenInvalidVariation()

var defaultConfig = LdAiConfig.New().AddMessage("Hello").Build();

var tracker = client.ModelConfig("foo", Context.New(ContextKind.Default, "key"), defaultConfig);
var tracker = client.Config("foo", Context.New(ContextKind.Default, "key"), defaultConfig);

Assert.Equal(defaultConfig, tracker.Config);
}
Expand Down Expand Up @@ -95,7 +95,7 @@ public void ConfigNotEnabledReturnsDisabledInstance(string json)
// All the JSON inputs here are considered disabled, either due to lack of the 'enabled' property,
// or if present, it is set to false. Therefore, if the default was returned, we'd see the assertion fail
// (since calling LdAiConfig.New() constructs an enabled config by default.)
var tracker = client.ModelConfig("foo", Context.New(ContextKind.Default, "key"),
var tracker = client.Config("foo", Context.New(ContextKind.Default, "key"),
LdAiConfig.New().AddMessage("foo").Build());

Assert.False(tracker.Config.Enabled);
Expand All @@ -115,7 +115,7 @@ public void CanSetAllDefaultValueFields()

var client = new LdAiClient(mockClient.Object);

var tracker = client.ModelConfig("foo", Context.New(ContextKind.Default, "key"),
var tracker = client.Config("foo", Context.New(ContextKind.Default, "key"),
LdAiConfig.New().
AddMessage("foo").
SetModelParam("foo", LdValue.Of("bar")).
Expand Down Expand Up @@ -158,7 +158,7 @@ public void ConfigEnabledReturnsInstance()
var client = new LdAiClient(mockClient.Object);

// We shouldn't get this default.
var tracker = client.ModelConfig("foo", context,
var tracker = client.Config("foo", context,
LdAiConfig.New().AddMessage("Goodbye!").Build());

Assert.Collection(tracker.Config.Messages,
Expand Down Expand Up @@ -210,7 +210,7 @@ public void ModelParametersAreParsed()
var client = new LdAiClient(mockClient.Object);

// We shouldn't get this default.
var tracker = client.ModelConfig("foo", context,
var tracker = client.Config("foo", context,
LdAiConfig.New().AddMessage("Goodbye!").Build());

Assert.Equal("model-foo", tracker.Config.Model.Id);
Expand Down Expand Up @@ -247,7 +247,7 @@ public void ProviderConfigIsParsed()
var client = new LdAiClient(mockClient.Object);

// We shouldn't get this default.
var tracker = client.ModelConfig("foo", context,
var tracker = client.Config("foo", context,
LdAiConfig.New().AddMessage("Goodbye!").Build());

Assert.Equal("amazing-provider", tracker.Config.Provider.Id);
Expand Down

0 comments on commit 6f65972

Please sign in to comment.