From bed3dd330927df2ffb2891adad2d9d27d3e34b97 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 19:49:46 -0700 Subject: [PATCH 01/31] Updated ChatCompletionDependencyException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../ChatCompletionDependencyException.cs | 6 ------ .../ChatCompletionService.Exceptions.cs | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs index dbe8db33..339c5dd2 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class ChatCompletionDependencyException : Xeption { - public ChatCompletionDependencyException(Xeption innerException) - : base( - message: "Chat completion dependency error occurred, contact support.", - innerException: innerException) - { } - public ChatCompletionDependencyException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..bed4e541 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -33,21 +33,27 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var invalidConfigurationChatCompletionException = new InvalidConfigurationChatCompletionException(httpResponseUrlNotFoundException); - throw new ChatCompletionDependencyException(invalidConfigurationChatCompletionException); + throw new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + invalidConfigurationChatCompletionException); } catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedChatCompletionException = new UnauthorizedChatCompletionException(httpResponseUnauthorizedException); - throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); + throw new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + unauthorizedChatCompletionException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedChatCompletionException = new UnauthorizedChatCompletionException(httpResponseForbiddenException); - throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); + throw new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + unauthorizedChatCompletionException); } catch (HttpResponseNotFoundException httpResponseNotFoundException) { @@ -75,7 +81,9 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var failedServerChatCompletionException = new FailedServerChatCompletionException(httpResponseException); - throw new ChatCompletionDependencyException(failedServerChatCompletionException); + throw new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + failedServerChatCompletionException); } catch (Exception exception) { From 19a68096515d9146acb45f6d5639cb65e059fae7 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 19:55:06 -0700 Subject: [PATCH 02/31] Updated ChatCompletionDependencyValidationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../ChatCompletionDependencyValidationException.cs | 6 ------ .../ChatCompletionService.Exceptions.cs | 12 +++++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs index 3e8d550c..7b23d6d5 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class ChatCompletionDependencyValidationException : Xeption { - public ChatCompletionDependencyValidationException(Xeption innerException) - : base( - message: "Chat completion dependency validation error occurred, fix errors and try again.", - innerException: innerException) - { } - public ChatCompletionDependencyValidationException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..e7a25e5c 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -54,21 +54,27 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var notFoundChatCompletionException = new NotFoundChatCompletionException(httpResponseNotFoundException); - throw new ChatCompletionDependencyValidationException(notFoundChatCompletionException); + throw new ChatCompletionDependencyValidationException( + message: "Chat completion dependency validation error occurred, fix errors and try again.", + notFoundChatCompletionException); } catch (HttpResponseBadRequestException httpResponseBadRequestException) { var invalidChatCompletionException = new InvalidChatCompletionException(httpResponseBadRequestException); - throw new ChatCompletionDependencyValidationException(invalidChatCompletionException); + throw new ChatCompletionDependencyValidationException( + message: "Chat completion dependency validation error occurred, fix errors and try again.", + invalidChatCompletionException); } catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) { var excessiveCallChatCompletionException = new ExcessiveCallChatCompletionException(httpResponseTooManyRequestsException); - throw new ChatCompletionDependencyValidationException(excessiveCallChatCompletionException); + throw new ChatCompletionDependencyValidationException( + message: "Chat completion dependency validation error occurred, fix errors and try again.", + excessiveCallChatCompletionException); } catch (HttpResponseException httpResponseException) { From d77e497ef8c1e945e276e87c21d6250e1246ae02 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 19:59:05 -0700 Subject: [PATCH 03/31] Updated ChatCompletionServiceException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/ChatCompletionServiceException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionServiceException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionServiceException.cs index 4a306a4a..7b724626 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionServiceException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionServiceException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class ChatCompletionServiceException : Xeption { - public ChatCompletionServiceException(Exception innerException) - : base( - message: "Chat completion service error occurred, contact support.", - innerException: innerException) - { } - public ChatCompletionServiceException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..6024d7d3 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -83,6 +83,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction new FailedChatCompletionServiceException(exception); throw new ChatCompletionServiceException( + message: "Chat completion service error occurred, contact support.", failedChatCompletionServiceException); } } From 17260c1db83e0262137cc9d57b4fad9d43710054 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:04:32 -0700 Subject: [PATCH 04/31] Updated ChatCompletionValidationException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/ChatCompletionValidationException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs index 868b1a1a..ee30f61d 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs @@ -8,12 +8,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class ChatCompletionValidationException : Xeption { - public ChatCompletionValidationException(Xeption innerException) - : base( - message: "Chat completion validation error occurred, fix errors and try again.", - innerException: innerException) - { } - public ChatCompletionValidationException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..00b3b3a1 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -22,11 +22,15 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } catch (NullChatCompletionException nullChatCompletionException) { - throw new ChatCompletionValidationException(nullChatCompletionException); + throw new ChatCompletionValidationException( + message: "Chat completion validation error occurred, fix errors and try again.", + nullChatCompletionException); } catch (InvalidChatCompletionException invalidChatCompletionException) { - throw new ChatCompletionValidationException(invalidChatCompletionException); + throw new ChatCompletionValidationException( + message: "Chat completion validation error occurred, fix errors and try again.", + invalidChatCompletionException); } catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) { From d240c9d483ca8bcd165bd0cba6b85d3354fee1b8 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:09:17 -0700 Subject: [PATCH 05/31] Updated ExcessiveCallChatCompletionException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/ExcessiveCallChatCompletionException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs index a38dbafa..402fbf81 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class ExcessiveCallChatCompletionException : Xeption { - public ExcessiveCallChatCompletionException(Exception innerException) - : base( - message: "Excessive call error occurred, limit your calls.", - innerException: innerException) - { } - public ExcessiveCallChatCompletionException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..b15c7975 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -66,7 +66,9 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) { var excessiveCallChatCompletionException = - new ExcessiveCallChatCompletionException(httpResponseTooManyRequestsException); + new ExcessiveCallChatCompletionException( + message: "Excessive call error occurred, limit your calls.", + httpResponseTooManyRequestsException); throw new ChatCompletionDependencyValidationException(excessiveCallChatCompletionException); } From 51f8c94169f0ed5e2367be1e18dc7fa5a41df8ad Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:12:58 -0700 Subject: [PATCH 06/31] Updated FailedChatCompletionServiceException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/FailedChatCompletionServiceException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs index cd1e4a8b..dab5bfdb 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class FailedChatCompletionServiceException : Xeption { - public FailedChatCompletionServiceException(Exception innerException) - : base( - message: "Failed Chat Completion Service Exception occurred, please contact support for assistance.", - innerException: innerException) - { } - public FailedChatCompletionServiceException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..9ab7dc98 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -80,7 +80,9 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (Exception exception) { var failedChatCompletionServiceException = - new FailedChatCompletionServiceException(exception); + new FailedChatCompletionServiceException( + message: "Failed Chat Completion Service Exception occurred, please contact support for assistance.", + exception); throw new ChatCompletionServiceException( failedChatCompletionServiceException); From 32a91b54fa0069122e379844b28c9e5e504df9a1 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:18:15 -0700 Subject: [PATCH 07/31] Updated FailedServerChatCompletionException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/FailedServerChatCompletionException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedServerChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedServerChatCompletionException.cs index f4c17e4d..ff49a035 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedServerChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedServerChatCompletionException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class FailedServerChatCompletionException : Xeption { - public FailedServerChatCompletionException(Exception innerException) - : base( - message: "Failed chat completion server error occurred, contact support.", - innerException: innerException) - { } - public FailedServerChatCompletionException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..0b2bcdc1 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -73,7 +73,9 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseException httpResponseException) { var failedServerChatCompletionException = - new FailedServerChatCompletionException(httpResponseException); + new FailedServerChatCompletionException( + message: "Failed chat completion server error occurred, contact support.", + httpResponseException); throw new ChatCompletionDependencyException(failedServerChatCompletionException); } From fa0f8c109d5ddd59eb64e3152e32535ca645e14c Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:26:05 -0700 Subject: [PATCH 08/31] Updated InvalidChatCompletionException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../ChatCompletionServiceTests.Validations.Send.cs | 6 ++++-- .../Exceptions/InvalidChatCompletionException.cs | 9 +-------- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 +++- .../ChatCompletions/ChatCompletionService.Validations.cs | 4 +++- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs index 8557d1e4..a74bb45e 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs @@ -58,7 +58,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsNullAsync() invalidChatCompletion.Request = null; var invalidChatCompletionException = - new InvalidChatCompletionException(); + new InvalidChatCompletionException( + message: "Chat completion is invalid."); invalidChatCompletionException.AddData( key: nameof(ChatCompletion.Request), @@ -106,7 +107,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsInvalidAsync(s }; var invalidChatCompletionException = - new InvalidChatCompletionException(); + new InvalidChatCompletionException( + message: "Chat completion is invalid."); invalidChatCompletionException.AddData( key: nameof(ChatCompletion.Request.Model), diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs index a9d9f0a7..57f8d84d 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs @@ -9,17 +9,10 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class InvalidChatCompletionException : Xeption { - public InvalidChatCompletionException() + public InvalidChatCompletionException(string message) : base( message: "Chat completion is invalid.") { } - - public InvalidChatCompletionException(Exception innerException) - : base( - message: "Chat completion is invalid.", - innerException: innerException) - { } - public InvalidChatCompletionException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..9a15c1d9 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -59,7 +59,9 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseBadRequestException httpResponseBadRequestException) { var invalidChatCompletionException = - new InvalidChatCompletionException(httpResponseBadRequestException); + new InvalidChatCompletionException( + message: "Chat completion is invalid.", + httpResponseBadRequestException); throw new ChatCompletionDependencyValidationException(invalidChatCompletionException); } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs index d23e5168..0d5e7ec1 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs @@ -48,7 +48,9 @@ private void ValidateChatCompletionIsNotNull(ChatCompletion chatCompletion) private static void Validate(params (dynamic Rule, string Parameter)[] validations) { - var invalidChatCompletionException = new InvalidChatCompletionException(); + var invalidChatCompletionException = + new InvalidChatCompletionException( + message: "Chat completion is invalid."); foreach ((dynamic rule, string parameter) in validations) { From 8c3e56dc97b8b0f768fe8f6fddcf5394c6a81309 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:30:26 -0700 Subject: [PATCH 09/31] Updated InvalidConfigurationChatCompletionException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../InvalidConfigurationChatCompletionException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs index 47d5e40f..821eec6d 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class InvalidConfigurationChatCompletionException : Xeption { - public InvalidConfigurationChatCompletionException(Exception innerException) - : base( - message: "Invalid chat completion configuration error occurred, contact support.", - innerException: innerException) - { } - public InvalidConfigurationChatCompletionException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..8465a3ca 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -31,7 +31,9 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) { var invalidConfigurationChatCompletionException = - new InvalidConfigurationChatCompletionException(httpResponseUrlNotFoundException); + new InvalidConfigurationChatCompletionException( + message: "Invalid chat completion configuration error occurred, contact support.", + httpResponseUrlNotFoundException); throw new ChatCompletionDependencyException(invalidConfigurationChatCompletionException); } From 2e0426ca464691044826d74e1a1745f5b9fc9880 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:37:42 -0700 Subject: [PATCH 10/31] Updated NotFoundChatCompletionException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/NotFoundChatCompletionException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs index 11d5118b..46f1b734 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class NotFoundChatCompletionException : Xeption { - public NotFoundChatCompletionException(Exception innerException) - : base( - message: "Chat completion not found.", - innerException: innerException) - { } - public NotFoundChatCompletionException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..115010d5 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -52,7 +52,9 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseNotFoundException httpResponseNotFoundException) { var notFoundChatCompletionException = - new NotFoundChatCompletionException(httpResponseNotFoundException); + new NotFoundChatCompletionException( + message: "Chat completion not found.", + httpResponseNotFoundException); throw new ChatCompletionDependencyValidationException(notFoundChatCompletionException); } From f3a24302c05f370da7dc706b890d98801275a5cd Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 29 May 2024 20:47:49 -0700 Subject: [PATCH 11/31] Updated UnauthorizedChatCompletionException class by removing constructors in which the error message was hard coded in. Updated all relevant service files to include message. --- .../Exceptions/UnauthorizedChatCompletionException.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs index a6a2d54d..5a4185ac 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs @@ -9,12 +9,6 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class UnauthorizedChatCompletionException : Xeption { - public UnauthorizedChatCompletionException(Exception innerException) - : base( - message: "Unauthorized chat completion request, fix errors and try again.", - innerException: innerException) - { } - public UnauthorizedChatCompletionException(string message, Exception innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e753f46e..09b1a050 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -38,14 +38,18 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedChatCompletionException = - new UnauthorizedChatCompletionException(httpResponseUnauthorizedException); + new UnauthorizedChatCompletionException( + message: "Unauthorized chat completion request, fix errors and try again.", + httpResponseUnauthorizedException); throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedChatCompletionException = - new UnauthorizedChatCompletionException(httpResponseForbiddenException); + new UnauthorizedChatCompletionException( + message: "Unauthorized chat completion request, fix errors and try again.", + httpResponseForbiddenException); throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); } From 580c121374e00a18bebc74601b387194a9f591d9 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 02:45:45 -0700 Subject: [PATCH 12/31] Added create methods to both ChatCompletions.Exceptions.cs and ChatCompletionServiceTests.cs as well as refactored code --- ...tCompletionServiceTests.Exceptions.Send.cs | 15 ++++++-------- .../ChatCompletionServiceTests.cs | 9 +++++++++ .../ChatCompletionService.Exceptions.cs | 20 +++++++++++-------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs index 31bb0a9f..ff2a00f3 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs @@ -32,9 +32,8 @@ private async Task ShouldThrowDependencyExceptionOnSendIfUrlNotFoundAsync() innerException: httpResponseUrlNotFoundException); var expectedChatCompletionDependencyException = - new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", - innerException: invalidConfigurationChatCompletionException); + createChatCompletionDependencyException( + innerException: invalidConfigurationChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -78,9 +77,8 @@ private async Task ShouldThrowDependencyExceptionOnSendIfUnauthorizedAsync( innerException: unauthorizedException); var expectedChatCompletionDependencyException = - new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", - innerException: unauthorizedChatCompletionException); + createChatCompletionDependencyException( + innerException: unauthorizedChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -260,9 +258,8 @@ private async Task ShouldThrowDependencyExceptionOnSendIfHttpResponseErrorOccurr innerException: httpResponseException); var expectedChatCompletionDependencyException = - new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", - innerException: failedServerChatCompletionException); + createChatCompletionDependencyException( + innerException: failedServerChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index 465752a3..e522a5a4 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -13,9 +13,11 @@ using Standard.AI.OpenAI.Brokers.DateTimes; using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; +using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalChatCompletions; using Standard.AI.OpenAI.Services.Foundations.ChatCompletions; using Tynamix.ObjectFiller; +using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ChatCompletions @@ -154,5 +156,12 @@ private static Filler ChatCompletionFiller() return filler; } + + private static ChatCompletionDependencyException createChatCompletionDependencyException(Xeption innerException) + { + return new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + innerException); + } } } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index bed4e541..c211d5e5 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -7,6 +7,7 @@ using RESTFulSense.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; +using Xeptions; namespace Standard.AI.OpenAI.Services.Foundations.ChatCompletions { @@ -33,8 +34,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var invalidConfigurationChatCompletionException = new InvalidConfigurationChatCompletionException(httpResponseUrlNotFoundException); - throw new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", + throw createChatCompletionDependencyException( invalidConfigurationChatCompletionException); } catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) @@ -42,8 +42,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var unauthorizedChatCompletionException = new UnauthorizedChatCompletionException(httpResponseUnauthorizedException); - throw new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", + throw createChatCompletionDependencyException( unauthorizedChatCompletionException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) @@ -51,8 +50,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var unauthorizedChatCompletionException = new UnauthorizedChatCompletionException(httpResponseForbiddenException); - throw new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", + throw createChatCompletionDependencyException( unauthorizedChatCompletionException); } catch (HttpResponseNotFoundException httpResponseNotFoundException) @@ -81,8 +79,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var failedServerChatCompletionException = new FailedServerChatCompletionException(httpResponseException); - throw new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", + throw createChatCompletionDependencyException( failedServerChatCompletionException); } catch (Exception exception) @@ -94,5 +91,12 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction failedChatCompletionServiceException); } } + + private static ChatCompletionDependencyException createChatCompletionDependencyException(Xeption innerException) + { + return new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + innerException); + } } } \ No newline at end of file From a8b716ce813d0b5f830c24eb8597ca7ad21a1350 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 02:52:29 -0700 Subject: [PATCH 13/31] Added create methods to both ChatCompletions.Exceptions.cs and ChatCompletionServiceTests.cs as well as refactored code --- ...hatCompletionServiceTests.Exceptions.Send.cs | 15 ++++++--------- .../ChatCompletionServiceTests.cs | 9 +++++++++ .../ChatCompletionService.Exceptions.cs | 17 +++++++++++------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs index 31bb0a9f..5a8e097f 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs @@ -125,9 +125,8 @@ private async Task ShouldThrowDependencyValidationExceptionOnSendIfChatCompletio innerException: httpResponseNotFoundException); var expectedChatCompletionDependencyValidationException = - new ChatCompletionDependencyValidationException( - message: "Chat completion dependency validation error occurred, fix errors and try again.", - innerException: notFoundChatCompletionException); + createChatCompletionDependencyValidationException( + innerException: notFoundChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -170,9 +169,8 @@ private async Task ShouldThrowDependencyValidationExceptionOnSendIfBadRequestErr innerException: httpResponseBadRequestException); var expectedChatCompletionDependencyValidationException = - new ChatCompletionDependencyValidationException( - message: "Chat completion dependency validation error occurred, fix errors and try again.", - innerException: invalidChatCompletionException); + createChatCompletionDependencyValidationException( + innerException: invalidChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -217,9 +215,8 @@ private async Task ShouldThrowDependencyValidationExceptionOnSendIfTooManyReques innerException: httpResponseTooManyRequestsException); var expectedChatCompletionDependencyValidationException = - new ChatCompletionDependencyValidationException( - message: "Chat completion dependency validation error occurred, fix errors and try again.", - innerException: excessiveCallChatCompletionException); + createChatCompletionDependencyValidationException( + innerException: excessiveCallChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index 465752a3..3568039c 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -13,9 +13,11 @@ using Standard.AI.OpenAI.Brokers.DateTimes; using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; +using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalChatCompletions; using Standard.AI.OpenAI.Services.Foundations.ChatCompletions; using Tynamix.ObjectFiller; +using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ChatCompletions @@ -154,5 +156,12 @@ private static Filler ChatCompletionFiller() return filler; } + + private static ChatCompletionDependencyValidationException createChatCompletionDependencyValidationException(Xeption innerException) + { + return new ChatCompletionDependencyValidationException( + "Chat completion dependency validation error occurred, fix errors and try again.", + innerException); + } } } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index e7a25e5c..0741bed9 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -7,6 +7,7 @@ using RESTFulSense.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; +using Xeptions; namespace Standard.AI.OpenAI.Services.Foundations.ChatCompletions { @@ -54,8 +55,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var notFoundChatCompletionException = new NotFoundChatCompletionException(httpResponseNotFoundException); - throw new ChatCompletionDependencyValidationException( - message: "Chat completion dependency validation error occurred, fix errors and try again.", + throw createChatCompletionDependencyValidationException( notFoundChatCompletionException); } catch (HttpResponseBadRequestException httpResponseBadRequestException) @@ -63,8 +63,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var invalidChatCompletionException = new InvalidChatCompletionException(httpResponseBadRequestException); - throw new ChatCompletionDependencyValidationException( - message: "Chat completion dependency validation error occurred, fix errors and try again.", + throw createChatCompletionDependencyValidationException( invalidChatCompletionException); } catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) @@ -72,8 +71,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var excessiveCallChatCompletionException = new ExcessiveCallChatCompletionException(httpResponseTooManyRequestsException); - throw new ChatCompletionDependencyValidationException( - message: "Chat completion dependency validation error occurred, fix errors and try again.", + throw createChatCompletionDependencyValidationException( excessiveCallChatCompletionException); } catch (HttpResponseException httpResponseException) @@ -92,5 +90,12 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction failedChatCompletionServiceException); } } + + private static ChatCompletionDependencyValidationException createChatCompletionDependencyValidationException(Xeption innerException) + { + return new ChatCompletionDependencyValidationException( + "Chat completion dependency validation error occurred, fix errors and try again.", + innerException); + } } } \ No newline at end of file From b303722b83311fb830e34c45c7d980a0b9035999 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 02:58:42 -0700 Subject: [PATCH 14/31] Added create methods to both ChatCompletions.Exceptions.cs and ChatCompletionServiceTests.cs as well as refactored code --- ...ChatCompletionServiceTests.Validations.Send.cs | 15 ++++++--------- .../ChatCompletions/ChatCompletionServiceTests.cs | 9 +++++++++ .../ChatCompletionService.Exceptions.cs | 14 ++++++++++---- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs index 8557d1e4..697f766d 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs @@ -24,9 +24,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfChatCompletionIsNullAsy new NullChatCompletionException(); var expectedChatCompletionValidationException = - new ChatCompletionValidationException( - message: "Chat completion validation error occurred, fix errors and try again.", - innerException: nullChatCompletionException); + createChatCompletionValidationException( + innerException: nullChatCompletionException); // when ValueTask sendChatCompletionTask = @@ -65,9 +64,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsNullAsync() values: "Value is required"); var expectedChatCompletionValidationException = - new ChatCompletionValidationException( - message: "Chat completion validation error occurred, fix errors and try again.", - innerException: invalidChatCompletionException); + createChatCompletionValidationException( + innerException: invalidChatCompletionException); // when ValueTask sendChatCompletionTask = @@ -117,9 +115,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsInvalidAsync(s values: "Value is required"); var expectedChatCompletionValidationException = - new ChatCompletionValidationException( - message: "Chat completion validation error occurred, fix errors and try again.", - innerException: invalidChatCompletionException); + createChatCompletionValidationException( + innerException: invalidChatCompletionException); // when ValueTask sendChatCompletionTask = diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index 465752a3..bdeb28f5 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -13,9 +13,11 @@ using Standard.AI.OpenAI.Brokers.DateTimes; using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; +using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalChatCompletions; using Standard.AI.OpenAI.Services.Foundations.ChatCompletions; using Tynamix.ObjectFiller; +using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ChatCompletions @@ -154,5 +156,12 @@ private static Filler ChatCompletionFiller() return filler; } + + private static ChatCompletionValidationException createChatCompletionValidationException(Xeption innerException) + { + return new ChatCompletionValidationException( + message: "Chat completion validation error occurred, fix errors and try again.", + innerException); + } } } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 00b3b3a1..7d2f1314 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -7,6 +7,7 @@ using RESTFulSense.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; +using Xeptions; namespace Standard.AI.OpenAI.Services.Foundations.ChatCompletions { @@ -22,14 +23,12 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } catch (NullChatCompletionException nullChatCompletionException) { - throw new ChatCompletionValidationException( - message: "Chat completion validation error occurred, fix errors and try again.", + throw createChatCompletionValidationException( nullChatCompletionException); } catch (InvalidChatCompletionException invalidChatCompletionException) { - throw new ChatCompletionValidationException( - message: "Chat completion validation error occurred, fix errors and try again.", + throw createChatCompletionValidationException( invalidChatCompletionException); } catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) @@ -90,5 +89,12 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction failedChatCompletionServiceException); } } + + private static ChatCompletionValidationException createChatCompletionValidationException(Xeption innerException) + { + return new ChatCompletionValidationException( + message: "Chat completion validation error occurred, fix errors and try again.", + innerException); + } } } \ No newline at end of file From c21ac0c249a7b78be903a08c9a806432bbd73320 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 03:13:07 -0700 Subject: [PATCH 15/31] Added create methods to both ChatCompletions.Exceptions.cs and ChatCompletionServiceTests.cs as well as refactored code --- .../ChatCompletionServiceTests.Validations.Send.cs | 6 ++---- .../ChatCompletions/ChatCompletionServiceTests.cs | 8 ++++++++ .../Exceptions/InvalidChatCompletionException.cs | 3 +-- .../ChatCompletionService.Exceptions.cs | 11 +++++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs index a74bb45e..b33af733 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs @@ -58,8 +58,7 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsNullAsync() invalidChatCompletion.Request = null; var invalidChatCompletionException = - new InvalidChatCompletionException( - message: "Chat completion is invalid."); + createInvalidChatCompletionException(); invalidChatCompletionException.AddData( key: nameof(ChatCompletion.Request), @@ -107,8 +106,7 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsInvalidAsync(s }; var invalidChatCompletionException = - new InvalidChatCompletionException( - message: "Chat completion is invalid."); + createInvalidChatCompletionException(); invalidChatCompletionException.AddData( key: nameof(ChatCompletion.Request.Model), diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index 465752a3..4243b7df 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -13,9 +13,11 @@ using Standard.AI.OpenAI.Brokers.DateTimes; using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; +using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalChatCompletions; using Standard.AI.OpenAI.Services.Foundations.ChatCompletions; using Tynamix.ObjectFiller; +using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ChatCompletions @@ -154,5 +156,11 @@ private static Filler ChatCompletionFiller() return filler; } + + private static InvalidChatCompletionException createInvalidChatCompletionException() + { + return new InvalidChatCompletionException( + message: "Chat completion is invalid."); + } } } diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs index 57f8d84d..976a17fc 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs @@ -10,8 +10,7 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti public class InvalidChatCompletionException : Xeption { public InvalidChatCompletionException(string message) - : base( - message: "Chat completion is invalid.") + : base(message) { } public InvalidChatCompletionException(string message, Xeption innerException) : base(message, innerException) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 9a15c1d9..f1701a42 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -7,6 +7,7 @@ using RESTFulSense.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; +using Xeptions; namespace Standard.AI.OpenAI.Services.Foundations.ChatCompletions { @@ -59,8 +60,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseBadRequestException httpResponseBadRequestException) { var invalidChatCompletionException = - new InvalidChatCompletionException( - message: "Chat completion is invalid.", + createInvalidChatCompletionException( httpResponseBadRequestException); throw new ChatCompletionDependencyValidationException(invalidChatCompletionException); @@ -88,5 +88,12 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction failedChatCompletionServiceException); } } + + private static InvalidChatCompletionException createInvalidChatCompletionException(Xeption innerException) + { + return new InvalidChatCompletionException( + message: "Chat completion is invalid.", + innerException); + } } } \ No newline at end of file From efdd319fab13994502c4f5bbf3cc560b7726b407 Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 03:21:24 -0700 Subject: [PATCH 16/31] Updated NullChatCompletionException class's constructor in which the error message was hard coded in. Updated all relevant service files to include message. --- .../ChatCompletionServiceTests.Validations.Send.cs | 3 ++- .../Exceptions/NullChatCompletionException.cs | 5 ++--- .../ChatCompletions/ChatCompletionService.Validations.cs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs index 8557d1e4..386cdb59 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs @@ -21,7 +21,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfChatCompletionIsNullAsy ChatCompletion nullChatCompletion = null; var nullChatCompletionException = - new NullChatCompletionException(); + new NullChatCompletionException( + message: "Chat completion is null."); var expectedChatCompletionValidationException = new ChatCompletionValidationException( diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs index 9e48cbc3..f850d819 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs @@ -8,9 +8,8 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti { public class NullChatCompletionException : Xeption { - public NullChatCompletionException() - : base( - message: "Chat completion is null.") + public NullChatCompletionException(string message) + : base(message) { } public NullChatCompletionException(string message, Xeption innerException) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs index d23e5168..c57fc05a 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Validations.cs @@ -30,7 +30,8 @@ private void ValidateChatCompletionIsNotNull(ChatCompletion chatCompletion) { if (chatCompletion is null) { - throw new NullChatCompletionException(); + throw new NullChatCompletionException( + message: "Chat completion is null."); } } From 7e584b314f90f7b82980a5a1da86b1d600673fcf Mon Sep 17 00:00:00 2001 From: Lezune Date: Fri, 31 May 2024 03:24:49 -0700 Subject: [PATCH 17/31] Added create methods to both ChatCompletions.Exceptions.cs and ChatCompletionServiceTests.cs as well as refactored code --- .../ChatCompletionService.Exceptions.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 09b1a050..70f19452 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -38,8 +38,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedChatCompletionException = - new UnauthorizedChatCompletionException( - message: "Unauthorized chat completion request, fix errors and try again.", + createUnauthorizedChatCompletionException( httpResponseUnauthorizedException); throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); @@ -47,8 +46,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedChatCompletionException = - new UnauthorizedChatCompletionException( - message: "Unauthorized chat completion request, fix errors and try again.", + createUnauthorizedChatCompletionException( httpResponseForbiddenException); throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); @@ -90,5 +88,12 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction failedChatCompletionServiceException); } } + + private static UnauthorizedChatCompletionException createUnauthorizedChatCompletionException(Exception innerException) + { + return new UnauthorizedChatCompletionException( + message: "Unauthorized chat completion request, fix errors and try again.", + innerException); + } } } \ No newline at end of file From 63a7cb0e42e6ca2cc1e810aee1333e882f9b4149 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 08:11:43 -0700 Subject: [PATCH 18/31] Reverted Unit Test files and updated create method declaration and calls to adhere to method naming standards --- .../ChatCompletionServiceTests.Exceptions.Send.cs | 15 +++++++++------ .../ChatCompletions/ChatCompletionServiceTests.cs | 9 --------- .../ChatCompletionService.Exceptions.cs | 10 +++++----- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs index ff2a00f3..31bb0a9f 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs @@ -32,8 +32,9 @@ private async Task ShouldThrowDependencyExceptionOnSendIfUrlNotFoundAsync() innerException: httpResponseUrlNotFoundException); var expectedChatCompletionDependencyException = - createChatCompletionDependencyException( - innerException: invalidConfigurationChatCompletionException); + new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + innerException: invalidConfigurationChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -77,8 +78,9 @@ private async Task ShouldThrowDependencyExceptionOnSendIfUnauthorizedAsync( innerException: unauthorizedException); var expectedChatCompletionDependencyException = - createChatCompletionDependencyException( - innerException: unauthorizedChatCompletionException); + new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + innerException: unauthorizedChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -258,8 +260,9 @@ private async Task ShouldThrowDependencyExceptionOnSendIfHttpResponseErrorOccurr innerException: httpResponseException); var expectedChatCompletionDependencyException = - createChatCompletionDependencyException( - innerException: failedServerChatCompletionException); + new ChatCompletionDependencyException( + message: "Chat completion dependency error occurred, contact support.", + innerException: failedServerChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index e522a5a4..465752a3 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -13,11 +13,9 @@ using Standard.AI.OpenAI.Brokers.DateTimes; using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; -using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalChatCompletions; using Standard.AI.OpenAI.Services.Foundations.ChatCompletions; using Tynamix.ObjectFiller; -using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ChatCompletions @@ -156,12 +154,5 @@ private static Filler ChatCompletionFiller() return filler; } - - private static ChatCompletionDependencyException createChatCompletionDependencyException(Xeption innerException) - { - return new ChatCompletionDependencyException( - message: "Chat completion dependency error occurred, contact support.", - innerException); - } } } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index c211d5e5..b29d1e6e 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -34,7 +34,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var invalidConfigurationChatCompletionException = new InvalidConfigurationChatCompletionException(httpResponseUrlNotFoundException); - throw createChatCompletionDependencyException( + throw CreateChatCompletionDependencyException( invalidConfigurationChatCompletionException); } catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) @@ -42,7 +42,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var unauthorizedChatCompletionException = new UnauthorizedChatCompletionException(httpResponseUnauthorizedException); - throw createChatCompletionDependencyException( + throw CreateChatCompletionDependencyException( unauthorizedChatCompletionException); } catch (HttpResponseForbiddenException httpResponseForbiddenException) @@ -50,7 +50,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var unauthorizedChatCompletionException = new UnauthorizedChatCompletionException(httpResponseForbiddenException); - throw createChatCompletionDependencyException( + throw CreateChatCompletionDependencyException( unauthorizedChatCompletionException); } catch (HttpResponseNotFoundException httpResponseNotFoundException) @@ -79,7 +79,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var failedServerChatCompletionException = new FailedServerChatCompletionException(httpResponseException); - throw createChatCompletionDependencyException( + throw CreateChatCompletionDependencyException( failedServerChatCompletionException); } catch (Exception exception) @@ -92,7 +92,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } } - private static ChatCompletionDependencyException createChatCompletionDependencyException(Xeption innerException) + private static ChatCompletionDependencyException CreateChatCompletionDependencyException(Xeption innerException) { return new ChatCompletionDependencyException( message: "Chat completion dependency error occurred, contact support.", From 42f4a89261c0efb370c1035e3c19fecb2253dda5 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 08:13:45 -0700 Subject: [PATCH 19/31] Updated create method to adhere to method naming standards --- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 0741bed9..cfa537e4 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -55,7 +55,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var notFoundChatCompletionException = new NotFoundChatCompletionException(httpResponseNotFoundException); - throw createChatCompletionDependencyValidationException( + throw CreateChatCompletionDependencyValidationException( notFoundChatCompletionException); } catch (HttpResponseBadRequestException httpResponseBadRequestException) @@ -63,7 +63,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var invalidChatCompletionException = new InvalidChatCompletionException(httpResponseBadRequestException); - throw createChatCompletionDependencyValidationException( + throw CreateChatCompletionDependencyValidationException( invalidChatCompletionException); } catch (HttpResponseTooManyRequestsException httpResponseTooManyRequestsException) @@ -71,7 +71,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction var excessiveCallChatCompletionException = new ExcessiveCallChatCompletionException(httpResponseTooManyRequestsException); - throw createChatCompletionDependencyValidationException( + throw CreateChatCompletionDependencyValidationException( excessiveCallChatCompletionException); } catch (HttpResponseException httpResponseException) @@ -91,7 +91,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } } - private static ChatCompletionDependencyValidationException createChatCompletionDependencyValidationException(Xeption innerException) + private static ChatCompletionDependencyValidationException CreateChatCompletionDependencyValidationException(Xeption innerException) { return new ChatCompletionDependencyValidationException( "Chat completion dependency validation error occurred, fix errors and try again.", From 2ebbe8db52a93ad977b27a521f4188718c9a94c0 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 08:14:29 -0700 Subject: [PATCH 20/31] Reverted Unit Test files to original state --- .../ChatCompletionServiceTests.Exceptions.Send.cs | 15 +++++++++------ .../ChatCompletions/ChatCompletionServiceTests.cs | 9 --------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs index 5a8e097f..31bb0a9f 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Exceptions.Send.cs @@ -125,8 +125,9 @@ private async Task ShouldThrowDependencyValidationExceptionOnSendIfChatCompletio innerException: httpResponseNotFoundException); var expectedChatCompletionDependencyValidationException = - createChatCompletionDependencyValidationException( - innerException: notFoundChatCompletionException); + new ChatCompletionDependencyValidationException( + message: "Chat completion dependency validation error occurred, fix errors and try again.", + innerException: notFoundChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -169,8 +170,9 @@ private async Task ShouldThrowDependencyValidationExceptionOnSendIfBadRequestErr innerException: httpResponseBadRequestException); var expectedChatCompletionDependencyValidationException = - createChatCompletionDependencyValidationException( - innerException: invalidChatCompletionException); + new ChatCompletionDependencyValidationException( + message: "Chat completion dependency validation error occurred, fix errors and try again.", + innerException: invalidChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( @@ -215,8 +217,9 @@ private async Task ShouldThrowDependencyValidationExceptionOnSendIfTooManyReques innerException: httpResponseTooManyRequestsException); var expectedChatCompletionDependencyValidationException = - createChatCompletionDependencyValidationException( - innerException: excessiveCallChatCompletionException); + new ChatCompletionDependencyValidationException( + message: "Chat completion dependency validation error occurred, fix errors and try again.", + innerException: excessiveCallChatCompletionException); this.openAIBrokerMock.Setup(broker => broker.PostChatCompletionRequestAsync( diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index 3568039c..465752a3 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -13,11 +13,9 @@ using Standard.AI.OpenAI.Brokers.DateTimes; using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; -using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalChatCompletions; using Standard.AI.OpenAI.Services.Foundations.ChatCompletions; using Tynamix.ObjectFiller; -using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ChatCompletions @@ -156,12 +154,5 @@ private static Filler ChatCompletionFiller() return filler; } - - private static ChatCompletionDependencyValidationException createChatCompletionDependencyValidationException(Xeption innerException) - { - return new ChatCompletionDependencyValidationException( - "Chat completion dependency validation error occurred, fix errors and try again.", - innerException); - } } } From c9d8b4070eddef2ca2be60e1c13799896872caf4 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 08:16:51 -0700 Subject: [PATCH 21/31] Updated create method to adhere to method naming standards --- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 7d2f1314..7ede95e8 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -23,12 +23,12 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } catch (NullChatCompletionException nullChatCompletionException) { - throw createChatCompletionValidationException( + throw CreateChatCompletionValidationException( nullChatCompletionException); } catch (InvalidChatCompletionException invalidChatCompletionException) { - throw createChatCompletionValidationException( + throw CreateChatCompletionValidationException( invalidChatCompletionException); } catch (HttpResponseUrlNotFoundException httpResponseUrlNotFoundException) @@ -90,7 +90,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } } - private static ChatCompletionValidationException createChatCompletionValidationException(Xeption innerException) + private static ChatCompletionValidationException CreateChatCompletionValidationException(Xeption innerException) { return new ChatCompletionValidationException( message: "Chat completion validation error occurred, fix errors and try again.", From bdf3ef94efc25040a86d5a50e22f5bd984bcc646 Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 08:17:31 -0700 Subject: [PATCH 22/31] Reverted Unit Test files to original state --- ...ChatCompletionServiceTests.Validations.Send.cs | 15 +++++++++------ .../ChatCompletions/ChatCompletionServiceTests.cs | 9 --------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs index 697f766d..8557d1e4 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs @@ -24,8 +24,9 @@ private async Task ShouldThrowValidationExceptionOnSendIfChatCompletionIsNullAsy new NullChatCompletionException(); var expectedChatCompletionValidationException = - createChatCompletionValidationException( - innerException: nullChatCompletionException); + new ChatCompletionValidationException( + message: "Chat completion validation error occurred, fix errors and try again.", + innerException: nullChatCompletionException); // when ValueTask sendChatCompletionTask = @@ -64,8 +65,9 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsNullAsync() values: "Value is required"); var expectedChatCompletionValidationException = - createChatCompletionValidationException( - innerException: invalidChatCompletionException); + new ChatCompletionValidationException( + message: "Chat completion validation error occurred, fix errors and try again.", + innerException: invalidChatCompletionException); // when ValueTask sendChatCompletionTask = @@ -115,8 +117,9 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsInvalidAsync(s values: "Value is required"); var expectedChatCompletionValidationException = - createChatCompletionValidationException( - innerException: invalidChatCompletionException); + new ChatCompletionValidationException( + message: "Chat completion validation error occurred, fix errors and try again.", + innerException: invalidChatCompletionException); // when ValueTask sendChatCompletionTask = diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index bdeb28f5..465752a3 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -13,11 +13,9 @@ using Standard.AI.OpenAI.Brokers.DateTimes; using Standard.AI.OpenAI.Brokers.OpenAIs; using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions; -using Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Exceptions; using Standard.AI.OpenAI.Models.Services.Foundations.ExternalChatCompletions; using Standard.AI.OpenAI.Services.Foundations.ChatCompletions; using Tynamix.ObjectFiller; -using Xeptions; using Xunit; namespace Standard.AI.OpenAI.Tests.Unit.Services.Foundations.ChatCompletions @@ -156,12 +154,5 @@ private static Filler ChatCompletionFiller() return filler; } - - private static ChatCompletionValidationException createChatCompletionValidationException(Xeption innerException) - { - return new ChatCompletionValidationException( - message: "Chat completion validation error occurred, fix errors and try again.", - innerException); - } } } From 5780832564793aa8174db783bb0ea2493ad395ca Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 08:21:19 -0700 Subject: [PATCH 23/31] Updated create method to adhere to method naming standards --- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index f1701a42..399f96ad 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -60,7 +60,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseBadRequestException httpResponseBadRequestException) { var invalidChatCompletionException = - createInvalidChatCompletionException( + CreateInvalidChatCompletionException( httpResponseBadRequestException); throw new ChatCompletionDependencyValidationException(invalidChatCompletionException); @@ -89,7 +89,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } } - private static InvalidChatCompletionException createInvalidChatCompletionException(Xeption innerException) + private static InvalidChatCompletionException CreateInvalidChatCompletionException(Xeption innerException) { return new InvalidChatCompletionException( message: "Chat completion is invalid.", From 09f3b341fa6c29714d359e9e69999df6bed64d6e Mon Sep 17 00:00:00 2001 From: Lezune Date: Thu, 6 Jun 2024 08:27:01 -0700 Subject: [PATCH 24/31] Updated create method to adhere to method naming standards --- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 70f19452..e67ec4ea 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -38,7 +38,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseUnauthorizedException httpResponseUnauthorizedException) { var unauthorizedChatCompletionException = - createUnauthorizedChatCompletionException( + CreateUnauthorizedChatCompletionException( httpResponseUnauthorizedException); throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); @@ -46,7 +46,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction catch (HttpResponseForbiddenException httpResponseForbiddenException) { var unauthorizedChatCompletionException = - createUnauthorizedChatCompletionException( + CreateUnauthorizedChatCompletionException( httpResponseForbiddenException); throw new ChatCompletionDependencyException(unauthorizedChatCompletionException); @@ -89,7 +89,7 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } } - private static UnauthorizedChatCompletionException createUnauthorizedChatCompletionException(Exception innerException) + private static UnauthorizedChatCompletionException CreateUnauthorizedChatCompletionException(Exception innerException) { return new UnauthorizedChatCompletionException( message: "Unauthorized chat completion request, fix errors and try again.", From 946ac0b82caa10f1e59f80301791a22fcebf3db2 Mon Sep 17 00:00:00 2001 From: Lezune Date: Tue, 11 Jun 2024 14:03:58 -0700 Subject: [PATCH 25/31] Refactored Code --- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index b56c4abd..ba1b07e3 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -117,28 +117,28 @@ private static ChatCompletionValidationException CreateChatCompletionValidationE { return new ChatCompletionValidationException( message: "Chat completion validation error occurred, fix errors and try again.", - innerException); + innerException: innerException); } private static ChatCompletionDependencyException CreateChatCompletionDependencyException(Xeption innerException) { return new ChatCompletionDependencyException( message: "Chat completion dependency error occurred, contact support.", - innerException); + innerException: innerException); } private static ChatCompletionDependencyValidationException CreateChatCompletionDependencyValidationException(Xeption innerException) { return new ChatCompletionDependencyValidationException( "Chat completion dependency validation error occurred, fix errors and try again.", - innerException); + innerException: innerException); } private static ChatCompletionServiceException CreateChatCompletionServiceException(Xeption innerException) { return new ChatCompletionServiceException( message: "Chat completion service error occurred, contact support.", - innerException); + innerException: innerException); } private static NullChatCompletionException CreateNullChatCompletionException() From 0c582192972a1504333e4b7b9a39da1427d431b9 Mon Sep 17 00:00:00 2001 From: Lezune Date: Tue, 11 Jun 2024 15:39:14 -0700 Subject: [PATCH 26/31] Refactored Code --- .../ChatCompletionService.Exceptions.cs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index ba1b07e3..69b6afb1 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -15,7 +15,8 @@ internal partial class ChatCompletionService { private delegate ValueTask ReturningChatCompletionFunction(); - private async ValueTask TryCatch(ReturningChatCompletionFunction returningChatCompletionFunction) + private async ValueTask TryCatch( + ReturningChatCompletionFunction returningChatCompletionFunction) { try { @@ -105,7 +106,8 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction { var failedChatCompletionServiceException = new FailedChatCompletionServiceException( - message: "Failed Chat Completion Service Exception occurred, please contact support for assistance.", + message: "Failed Chat Completion Service Exception occurred, " + + "please contact support for assistance.", exception); throw CreateChatCompletionServiceException( @@ -113,32 +115,36 @@ private async ValueTask TryCatch(ReturningChatCompletionFunction } } - private static ChatCompletionValidationException CreateChatCompletionValidationException(Xeption innerException) + private static ChatCompletionValidationException CreateChatCompletionValidationException( + Xeption innerException) { return new ChatCompletionValidationException( message: "Chat completion validation error occurred, fix errors and try again.", - innerException: innerException); + innerException); } - private static ChatCompletionDependencyException CreateChatCompletionDependencyException(Xeption innerException) + private static ChatCompletionDependencyException CreateChatCompletionDependencyException( + Xeption innerException) { return new ChatCompletionDependencyException( message: "Chat completion dependency error occurred, contact support.", - innerException: innerException); + innerException); } - private static ChatCompletionDependencyValidationException CreateChatCompletionDependencyValidationException(Xeption innerException) + private static ChatCompletionDependencyValidationException CreateChatCompletionDependencyValidationException( + Xeption innerException) { return new ChatCompletionDependencyValidationException( "Chat completion dependency validation error occurred, fix errors and try again.", - innerException: innerException); + innerException); } - private static ChatCompletionServiceException CreateChatCompletionServiceException(Xeption innerException) + private static ChatCompletionServiceException CreateChatCompletionServiceException( + Xeption innerException) { return new ChatCompletionServiceException( message: "Chat completion service error occurred, contact support.", - innerException: innerException); + innerException); } private static NullChatCompletionException CreateNullChatCompletionException() From ebfa48ba2c25c498e0db493dd796cbd81a8f145d Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 12 Jun 2024 21:31:26 -0700 Subject: [PATCH 27/31] Removed Extra lines at the end of files and added line break to method declarations larger than 120 characters that needed a break after the return type. --- .../Exceptions/ChatCompletionDependencyException.cs | 2 +- .../ChatCompletionDependencyValidationException.cs | 2 +- .../Exceptions/ChatCompletionValidationException.cs | 2 +- .../Exceptions/ExcessiveCallChatCompletionException.cs | 2 +- .../Exceptions/FailedChatCompletionServiceException.cs | 2 +- .../Exceptions/InvalidChatCompletionException.cs | 2 +- .../InvalidConfigurationChatCompletionException.cs | 2 +- .../Exceptions/NotFoundChatCompletionException.cs | 2 +- .../Exceptions/NullChatCompletionException.cs | 1 - .../Exceptions/UnauthorizedChatCompletionException.cs | 2 +- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 5 +++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs index 339c5dd2..09edaa15 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyException.cs @@ -12,4 +12,4 @@ public ChatCompletionDependencyException(string message, Xeption innerException) : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs index 7b23d6d5..c2df38dd 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionDependencyValidationException.cs @@ -12,4 +12,4 @@ public ChatCompletionDependencyValidationException(string message, Xeption inner : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs index ee30f61d..a202d9c7 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ChatCompletionValidationException.cs @@ -12,4 +12,4 @@ public ChatCompletionValidationException(string message, Xeption innerException) : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs index 402fbf81..f1329cae 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/ExcessiveCallChatCompletionException.cs @@ -13,4 +13,4 @@ public ExcessiveCallChatCompletionException(string message, Exception innerExcep : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs index dab5bfdb..57cbf7c8 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/FailedChatCompletionServiceException.cs @@ -13,4 +13,4 @@ public FailedChatCompletionServiceException(string message, Exception innerExcep : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs index 976a17fc..7a5d4202 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs @@ -16,4 +16,4 @@ public InvalidChatCompletionException(string message, Xeption innerException) : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs index 821eec6d..bdc02c4d 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidConfigurationChatCompletionException.cs @@ -13,4 +13,4 @@ public InvalidConfigurationChatCompletionException(string message, Exception inn : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs index 46f1b734..a217fab3 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NotFoundChatCompletionException.cs @@ -13,4 +13,4 @@ public NotFoundChatCompletionException(string message, Exception innerException) : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs index f850d819..dc545aeb 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs @@ -11,7 +11,6 @@ public class NullChatCompletionException : Xeption public NullChatCompletionException(string message) : base(message) { } - public NullChatCompletionException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs index 5a4185ac..6fd5cb2b 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/UnauthorizedChatCompletionException.cs @@ -13,4 +13,4 @@ public UnauthorizedChatCompletionException(string message, Exception innerExcept : base(message, innerException) { } } -} +} \ No newline at end of file diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 69b6afb1..68f738ef 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -131,9 +131,10 @@ private static ChatCompletionDependencyException CreateChatCompletionDependencyE innerException); } - private static ChatCompletionDependencyValidationException CreateChatCompletionDependencyValidationException( - Xeption innerException) + private static ChatCompletionDependencyValidationException + CreateChatCompletionDependencyValidationException(Xeption innerException) { + return new ChatCompletionDependencyValidationException( "Chat completion dependency validation error occurred, fix errors and try again.", innerException); From 79795ef8353a9714f7ae3e0da6987e9a1351bb0c Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 12 Jun 2024 21:49:47 -0700 Subject: [PATCH 28/31] Added back the line break in class declaration where there was two or more constructors --- .../ChatCompletions/Exceptions/InvalidChatCompletionException.cs | 1 + .../ChatCompletions/Exceptions/NullChatCompletionException.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs index 7a5d4202..e7ee130e 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/InvalidChatCompletionException.cs @@ -12,6 +12,7 @@ public class InvalidChatCompletionException : Xeption public InvalidChatCompletionException(string message) : base(message) { } + public InvalidChatCompletionException(string message, Xeption innerException) : base(message, innerException) { } diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs index dc545aeb..f850d819 100644 --- a/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ChatCompletions/Exceptions/NullChatCompletionException.cs @@ -11,6 +11,7 @@ public class NullChatCompletionException : Xeption public NullChatCompletionException(string message) : base(message) { } + public NullChatCompletionException(string message, Xeption innerException) : base(message, innerException) { } From c3fa328edd14edf27b83c33046ec38b4c2cbc64c Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 12 Jun 2024 21:53:57 -0700 Subject: [PATCH 29/31] Added a line break for each method declaration that was longer than 120 characters. Added line break between constructors in class declarations. --- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 68f738ef..02219996 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -118,6 +118,7 @@ private async ValueTask TryCatch( private static ChatCompletionValidationException CreateChatCompletionValidationException( Xeption innerException) { + return new ChatCompletionValidationException( message: "Chat completion validation error occurred, fix errors and try again.", innerException); @@ -126,6 +127,7 @@ private static ChatCompletionValidationException CreateChatCompletionValidationE private static ChatCompletionDependencyException CreateChatCompletionDependencyException( Xeption innerException) { + return new ChatCompletionDependencyException( message: "Chat completion dependency error occurred, contact support.", innerException); @@ -143,6 +145,7 @@ private static ChatCompletionDependencyValidationException private static ChatCompletionServiceException CreateChatCompletionServiceException( Xeption innerException) { + return new ChatCompletionServiceException( message: "Chat completion service error occurred, contact support.", innerException); From b9c2df910804fe4013af5de4afee0238e6b4aa34 Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 12 Jun 2024 22:20:01 -0700 Subject: [PATCH 30/31] Reverted method call to what is was in previous commit --- .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 02219996..6319f84a 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -133,8 +133,8 @@ private static ChatCompletionDependencyException CreateChatCompletionDependencyE innerException); } - private static ChatCompletionDependencyValidationException - CreateChatCompletionDependencyValidationException(Xeption innerException) + private static ChatCompletionDependencyValidationException CreateChatCompletionDependencyValidationException( + Xeption innerException) { return new ChatCompletionDependencyValidationException( From 8e399f74d0a2c7e2df0564ca442894fdbae6a7ae Mon Sep 17 00:00:00 2001 From: Lezune Date: Wed, 12 Jun 2024 22:29:32 -0700 Subject: [PATCH 31/31] Removed create method in the unit test class and refactored code. --- .../ChatCompletionServiceTests.Validations.Send.cs | 6 ++++-- .../ChatCompletions/ChatCompletionServiceTests.cs | 6 ------ .../ChatCompletions/ChatCompletionService.Exceptions.cs | 4 ---- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs index 4add66c6..41b043fa 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.Validations.Send.cs @@ -59,7 +59,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsNullAsync() invalidChatCompletion.Request = null; var invalidChatCompletionException = - createInvalidChatCompletionException(); + new InvalidChatCompletionException( + message: "Chat completion is invalid."); ; invalidChatCompletionException.AddData( key: nameof(ChatCompletion.Request), @@ -107,7 +108,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsInvalidAsync(s }; var invalidChatCompletionException = - createInvalidChatCompletionException(); + new InvalidChatCompletionException( + message: "Chat completion is invalid."); invalidChatCompletionException.AddData( key: nameof(ChatCompletion.Request.Model), diff --git a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs index 4243b7df..07d47adb 100644 --- a/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs +++ b/Standard.AI.OpenAI.Tests.Unit/Services/Foundations/ChatCompletions/ChatCompletionServiceTests.cs @@ -156,11 +156,5 @@ private static Filler ChatCompletionFiller() return filler; } - - private static InvalidChatCompletionException createInvalidChatCompletionException() - { - return new InvalidChatCompletionException( - message: "Chat completion is invalid."); - } } } diff --git a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs index 6319f84a..69b6afb1 100644 --- a/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs +++ b/Standard.AI.OpenAI/Services/Foundations/ChatCompletions/ChatCompletionService.Exceptions.cs @@ -118,7 +118,6 @@ private async ValueTask TryCatch( private static ChatCompletionValidationException CreateChatCompletionValidationException( Xeption innerException) { - return new ChatCompletionValidationException( message: "Chat completion validation error occurred, fix errors and try again.", innerException); @@ -127,7 +126,6 @@ private static ChatCompletionValidationException CreateChatCompletionValidationE private static ChatCompletionDependencyException CreateChatCompletionDependencyException( Xeption innerException) { - return new ChatCompletionDependencyException( message: "Chat completion dependency error occurred, contact support.", innerException); @@ -136,7 +134,6 @@ private static ChatCompletionDependencyException CreateChatCompletionDependencyE private static ChatCompletionDependencyValidationException CreateChatCompletionDependencyValidationException( Xeption innerException) { - return new ChatCompletionDependencyValidationException( "Chat completion dependency validation error occurred, fix errors and try again.", innerException); @@ -145,7 +142,6 @@ private static ChatCompletionDependencyValidationException CreateChatCompletionD private static ChatCompletionServiceException CreateChatCompletionServiceException( Xeption innerException) { - return new ChatCompletionServiceException( message: "Chat completion service error occurred, contact support.", innerException);