From 2a22c4884f76a0beadacefbf1b7e9b6400e38080 Mon Sep 17 00:00:00 2001 From: Rodion Mostovoi Date: Mon, 14 Aug 2023 19:55:28 +0600 Subject: [PATCH] Rename ChatGPTTranslatorServiceEconomical to EconomicalChatGPTTranslatorService This commit amends the name of the file and class from 'ChatGPTTranslatorServiceEconomical' to 'EconomicalChatGPTTranslatorService' for better readability and logical flow in code naming conventions. It also reflects the change in all usages of this class in the tests. --- ...ical.cs => EconomicalChatGPTTranslatorService.cs} | 6 +++--- .../ChatGptTranslatorServiceTests.cs | 2 +- .../ChatGptTranslatorServiceTests.cs | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) rename src/modules/OpenAI.ChatGpt.Modules.Translator/{ChatGPTTranslatorServiceEconomical.cs => EconomicalChatGPTTranslatorService.cs} (96%) diff --git a/src/modules/OpenAI.ChatGpt.Modules.Translator/ChatGPTTranslatorServiceEconomical.cs b/src/modules/OpenAI.ChatGpt.Modules.Translator/EconomicalChatGPTTranslatorService.cs similarity index 96% rename from src/modules/OpenAI.ChatGpt.Modules.Translator/ChatGPTTranslatorServiceEconomical.cs rename to src/modules/OpenAI.ChatGpt.Modules.Translator/EconomicalChatGPTTranslatorService.cs index 612dc9f..20b25e7 100644 --- a/src/modules/OpenAI.ChatGpt.Modules.Translator/ChatGPTTranslatorServiceEconomical.cs +++ b/src/modules/OpenAI.ChatGpt.Modules.Translator/EconomicalChatGPTTranslatorService.cs @@ -7,7 +7,7 @@ namespace OpenAI.ChatGpt.Modules.Translator; /// Provides a service for translating text using GPT models with economical batching. /// // ReSharper disable once InconsistentNaming -public class ChatGPTTranslatorServiceEconomical : IAsyncDisposable +public class EconomicalChatGPTTranslatorService : IAsyncDisposable { private readonly IChatGPTTranslatorService _chatGptTranslatorService; private readonly string _sourceLanguage; @@ -25,7 +25,7 @@ public class ChatGPTTranslatorServiceEconomical : IAsyncDisposable private readonly object _syncLock = new(); /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The GPT translation service to use. /// The source language code. @@ -36,7 +36,7 @@ public class ChatGPTTranslatorServiceEconomical : IAsyncDisposable /// The user ID. (Optional) /// The timespan for sending requests after inactivity. (Optional) /// The maximum tokens per request. (Optional) - public ChatGPTTranslatorServiceEconomical( + public EconomicalChatGPTTranslatorService( IChatGPTTranslatorService chatGptTranslatorService, string sourceLanguage, string targetLanguage, diff --git a/tests/OpenAI.ChatGpt.IntegrationTests/ChatGptTranslatorServiceTests.cs b/tests/OpenAI.ChatGpt.IntegrationTests/ChatGptTranslatorServiceTests.cs index 91b6f6a..6e8897e 100644 --- a/tests/OpenAI.ChatGpt.IntegrationTests/ChatGptTranslatorServiceTests.cs +++ b/tests/OpenAI.ChatGpt.IntegrationTests/ChatGptTranslatorServiceTests.cs @@ -92,7 +92,7 @@ public async void Batch_translate() }; var translationService = new ChatGPTTranslatorService(_client); - var service = new ChatGPTTranslatorServiceEconomical( + var service = new EconomicalChatGPTTranslatorService( translationService, "English", "Russian", maxTokensPerRequest: 50); var tasks = words.Select(async word => diff --git a/tests/OpenAI.ChatGpt.UnitTests/ChatGptTranslatorServiceTests.cs b/tests/OpenAI.ChatGpt.UnitTests/ChatGptTranslatorServiceTests.cs index b9ff6b0..2490385 100644 --- a/tests/OpenAI.ChatGpt.UnitTests/ChatGptTranslatorServiceTests.cs +++ b/tests/OpenAI.ChatGpt.UnitTests/ChatGptTranslatorServiceTests.cs @@ -74,12 +74,12 @@ public async Task Translating_multiple_texts_should_be_batched_together() { // Arrange var mockTranslatorService = new Mock(); - var batch = new ChatGPTTranslatorServiceEconomical.Batch(); + var batch = new EconomicalChatGPTTranslatorService.Batch(); batch.Add("Text 1"); batch.Add("Text 2"); mockTranslatorService.Setup(m - => m.TranslateObject(It.IsAny(), + => m.TranslateObject(It.IsAny(), true, "en", "fr", @@ -95,7 +95,7 @@ public async Task Translating_multiple_texts_should_be_batched_together() ).ReturnsAsync(batch) .Verifiable(); - var service = new ChatGPTTranslatorServiceEconomical( + var service = new EconomicalChatGPTTranslatorService( mockTranslatorService.Object, "en", "fr", maxTokensPerRequest: 50 ); @@ -106,7 +106,7 @@ public async Task Translating_multiple_texts_should_be_batched_together() // Assert await Task.WhenAll(result1, result2); mockTranslatorService.Verify(m - => m.TranslateObject(It.IsAny(), + => m.TranslateObject(It.IsAny(), true, "en", "fr", @@ -127,7 +127,7 @@ public async Task Batch_is_processed_after_inactivity_period() { var mockTranslatorService = new Mock(); - var service = new ChatGPTTranslatorServiceEconomical( + var service = new EconomicalChatGPTTranslatorService( mockTranslatorService.Object, "en", "fr", @@ -139,7 +139,7 @@ public async Task Batch_is_processed_after_inactivity_period() await Task.Delay(150); // Wait for the inactivity period mockTranslatorService.Verify(x => - x.TranslateObject(It.IsAny(), + x.TranslateObject(It.IsAny(), true, "en", "fr",