1
0

chore: Introduce Qodana static analysis configuration and apply minor code formatting and C# 12 collection expressions.

This commit is contained in:
2026-03-01 20:07:20 +01:00
parent ec575ab5f9
commit 15f9647f8a
24 changed files with 344 additions and 80 deletions

View File

@@ -28,10 +28,10 @@ public class OpenAiCompatibleClient : ISpeechClient, ILlmClient
using var content = new MultipartFormDataContent();
using var fileStream = File.OpenRead(filePath);
using var streamContent = new StreamContent(fileStream);
streamContent.Headers.ContentType = new MediaTypeHeaderValue("audio/wav"); // or mpeg
content.Add(streamContent, "file", Path.GetFileName(filePath));
string modelToUse = string.IsNullOrWhiteSpace(model) ? Toak.Core.Constants.Defaults.WhisperModel : model;
content.Add(new StringContent(modelToUse), "model");
@@ -45,7 +45,7 @@ public class OpenAiCompatibleClient : ISpeechClient, ILlmClient
Logger.LogDebug($"Sending Whisper API request ({modelToUse})...");
var response = await _httpClient.PostAsync("audio/transcriptions", content);
Logger.LogDebug($"Whisper API response status: {response.StatusCode}");
if (!response.IsSuccessStatusCode)
{
var error = await response.Content.ReadAsStringAsync();
@@ -106,9 +106,10 @@ public class OpenAiCompatibleClient : ISpeechClient, ILlmClient
var jsonContent = new StringContent(JsonSerializer.Serialize(requestBody, AppJsonSerializerContext.Default.OpenAiRequest), System.Text.Encoding.UTF8, "application/json");
using var request = new HttpRequestMessage(HttpMethod.Post, "chat/completions") { Content = jsonContent };
using var request = new HttpRequestMessage(HttpMethod.Post, "chat/completions");
request.Content = jsonContent;
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/event-stream"));
Logger.LogDebug($"Sending OpenAi Steam API request (model: {requestBody.Model})...");
using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
Logger.LogDebug($"OpenAi Stream API response status: {response.StatusCode}");