Class LdAiClient
The LaunchDarkly AI client. The client is capable of retrieving AI configurations from LaunchDarkly, and generating events specific to usage of the AI configuration when interacting with model providers.
Implements
Inherited Members
Namespace: LaunchDarkly.Sdk.Server.Ai
Assembly: LaunchDarkly.ServerSdk.Ai.dll
Syntax
public sealed class LdAiClient : ILdAiClient
Constructors
| Edit this page View SourceLdAiClient(ILaunchDarklyClient)
Constructs a new LaunchDarkly AI client. Please note, the client library is an alpha release and is not considered ready for production use.
Example:
var baseClient = new LdClient(Configuration.Builder("my-sdk-key").Build());
var aiClient = new LdAiClient(new LdClientAdapter(baseClient));
Declaration
public LdAiClient(ILaunchDarklyClient client)
Parameters
Type | Name | Description |
---|---|---|
ILaunchDarklyClient | client | an object satisfying ILaunchDarklyClient, such as an LdClientAdapter |
Methods
| Edit this page View SourceConfig(string, Context, LdAiConfig, IReadOnlyDictionary<string, object>)
Retrieves a LaunchDarkly AI config identified by the given key. The return value is an ILdAiConfigTracker, which makes the configuration available and provides convenience methods for generating events related to model usage.
Any variables provided will be interpolated into the prompt's messages. Additionally, the current LaunchDarkly context will be available as 'ldctx' within a prompt message.
Declaration
public ILdAiConfigTracker Config(string key, Context context, LdAiConfig defaultValue, IReadOnlyDictionary<string, object> variables = null)
Parameters
Type | Name | Description |
---|---|---|
string | key | the AI config key |
Context | context | the context |
LdAiConfig | defaultValue | the default config, if unable to retrieve from LaunchDarkly |
IReadOnlyDictionary<string, object> | variables | the list of variables used when interpolating the prompt |
Returns
Type | Description |
---|---|
ILdAiConfigTracker | an AI config tracker |