Skip to content

Commit 2b6ca6b

Browse files
committed
Ad comments
1 parent 780de97 commit 2b6ca6b

24 files changed

+69
-0
lines changed

ChatAIze.GenerativeCS/Clients/GeminiClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class GeminiClient<TChat, TMessage, TFunctionCall, TFunctionResult>
2323
{
2424
private readonly HttpClient _httpClient = new()
2525
{
26+
// Long timeout to accommodate streaming and large uploads.
2627
Timeout = TimeSpan.FromMinutes(15)
2728
};
2829

@@ -31,6 +32,7 @@ public class GeminiClient<TChat, TMessage, TFunctionCall, TFunctionResult>
3132
/// </summary>
3233
public GeminiClient()
3334
{
35+
// Allow environment variables to supply credentials when no explicit API key is provided.
3436
if (string.IsNullOrWhiteSpace(ApiKey))
3537
{
3638
ApiKey = EnvironmentVariableManager.GetGeminiAPIKey();

ChatAIze.GenerativeCS/Clients/OpenAIClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class OpenAIClient<TChat, TMessage, TFunctionCall, TFunctionResult>
2424
{
2525
private readonly HttpClient _httpClient = new()
2626
{
27+
// Long timeout to accommodate streaming and large uploads.
2728
Timeout = TimeSpan.FromMinutes(15)
2829
};
2930

@@ -32,6 +33,7 @@ public class OpenAIClient<TChat, TMessage, TFunctionCall, TFunctionResult>
3233
/// </summary>
3334
public OpenAIClient()
3435
{
36+
// Allow environment variables to supply credentials when no explicit API key is provided.
3537
if (string.IsNullOrWhiteSpace(ApiKey))
3638
{
3739
ApiKey = EnvironmentVariableManager.GetOpenAIAPIKey();

ChatAIze.GenerativeCS/Constants/DefaultModels.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ public static class OpenAI
1313
/// <summary>
1414
/// Default chat completion model.
1515
/// </summary>
16+
/// <remarks>Used when callers omit a model identifier to favor a generally capable, up-to-date model.</remarks>
1617
public const string ChatCompletion = ChatCompletionModels.OpenAI.GPT51;
1718

1819
/// <summary>
1920
/// Default embedding model.
2021
/// </summary>
22+
/// <remarks>Balances cost and quality for general-purpose embeddings.</remarks>
2123
public const string Embedding = EmbeddingModels.OpenAI.TextEmbedding3Small;
2224

2325
/// <summary>
2426
/// Default text-to-speech model.
2527
/// </summary>
28+
/// <remarks>Chosen for latency and voice quality in typical scenarios.</remarks>
2629
public const string TextToSpeech = TextToSpeechModels.OpenAI.GPT4oMiniTTS;
2730

2831
/// <summary>

ChatAIze.GenerativeCS/Models/Chat.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public ValueTask<TMessage> FromSystemAsync(string message, PinLocation pinLocati
7777
/// <param name="pinLocation">Optional pin location for message ordering.</param>
7878
public async void FromSystem(string message, PinLocation pinLocation = PinLocation.None)
7979
{
80+
// Intentional fire-and-forget wrapper to keep API ergonomic for callers that don't await.
8081
_ = await FromSystemAsync(message, pinLocation);
8182
}
8283

@@ -109,6 +110,7 @@ public ValueTask<TMessage> FromUserAsync(string message, PinLocation pinLocation
109110
/// <param name="imageUrls">Optional set of image URLs attached to the message.</param>
110111
public async void FromUser(string message, PinLocation pinLocation = PinLocation.None, params ICollection<string> imageUrls)
111112
{
113+
// Intentional fire-and-forget wrapper to keep API ergonomic for callers that don't await.
112114
_ = await FromUserAsync(message, pinLocation, imageUrls);
113115
}
114116

@@ -144,6 +146,7 @@ public ValueTask<TMessage> FromUserAsync(string userName, string message, PinLoc
144146
/// <param name="imageUrls">Optional set of image URLs attached to the message.</param>
145147
public async void FromUser(string userName, string message, PinLocation pinLocation = PinLocation.None, params ICollection<string> imageUrls)
146148
{
149+
// Intentional fire-and-forget wrapper to keep API ergonomic for callers that don't await.
147150
_ = await FromUserAsync(userName, message, pinLocation, imageUrls);
148151
}
149152

@@ -173,6 +176,7 @@ public ValueTask<TMessage> FromChatbotAsync(string message, PinLocation pinLocat
173176
/// <param name="pinLocation">Optional pin location for message ordering.</param>
174177
public async void FromChatbot(string message, PinLocation pinLocation = PinLocation.None)
175178
{
179+
// Intentional fire-and-forget wrapper to keep API ergonomic for callers that don't await.
176180
_ = await FromChatbotAsync(message, pinLocation);
177181
}
178182

@@ -202,6 +206,7 @@ public ValueTask<TMessage> FromChatbotAsync(TFunctionCall functionCall, PinLocat
202206
/// <param name="pinLocation">Optional pin location for message ordering.</param>
203207
public async void FromChatbot(TFunctionCall functionCall, PinLocation pinLocation = PinLocation.None)
204208
{
209+
// Intentional fire-and-forget wrapper to keep API ergonomic for callers that don't await.
205210
_ = await FromChatbotAsync(functionCall, pinLocation);
206211
}
207212

@@ -231,6 +236,7 @@ public ValueTask<TMessage> FromChatbotAsync(IEnumerable<TFunctionCall> functionC
231236
/// <param name="pinLocation">Optional pin location for message ordering.</param>
232237
public async void FromChatbot(IEnumerable<TFunctionCall> functionCalls, PinLocation pinLocation = PinLocation.None)
233238
{
239+
// Intentional fire-and-forget wrapper to keep API ergonomic for callers that don't await.
234240
_ = await FromChatbotAsync(functionCalls, pinLocation);
235241
}
236242

@@ -260,6 +266,7 @@ public ValueTask<TMessage> FromFunctionAsync(TFunctionResult functionResult, Pin
260266
/// <param name="pinLocation">Optional pin location for message ordering.</param>
261267
public async void FromFunction(TFunctionResult functionResult, PinLocation pinLocation = PinLocation.None)
262268
{
269+
// Intentional fire-and-forget wrapper to keep API ergonomic for callers that don't await.
263270
_ = await FromFunctionAsync(functionResult, pinLocation);
264271
}
265272
}

ChatAIze.GenerativeCS/Models/FunctionCall.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public FunctionCall(string toolCallId, string name, string arguments)
4242
/// <summary>
4343
/// Gets or sets the provider-issued tool call identifier.
4444
/// </summary>
45+
/// <remarks>When present, this ties a function call to its matching tool result in later messages.</remarks>
4546
public string? ToolCallId { get; set; }
4647

4748
/// <summary>

ChatAIze.GenerativeCS/Models/FunctionResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public FunctionResult(string toolCallId, string name, string value)
4242
/// <summary>
4343
/// Gets or sets the provider-issued tool call identifier used to correlate the result with a prior tool call.
4444
/// </summary>
45+
/// <remarks>Providers like OpenAI expect this to mirror the tool call id emitted in the original function call.</remarks>
4546
public string? ToolCallId { get; set; }
4647

4748
/// <summary>

ChatAIze.GenerativeCS/Options/Gemini/ChatCompletionOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public ChatCompletionOptions(string model = DefaultModels.Gemini.ChatCompletion,
6969
/// <summary>
7070
/// Gets or sets a callback used to dynamically supply a system message.
7171
/// </summary>
72+
/// <remarks>Applied at request time so callers can inject context-sensitive instructions.</remarks>
7273
public Func<string?>? SystemMessageCallback { get; set; } = null;
7374

7475
/// <summary>
@@ -79,11 +80,13 @@ public ChatCompletionOptions(string model = DefaultModels.Gemini.ChatCompletion,
7980
/// <summary>
8081
/// Gets a callback invoked whenever a message is added to the chat.
8182
/// </summary>
83+
/// <remarks>Useful for logging or persisting transcripts as tool calls and model replies are appended.</remarks>
8284
public Func<TMessage, ValueTask> AddMessageCallback { get; } = (_) => ValueTask.CompletedTask;
8385

8486
/// <summary>
8587
/// Gets or sets the fallback function callback used when a function does not have an explicit delegate.
8688
/// </summary>
89+
/// <remarks>Defaults to throwing to make the absence of a callback explicit.</remarks>
8790
public Func<string, string, CancellationToken, ValueTask<object?>> DefaultFunctionCallback { get; set; } = (_, _, _) => throw new NotImplementedException("Function callback has not been implemented.");
8891

8992
/// <summary>

ChatAIze.GenerativeCS/Options/OpenAI/ChatCompletionOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public ChatCompletionOptions(string model = DefaultModels.OpenAI.ChatCompletion,
130130
/// <summary>
131131
/// Gets or sets a value indicating whether function call and result messages before the latest user message should be removed.
132132
/// </summary>
133+
/// <remarks>Use when continuing an existing chat but wanting the model to ignore earlier tool interactions and only consider the latest user turn.</remarks>
133134
public bool IsIgnoringPreviousFunctionCalls { get; set; }
134135

135136
/// <summary>
@@ -160,11 +161,13 @@ public ChatCompletionOptions(string model = DefaultModels.OpenAI.ChatCompletion,
160161
/// <summary>
161162
/// Gets or sets a callback invoked whenever a message is added to the chat during request processing.
162163
/// </summary>
164+
/// <remarks>Useful for logging or persisting transcripts as tool calls and model replies are appended.</remarks>
163165
public Func<TMessage, Task> AddMessageCallback { get; set; } = (_) => Task.CompletedTask;
164166

165167
/// <summary>
166168
/// Gets or sets the fallback function callback used when a function does not have an explicit delegate; should return a string or serializable object.
167169
/// </summary>
170+
/// <remarks>Defaults to throwing to make the absence of a callback explicit.</remarks>
168171
public Func<string, string, CancellationToken, ValueTask<object?>> DefaultFunctionCallback { get; set; } = (_, _, _) => throw new NotImplementedException("Function callback has not been implemented.");
169172

170173
/// <summary>

ChatAIze.GenerativeCS/Options/OpenAI/EmbeddingOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public EmbeddingOptions(string model = DefaultModels.OpenAI.Embedding, string? a
3131
/// <summary>
3232
/// Gets or sets optional output dimensions.
3333
/// </summary>
34+
/// <remarks>Only supported by specific models; unsupported combinations will be rejected by the provider.</remarks>
3435
public int? Dimensions { get; set; }
3536

3637
/// <summary>

ChatAIze.GenerativeCS/Options/OpenAI/ModerationOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ public ModerationOptions(string model = DefaultModels.OpenAI.Moderation, string?
3131
/// <summary>
3232
/// Gets or sets the maximum number of attempts (including the first call) before a moderation request is treated as failed.
3333
/// </summary>
34+
/// <remarks>Used by the retry helper; does not retry on client-side validation errors.</remarks>
3435
public int MaxAttempts { get; set; } = 5;
3536
}

0 commit comments

Comments
 (0)