LaunchDarkly Dotnet Server AI SDK
Search Results for

    Show / Hide Table of Contents

    Class LdAiClient

    The LaunchDarkly AI client. The client is capable of retrieving AI Configs from LaunchDarkly, and generating events specific to usage of the AI Config when interacting with model providers.

    Inheritance
    object
    LdAiClient
    Implements
    ILdAiClient
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: LaunchDarkly.Sdk.Server.Ai
    Assembly: LaunchDarkly.ServerSdk.Ai.dll
    Syntax
    public sealed class LdAiClient : ILdAiClient

    Constructors

    | Edit this page View Source

    LdAiClient(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 Source

    AgentConfig(string, Context, LdAiAgentConfigDefault, IReadOnlyDictionary<string, object>)

    Retrieves a LaunchDarkly AI Agent Config identified by the given key. The return value is an LdAiAgentConfig, which provides Instructions, Tools, and a CreateTracker method for generating a tracker that emits model usage events.

    Any variables provided will be interpolated into the agent's instructions. Additionally, the current LaunchDarkly context will be available as 'ldctx' within the instructions template.

    Declaration
    public LdAiAgentConfig AgentConfig(string key, Context context, LdAiAgentConfigDefault defaultValue = null, IReadOnlyDictionary<string, object> variables = null)
    Parameters
    Type Name Description
    string key

    the AI Agent Config key

    Context context

    the context

    LdAiAgentConfigDefault defaultValue

    the default config, if unable to retrieve from LaunchDarkly. When not provided, a disabled config is used as the fallback.

    IReadOnlyDictionary<string, object> variables

    the list of variables used when interpolating the instructions

    Returns
    Type Description
    LdAiAgentConfig

    an AI Agent Config

    | Edit this page View Source

    AgentConfigs(IEnumerable<AgentConfigRequest>, Context)

    Retrieves multiple LaunchDarkly AI Agent Configs in a single call. Each request is evaluated independently. A single aggregate usage event is fired for the entire batch.

    Declaration
    public IReadOnlyDictionary<string, LdAiAgentConfig> AgentConfigs(IEnumerable<AgentConfigRequest> agentConfigs, Context context)
    Parameters
    Type Name Description
    IEnumerable<AgentConfigRequest> agentConfigs

    the collection of agent config requests

    Context context

    the context

    Returns
    Type Description
    IReadOnlyDictionary<string, LdAiAgentConfig>

    a dictionary mapping each agent config key to its evaluated LdAiAgentConfig

    | Edit this page View Source

    CompletionConfig(string, Context, LdAiCompletionConfigDefault, IReadOnlyDictionary<string, object>)

    Retrieves a LaunchDarkly AI Completion Config identified by the given key. The return value is an LdAiCompletionConfig, which makes the configuration available and provides a CreateTracker method (inherited from LdAiConfig) for generating a tracker that emits 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 LdAiCompletionConfig CompletionConfig(string key, Context context, LdAiCompletionConfigDefault defaultValue = null, IReadOnlyDictionary<string, object> variables = null)
    Parameters
    Type Name Description
    string key

    the AI Completion Config key

    Context context

    the context

    LdAiCompletionConfigDefault defaultValue

    the default config, if unable to retrieve from LaunchDarkly. When not provided, a disabled config is used as the fallback.

    IReadOnlyDictionary<string, object> variables

    the list of variables used when interpolating the prompt

    Returns
    Type Description
    LdAiCompletionConfig

    an AI Completion Config

    | Edit this page View Source

    Config(string, Context, LdAiCompletionConfigDefault, IReadOnlyDictionary<string, object>)

    Retrieves a LaunchDarkly AI Completion Config identified by the given key.

    Declaration
    [Obsolete("Use CompletionConfig instead.")]
    public LdAiCompletionConfig Config(string key, Context context, LdAiCompletionConfigDefault defaultValue = null, IReadOnlyDictionary<string, object> variables = null)
    Parameters
    Type Name Description
    string key

    the AI Completion Config key

    Context context

    the context

    LdAiCompletionConfigDefault 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
    LdAiCompletionConfig

    an AI Completion Config

    | Edit this page View Source

    CreateTracker(string, Context)

    Reconstructs a tracker from a resumption token. This enables cross-process scenarios such as deferred feedback, where a tracker's runId needs to be reused in a different process or at a later time.

    The reconstructed tracker will have empty model and provider names, as these are not included in the resumption token.

    Declaration
    public ILdAiConfigTracker CreateTracker(string resumptionToken, Context context)
    Parameters
    Type Name Description
    string resumptionToken

    the resumption token obtained from ResumptionToken

    Context context

    the context to use for track events

    Returns
    Type Description
    ILdAiConfigTracker

    a tracker associated with the original runId

    | Edit this page View Source

    JudgeConfig(string, Context, LdAiJudgeConfigDefault, IReadOnlyDictionary<string, object>)

    Retrieves a LaunchDarkly AI Judge Config identified by the given key. The return value is an LdAiJudgeConfig, which provides Messages, EvaluationMetricKey, and a CreateTracker method for generating a tracker that emits model usage events.

    Any variables provided will be interpolated into the judge's prompt messages. Additionally, the current LaunchDarkly context will be available as 'ldctx' within the message templates.

    Declaration
    public LdAiJudgeConfig JudgeConfig(string key, Context context, LdAiJudgeConfigDefault defaultValue = null, IReadOnlyDictionary<string, object> variables = null)
    Parameters
    Type Name Description
    string key

    the AI Judge Config key

    Context context

    the context

    LdAiJudgeConfigDefault defaultValue

    the default config, if unable to retrieve from LaunchDarkly. When not provided, a disabled config is used as the fallback.

    IReadOnlyDictionary<string, object> variables

    the list of variables used when interpolating the messages

    Returns
    Type Description
    LdAiJudgeConfig

    an AI Judge Config

    Implements

    ILdAiClient

    Extension Methods

    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX