Interface ILdAiClient
Represents the interface of the AI client, useful for mocking.
Namespace: LaunchDarkly.Sdk.Server.Ai.Interfaces
Assembly: LaunchDarkly.ServerSdk.Ai.dll
Syntax
public interface ILdAiClient
Methods
| Edit this page View SourceAgentConfig(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
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 |
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
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 |
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
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 |
Config(string, Context, LdAiCompletionConfigDefault, IReadOnlyDictionary<string, object>)
Retrieves a LaunchDarkly AI Completion Config identified by the given key.
Declaration
[Obsolete("Use CompletionConfig instead.")]
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 |
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
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 |
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
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 |