Skip to content

Commit d67431a

Browse files
authored
Add comment LoggingChatClient et al trace-level logging (#6391)
Also fixed the name of the LoggingSpeechToTextClientBuilderExtensions type to conform to patterns used elsewhere in the library.
1 parent 3b9599f commit d67431a

6 files changed

Lines changed: 49 additions & 1 deletion

File tree

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/LoggingChatClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@
1313
namespace Microsoft.Extensions.AI;
1414

1515
/// <summary>A delegating chat client that logs chat operations to an <see cref="ILogger"/>.</summary>
16+
/// <remarks>
1617
/// <para>
1718
/// The provided implementation of <see cref="IChatClient"/> is thread-safe for concurrent use so long as the
1819
/// <see cref="ILogger"/> employed is also thread-safe for concurrent use.
1920
/// </para>
21+
/// <para>
22+
/// When the employed <see cref="ILogger"/> enables <see cref="Logging.LogLevel.Trace"/>, the contents of
23+
/// chat messages and options are logged. These messages and options may contain sensitive application data.
24+
/// <see cref="Logging.LogLevel.Trace"/> is disabled by default and should never be enabled in a production environment.
25+
/// Messages and options are not logged at other logging levels.
26+
/// </para>
27+
/// </remarks>
2028
public partial class LoggingChatClient : DelegatingChatClient
2129
{
2230
/// <summary>An <see cref="ILogger"/> instance used for all logging.</summary>

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/LoggingChatClientBuilderExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public static class LoggingChatClientBuilderExtensions
2121
/// <param name="configure">An optional callback that can be used to configure the <see cref="LoggingChatClient"/> instance.</param>
2222
/// <returns>The <paramref name="builder"/>.</returns>
2323
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
24+
/// <remarks>
25+
/// <para>
26+
/// When the employed <see cref="ILogger"/> enables <see cref="Logging.LogLevel.Trace"/>, the contents of
27+
/// chat messages and options are logged. These messages and options may contain sensitive application data.
28+
/// <see cref="Logging.LogLevel.Trace"/> is disabled by default and should never be enabled in a production environment.
29+
/// Messages and options are not logged at other logging levels.
30+
/// </para>
31+
/// </remarks>
2432
public static ChatClientBuilder UseLogging(
2533
this ChatClientBuilder builder,
2634
ILoggerFactory? loggerFactory = null,

src/Libraries/Microsoft.Extensions.AI/Embeddings/LoggingEmbeddingGenerator.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ namespace Microsoft.Extensions.AI;
1414
/// <summary>A delegating embedding generator that logs embedding generation operations to an <see cref="ILogger"/>.</summary>
1515
/// <typeparam name="TInput">Specifies the type of the input passed to the generator.</typeparam>
1616
/// <typeparam name="TEmbedding">Specifies the type of the embedding instance produced by the generator.</typeparam>
17+
/// <remarks>
1718
/// <para>
1819
/// The provided implementation of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> is thread-safe for concurrent use
1920
/// so long as the <see cref="ILogger"/> employed is also thread-safe for concurrent use.
2021
/// </para>
22+
/// <para>
23+
/// When the employed <see cref="ILogger"/> enables <see cref="Logging.LogLevel.Trace"/>, the contents of
24+
/// values and options are logged. These values and options may contain sensitive application data.
25+
/// <see cref="Logging.LogLevel.Trace"/> is disabled by default and should never be enabled in a production environment.
26+
/// Messages and options are not logged at other logging levels.
27+
/// </para>
28+
/// </remarks>
2129
public partial class LoggingEmbeddingGenerator<TInput, TEmbedding> : DelegatingEmbeddingGenerator<TInput, TEmbedding>
2230
where TEmbedding : Embedding
2331
{

src/Libraries/Microsoft.Extensions.AI/Embeddings/LoggingEmbeddingGeneratorBuilderExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public static class LoggingEmbeddingGeneratorBuilderExtensions
2323
/// <param name="configure">An optional callback that can be used to configure the <see cref="LoggingEmbeddingGenerator{TInput, TEmbedding}"/> instance.</param>
2424
/// <returns>The <paramref name="builder"/>.</returns>
2525
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
26+
/// <remarks>
27+
/// <para>
28+
/// When the employed <see cref="ILogger"/> enables <see cref="Logging.LogLevel.Trace"/>, the contents of
29+
/// values and options are logged. These values and options may contain sensitive application data.
30+
/// <see cref="Logging.LogLevel.Trace"/> is disabled by default and should never be enabled in a production environment.
31+
/// Messages and options are not logged at other logging levels.
32+
/// </para>
33+
/// </remarks>
2634
public static EmbeddingGeneratorBuilder<TInput, TEmbedding> UseLogging<TInput, TEmbedding>(
2735
this EmbeddingGeneratorBuilder<TInput, TEmbedding> builder,
2836
ILoggerFactory? loggerFactory = null,

src/Libraries/Microsoft.Extensions.AI/SpeechToText/LoggingSpeechToTextClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@
1515
namespace Microsoft.Extensions.AI;
1616

1717
/// <summary>A delegating speech to text client that logs speech to text operations to an <see cref="ILogger"/>.</summary>
18+
/// <remarks>
1819
/// <para>
1920
/// The provided implementation of <see cref="ISpeechToTextClient"/> is thread-safe for concurrent use so long as the
2021
/// <see cref="ILogger"/> employed is also thread-safe for concurrent use.
2122
/// </para>
23+
/// <para>
24+
/// When the employed <see cref="ILogger"/> enables <see cref="Logging.LogLevel.Trace"/>, the contents of
25+
/// messages and options are logged. These messages and options may contain sensitive application data.
26+
/// <see cref="Logging.LogLevel.Trace"/> is disabled by default and should never be enabled in a production environment.
27+
/// Messages and options are not logged at other logging levels.
28+
/// </para>
29+
/// </remarks>
2230
[Experimental("MEAI001")]
2331
public partial class LoggingSpeechToTextClient : DelegatingSpeechToTextClient
2432
{

src/Libraries/Microsoft.Extensions.AI/SpeechToText/SpeechToTextClientBuilderExtensions.cs renamed to src/Libraries/Microsoft.Extensions.AI/SpeechToText/LoggingSpeechToTextClientBuilderExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.Extensions.AI;
1212

1313
/// <summary>Provides extensions for configuring <see cref="LoggingSpeechToTextClient"/> instances.</summary>
1414
[Experimental("MEAI001")]
15-
public static class SpeechToTextClientBuilderExtensions
15+
public static class LoggingSpeechToTextClientBuilderExtensions
1616
{
1717
/// <summary>Adds logging to the audio transcription client pipeline.</summary>
1818
/// <param name="builder">The <see cref="SpeechToTextClientBuilder"/>.</param>
@@ -22,6 +22,14 @@ public static class SpeechToTextClientBuilderExtensions
2222
/// </param>
2323
/// <param name="configure">An optional callback that can be used to configure the <see cref="LoggingSpeechToTextClient"/> instance.</param>
2424
/// <returns>The <paramref name="builder"/>.</returns>
25+
/// <remarks>
26+
/// <para>
27+
/// When the employed <see cref="ILogger"/> enables <see cref="Logging.LogLevel.Trace"/>, the contents of
28+
/// messages and options are logged. These messages and options may contain sensitive application data.
29+
/// <see cref="Logging.LogLevel.Trace"/> is disabled by default and should never be enabled in a production environment.
30+
/// Messages and options are not logged at other logging levels.
31+
/// </para>
32+
/// </remarks>
2533
public static SpeechToTextClientBuilder UseLogging(
2634
this SpeechToTextClientBuilder builder,
2735
ILoggerFactory? loggerFactory = null,

0 commit comments

Comments
 (0)