< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Evaluation.EvaluationCaptureChatClientExtensions
Assembly: NexusLabs.Needlr.AgentFramework.Evaluation
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Evaluation/EvaluationCaptureChatClientExtensions.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 47
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
WithEvaluationCapture(...)100%11100%
WithEvaluationCapture(...)100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Evaluation/EvaluationCaptureChatClientExtensions.cs

#LineLine coverage
 1using Microsoft.Extensions.AI;
 2
 3namespace NexusLabs.Needlr.AgentFramework.Evaluation;
 4
 5/// <summary>
 6/// Extension methods for opting in to <see cref="EvaluationCaptureChatClient"/>
 7/// capture/replay behavior.
 8/// </summary>
 9public static class EvaluationCaptureChatClientExtensions
 10{
 11    /// <summary>
 12    /// Wraps <paramref name="innerClient"/> with an
 13    /// <see cref="EvaluationCaptureChatClient"/> backed by
 14    /// <paramref name="store"/>.
 15    /// </summary>
 16    /// <param name="innerClient">The chat client to delegate cache-miss calls to.</param>
 17    /// <param name="store">Backing store for captured responses.</param>
 18    /// <returns>A new <see cref="IChatClient"/> that captures and replays responses.</returns>
 19    public static IChatClient WithEvaluationCapture(
 20        this IChatClient innerClient,
 21        IEvaluationCaptureStore store)
 22    {
 323        ArgumentNullException.ThrowIfNull(innerClient);
 224        ArgumentNullException.ThrowIfNull(store);
 125        return new EvaluationCaptureChatClient(innerClient, store);
 26    }
 27
 28    /// <summary>
 29    /// Wraps <paramref name="innerClient"/> with an
 30    /// <see cref="EvaluationCaptureChatClient"/> backed by a
 31    /// <see cref="FileEvaluationCaptureStore"/> rooted at
 32    /// <paramref name="cacheDirectory"/>.
 33    /// </summary>
 34    /// <param name="innerClient">The chat client to delegate cache-miss calls to.</param>
 35    /// <param name="cacheDirectory">Directory used to persist captured responses.</param>
 36    /// <returns>A new <see cref="IChatClient"/> that captures and replays responses.</returns>
 37    public static IChatClient WithEvaluationCapture(
 38        this IChatClient innerClient,
 39        string cacheDirectory)
 40    {
 541        ArgumentNullException.ThrowIfNull(innerClient);
 442        ArgumentException.ThrowIfNullOrWhiteSpace(cacheDirectory);
 143        return new EvaluationCaptureChatClient(
 144            innerClient,
 145            new FileEvaluationCaptureStore(cacheDirectory));
 46    }
 47}