improve formatting

This commit is contained in:
2026-03-22 14:16:18 +01:00
parent f6e2030201
commit a26d453720
2 changed files with 14 additions and 12 deletions
+9 -11
View File
@@ -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;
/// </summary>
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<Hush.Providers.Models.Request.Message> { new Hush.Providers.Models.Request.Message { Role = "user", Content = prompt } }
Messages = new List<Models.Request.Message> { 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<Hush.Providers.Models.Request.Message> { new Hush.Providers.Models.Request.Message { Role = "user", Content = prompt } }
Messages = new List<Models.Request.Message> { 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
};