Skip to content

Commit d96e0c2

Browse files
author
Piotr Stachaczynski
committed
fix: build warnings
1 parent 369a4ed commit d96e0c2

7 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/MaIN.Services/Services/DataSourceProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task<string> FetchApiData(object? details, string? filter,
6868

6969
if (!apiDetails?.AuthenticationToken.IsNullOrEmpty() ?? false)
7070
{
71-
if (!apiDetails.AuthenticationType.HasValue)
71+
if (!apiDetails!.AuthenticationType.HasValue)
7272
throw new InvalidOperationException("Please specify an authorization type");
7373

7474
switch (apiDetails.AuthenticationType)

src/MaIN.Services/Services/LLMService/AnthropicService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,10 @@ await notificationService.DispatchNotification(
347347

348348
var toolUseBuilders = new Dictionary<int, AnthropicToolUseBuilder>();
349349

350-
while (!reader.EndOfStream)
350+
while (true)
351351
{
352352
var line = await reader.ReadLineAsync(cancellationToken);
353+
if (line is null) break;
353354
if (string.IsNullOrWhiteSpace(line))
354355
continue;
355356

@@ -679,9 +680,10 @@ private async Task ProcessStreamingChatAsync(
679680
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken);
680681
using var reader = new StreamReader(stream);
681682

682-
while (!reader.EndOfStream)
683+
while (true)
683684
{
684685
var line = await reader.ReadLineAsync(cancellationToken);
686+
if (line is null) break;
685687
if (string.IsNullOrWhiteSpace(line))
686688
continue;
687689

src/MaIN.Services/Services/LLMService/GeminiService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ protected override void ApplyBackendParams(Dictionary<string, object> requestBod
155155

156156
if (requestOptions.InteractiveUpdates)
157157
{
158-
await notificationService.DispatchNotification(
158+
await _notificationService.DispatchNotification(
159159
NotificationMessageBuilder.CreateChatCompletion(chat.Id, tokenValue, false),
160160
ServiceConstants.Notifications.ReceiveMessageUpdate);
161161
}

src/MaIN.Services/Services/LLMService/OpenAiCompatibleService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,10 @@ await _notificationService.DispatchNotification(
314314

315315
var toolCallsBuilder = new Dictionary<int, ToolCallBuilder>();
316316

317-
while (!reader.EndOfStream)
317+
while (true)
318318
{
319319
var line = await reader.ReadLineAsync(cancellationToken);
320+
if (line is null) break;
320321
if (string.IsNullOrWhiteSpace(line))
321322
continue;
322323

@@ -755,11 +756,12 @@ private async Task ProcessStreamingChatAsync(
755756
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken);
756757
using var reader = new StreamReader(stream);
757758

758-
while (!reader.EndOfStream)
759+
while (true)
759760
{
760761
cancellationToken.ThrowIfCancellationRequested();
761762

762763
var line = await reader.ReadLineAsync(cancellationToken);
764+
if (line is null) break;
763765
if (string.IsNullOrWhiteSpace(line))
764766
continue;
765767

src/MaIN.Services/Services/LLMService/VertexService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public sealed class VertexService(
2424
ILogger<VertexService>? logger = null)
2525
: OpenAiCompatibleService(notificationService, httpClientFactory, memoryFactory, memoryService, logger), ILLMService
2626
{
27+
private readonly IHttpClientFactory _httpClientFactory = httpClientFactory;
2728
private GoogleServiceAccountTokenProvider? _tokenProvider;
2829
private string _location = "us-central1";
2930

@@ -46,7 +47,7 @@ protected override string GetApiKey()
4647
var auth = Auth;
4748
_tokenProvider ??= new GoogleServiceAccountTokenProvider(auth);
4849

49-
var httpClient = httpClientFactory.CreateClient(HttpClientName);
50+
var httpClient = _httpClientFactory.CreateClient(HttpClientName);
5051
// Task.Run avoids deadlocking on Blazor Server's single-threaded SynchronizationContext
5152
return Task.Run(() => _tokenProvider.GetAccessTokenAsync(httpClient)).GetAwaiter().GetResult();
5253
}

src/MaIN.Services/Services/McpService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ private async Task<McpResult> PromptWithHttp(
146146
.Deserialize<Dictionary<string, JsonElement>>(argsJson)
147147
?.ToDictionary(
148148
kvp => kvp.Key,
149-
kvp => kvp.Value.ValueKind switch
149+
kvp => (object?)(kvp.Value.ValueKind switch
150150
{
151151
JsonValueKind.String => (object)kvp.Value.GetString()!,
152152
JsonValueKind.True => true,
153153
JsonValueKind.False => false,
154154
JsonValueKind.Number when kvp.Value.TryGetInt64(out var l) => l,
155155
JsonValueKind.Number => (object)kvp.Value.GetDouble(),
156156
_ => (object)kvp.Value
157-
})
158-
?? new Dictionary<string, object>();
157+
}))
158+
?? new Dictionary<string, object?>();
159159

160160
var toolResult = await mcpClient.CallToolAsync(toolName, argsDict);
161161
var resultText = string.Join("\n", toolResult.Content
@@ -291,16 +291,16 @@ private async Task<McpResult> PromptWithAnthropic(
291291
.Deserialize<Dictionary<string, JsonElement>>(inputElement.GetRawText())
292292
?.ToDictionary(
293293
kvp => kvp.Key,
294-
kvp => kvp.Value.ValueKind switch
294+
kvp => (object?)(kvp.Value.ValueKind switch
295295
{
296296
JsonValueKind.String => (object)kvp.Value.GetString()!,
297297
JsonValueKind.True => true,
298298
JsonValueKind.False => false,
299299
JsonValueKind.Number when kvp.Value.TryGetInt64(out var l) => l,
300300
JsonValueKind.Number => (object)kvp.Value.GetDouble(),
301301
_ => (object)kvp.Value
302-
})
303-
?? new Dictionary<string, object>();
302+
}))
303+
?? new Dictionary<string, object?>();
304304

305305
var toolResult = await mcpClient.CallToolAsync(toolName, argsDict);
306306
var resultText = string.Join("\n", toolResult.Content

src/MaIN.Services/Services/Steps/Commands/FetchCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ await notificationService.DispatchNotification(
154154
"ReceiveAgentUpdate");
155155

156156
var result = await llmServiceFactory.CreateService(backend)
157-
.AskMemory(memoryChat!, new ChatMemoryOptions { TextData = new Dictionary<string, string> { ["web-content"] = cleanText } }, new ChatRequestOptions());
157+
.AskMemory(memoryChat!, new ChatMemoryOptions { TextData = new Dictionary<string, string> { ["web-content"] = cleanText ?? string.Empty } }, new ChatRequestOptions());
158158

159159
await notificationService.DispatchNotification(
160160
NotificationMessageBuilder.CreateActorProgress(

0 commit comments

Comments
 (0)