Skip to content

Commit

Permalink
Rename ChatGPTTranslatorServiceEconomical to EconomicalChatGPTTransla…
Browse files Browse the repository at this point in the history
…torService

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.
  • Loading branch information
rodion-m committed Aug 14, 2023
1 parent 1486d10 commit 2a22c48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace OpenAI.ChatGpt.Modules.Translator;
/// Provides a service for translating text using GPT models with economical batching.
/// </summary>
// ReSharper disable once InconsistentNaming
public class ChatGPTTranslatorServiceEconomical : IAsyncDisposable
public class EconomicalChatGPTTranslatorService : IAsyncDisposable
{
private readonly IChatGPTTranslatorService _chatGptTranslatorService;
private readonly string _sourceLanguage;
Expand All @@ -25,7 +25,7 @@ public class ChatGPTTranslatorServiceEconomical : IAsyncDisposable
private readonly object _syncLock = new();

/// <summary>
/// Initializes a new instance of the <see cref="ChatGPTTranslatorServiceEconomical"/> class.
/// Initializes a new instance of the <see cref="EconomicalChatGPTTranslatorService"/> class.
/// </summary>
/// <param name="chatGptTranslatorService">The GPT translation service to use.</param>
/// <param name="sourceLanguage">The source language code.</param>
Expand All @@ -36,7 +36,7 @@ public class ChatGPTTranslatorServiceEconomical : IAsyncDisposable
/// <param name="user">The user ID. (Optional)</param>
/// <param name="sendRequestAfterInactivity">The timespan for sending requests after inactivity. (Optional)</param>
/// <param name="maxTokensPerRequest">The maximum tokens per request. (Optional)</param>
public ChatGPTTranslatorServiceEconomical(
public EconomicalChatGPTTranslatorService(
IChatGPTTranslatorService chatGptTranslatorService,
string sourceLanguage,
string targetLanguage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
12 changes: 6 additions & 6 deletions tests/OpenAI.ChatGpt.UnitTests/ChatGptTranslatorServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public async Task Translating_multiple_texts_should_be_batched_together()
{
// Arrange
var mockTranslatorService = new Mock<IChatGPTTranslatorService>();
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<ChatGPTTranslatorServiceEconomical.Batch>(),
=> m.TranslateObject(It.IsAny<EconomicalChatGPTTranslatorService.Batch>(),
true,
"en",
"fr",
Expand All @@ -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
);

Expand All @@ -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<ChatGPTTranslatorServiceEconomical.Batch>(),
=> m.TranslateObject(It.IsAny<EconomicalChatGPTTranslatorService.Batch>(),
true,
"en",
"fr",
Expand All @@ -127,7 +127,7 @@ public async Task Batch_is_processed_after_inactivity_period()
{
var mockTranslatorService = new Mock<IChatGPTTranslatorService>();

var service = new ChatGPTTranslatorServiceEconomical(
var service = new EconomicalChatGPTTranslatorService(
mockTranslatorService.Object,
"en",
"fr",
Expand All @@ -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<ChatGPTTranslatorServiceEconomical.Batch>(),
x.TranslateObject(It.IsAny<EconomicalChatGPTTranslatorService.Batch>(),
true,
"en",
"fr",
Expand Down

0 comments on commit 2a22c48

Please sign in to comment.