| | | 1 | | using Microsoft.Extensions.AI; |
| | | 2 | | |
| | | 3 | | namespace NexusLabs.Needlr.AgentFramework.Workflows.Middleware; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Extension methods for adding transcript logging to a <see cref="ChatClientBuilder"/> pipeline. |
| | | 7 | | /// </summary> |
| | | 8 | | public static class ChatClientBuilderTranscriptExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Inserts a <see cref="TranscriptLoggingChatClient"/> into the pipeline that |
| | | 12 | | /// records every request/response pair to the supplied <paramref name="writer"/>. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="builder">The chat client builder.</param> |
| | | 15 | | /// <param name="writer">The transcript writer to record entries into.</param> |
| | | 16 | | /// <returns>The builder, for chaining.</returns> |
| | | 17 | | public static ChatClientBuilder UseTranscriptLogging( |
| | | 18 | | this ChatClientBuilder builder, |
| | | 19 | | ITranscriptWriter writer) |
| | | 20 | | { |
| | 1 | 21 | | ArgumentNullException.ThrowIfNull(builder); |
| | 1 | 22 | | ArgumentNullException.ThrowIfNull(writer); |
| | | 23 | | |
| | 2 | 24 | | return builder.Use(inner => new TranscriptLoggingChatClient(inner, writer)); |
| | | 25 | | } |
| | | 26 | | } |