66namespace LaunchDarkly . Sdk . Server . Ai . Interfaces ;
77
88/// <summary>
9- /// Represents the interface of the AI Config Tracker, useful for mocking.
9+ /// A utility capable of generating events related to a specific AI model
10+ /// configuration.
1011/// </summary>
1112public interface ILdAiConfigTracker
1213{
1314 /// <summary>
14- /// The retrieved AI model configuration.
15+ /// The AI model configuration retrieved from LaunchDarkly, or a default value if unable to retrieve .
1516 /// </summary>
1617 public LdAiConfig Config { get ; }
1718
1819 /// <summary>
19- /// Tracks a duration metric related to this config.
20+ /// Tracks a duration metric related to this config. For example, if a particular operation
21+ /// related to usage of the AI model takes 100ms, this can be tracked and made available in
22+ /// LaunchDarkly.
2023 /// </summary>
2124 /// <param name="durationMs">the duration in milliseconds</param>
2225 public void TrackDuration ( float durationMs ) ;
2326
2427 /// <summary>
2528 /// Tracks the duration of a task, and returns the result of the task.
29+ ///
2630 /// </summary>
2731 /// <param name="task">the task</param>
2832 /// <typeparam name="T">type of the task's result</typeparam>
@@ -44,6 +48,24 @@ public interface ILdAiConfigTracker
4448 /// <summary>
4549 /// Tracks a request to a provider. The request is a task that returns a <see cref="Response"/>, which
4650 /// contains information about the request such as token usage and metrics.
51+ ///
52+ /// It is the responsibility of the caller to fill in the <see cref="Response"/> object with any details
53+ /// that should be tracked.
54+ ///
55+ /// Example:
56+ /// <code>
57+ /// var response = tracker.TrackRequest(Task.Run(() => new Response {
58+ /// // 1. Make a request to the AI provider
59+ /// // 2. Identify relevant statistics returned in the response
60+ /// // 3. Return a Response object containing the relevant statistics
61+ /// Usage = new Usage { Total = 1, Input = 1, Output = 1 },
62+ /// Metrics = new Metrics { LatencyMs = 100 }
63+ /// }));
64+ /// </code>
65+ ///
66+ /// If no latency statistic is explicitly returned in the <see cref="Response"/>, then the duration of the
67+ /// Task is automatically measured and recorded as the latency metric associated with this request.
68+ ///
4769 /// </summary>
4870 /// <param name="request">a task representing the request</param>
4971 /// <returns>the task</returns>
@@ -52,6 +74,6 @@ public interface ILdAiConfigTracker
5274 /// <summary>
5375 /// Tracks token usage related to this config.
5476 /// </summary>
55- /// <param name="usage">the usage</param>
77+ /// <param name="usage">the token usage</param>
5678 public void TrackTokens ( Usage usage ) ;
5779}
0 commit comments