From a26d453720e9679a68f5a4da57cb8072efc9d4b2 Mon Sep 17 00:00:00 2001 From: TomiEckert Date: Sun, 22 Mar 2026 14:16:18 +0100 Subject: [PATCH] improve formatting --- Hush.Daemon/src/DaemonService.cs | 6 +++++- Hush.Providers/src/Providers/GroqProvider.cs | 20 +++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Hush.Daemon/src/DaemonService.cs b/Hush.Daemon/src/DaemonService.cs index de3ceae..1956573 100644 --- a/Hush.Daemon/src/DaemonService.cs +++ b/Hush.Daemon/src/DaemonService.cs @@ -33,7 +33,11 @@ public class DaemonService if (File.Exists(socketPath)) { - try { File.Delete(socketPath); } catch { } + try { File.Delete(socketPath); } + catch + { + // ignored + } } var configManager = new ConfigManager(); diff --git a/Hush.Providers/src/Providers/GroqProvider.cs b/Hush.Providers/src/Providers/GroqProvider.cs index d4aa651..cf44fae 100644 --- a/Hush.Providers/src/Providers/GroqProvider.cs +++ b/Hush.Providers/src/Providers/GroqProvider.cs @@ -3,7 +3,6 @@ using System.Text; using System.Text.Json; using Hush.Providers.Interfaces; using Hush.Providers.Models.Request; -using Hush.Providers.Models.Response; using Hush.Providers.Serialization; namespace Hush.Providers.Providers; @@ -13,8 +12,8 @@ namespace Hush.Providers.Providers; /// public class GroqProvider : IAudioToTextProvider, ITextStreamingProvider { - private const string ChatCompletionEndpoint = "https://api.groq.com/openai/v1/chat/completions"; - private const string TranscriptionEndpoint = "https://api.groq.com/openai/v1/audio/transcriptions"; + private const string CHAT_COMPLETION_ENDPOINT = "https://api.groq.com/openai/v1/chat/completions"; + private const string TRANSCRIPTION_ENDPOINT = "https://api.groq.com/openai/v1/audio/transcriptions"; private readonly HttpClient _httpClient; private readonly string _apiKey; @@ -36,9 +35,8 @@ public class GroqProvider : IAudioToTextProvider, ITextStreamingProvider string modelName, CancellationToken cancellationToken = default) { - if (audioStream == null) - throw new ArgumentNullException(nameof(audioStream)); - + ArgumentNullException.ThrowIfNull(audioStream); + if (string.IsNullOrWhiteSpace(modelName)) throw new ArgumentException("Model name is required", nameof(modelName)); @@ -56,7 +54,7 @@ public class GroqProvider : IAudioToTextProvider, ITextStreamingProvider if (request.Temperature.HasValue) content.Add(new StringContent(request.Temperature.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)), "temperature"); - var httpRequest = new HttpRequestMessage(HttpMethod.Post, TranscriptionEndpoint) + var httpRequest = new HttpRequestMessage(HttpMethod.Post, TRANSCRIPTION_ENDPOINT) { Content = content }; @@ -94,7 +92,7 @@ public class GroqProvider : IAudioToTextProvider, ITextStreamingProvider var request = new ChatCompletionRequest { Model = modelName, - Messages = new List { new Hush.Providers.Models.Request.Message { Role = "user", Content = prompt } } + Messages = new List { new() { Role = "user", Content = prompt } } }; var jsonContent = new StringContent( @@ -102,7 +100,7 @@ public class GroqProvider : IAudioToTextProvider, ITextStreamingProvider Encoding.UTF8, "application/json"); - var httpRequest = new HttpRequestMessage(HttpMethod.Post, ChatCompletionEndpoint) + var httpRequest = new HttpRequestMessage(HttpMethod.Post, CHAT_COMPLETION_ENDPOINT) { Content = jsonContent }; @@ -139,7 +137,7 @@ public class GroqProvider : IAudioToTextProvider, ITextStreamingProvider { Model = modelName, Stream = true, - Messages = new List { new Hush.Providers.Models.Request.Message { Role = "user", Content = prompt } } + Messages = new List { new() { Role = "user", Content = prompt } } }; var jsonContent = new StringContent( @@ -147,7 +145,7 @@ public class GroqProvider : IAudioToTextProvider, ITextStreamingProvider Encoding.UTF8, "application/json"); - var httpRequest = new HttpRequestMessage(HttpMethod.Post, ChatCompletionEndpoint) + var httpRequest = new HttpRequestMessage(HttpMethod.Post, CHAT_COMPLETION_ENDPOINT) { Content = jsonContent };