Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename ModelConfig method to Config #52

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ var aiClient = new LdAiClient(new LdClientAdapter(baseClient));

// Pass in the key of the AI config, a context, and a default value in case the config can't be
// retrieved from LaunchDarkly.
var myModelConfig = aiClient.ModelConfig("my-model-config", Context.New("user-key"), LdAiConfig.Disabled);
var myModelConfig = aiClient.Config("my-model-config", Context.New("user-key"), LdAiConfig.Disabled);
```
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
Loading