Skip to content

Commit

Permalink
Merge pull request #556 from Lezune/users/Lezune/Foundations-ChatComp…
Browse files Browse the repository at this point in the history
…letions-Update

CODE RUB:  Foundations ChatCompletions Exceptions Update v2.10.1
  • Loading branch information
glhays authored Jun 13, 2024
2 parents 882d8e3 + 8e399f7 commit 9af6fc0
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -58,7 +59,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),
Expand Down Expand Up @@ -106,7 +108,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfRequestIsInvalidAsync(s
};

var invalidChatCompletionException =
new InvalidChatCompletionException();
new InvalidChatCompletionException(
message: "Chat completion is invalid.");

invalidChatCompletionException.AddData(
key: nameof(ChatCompletion.Request.Model),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ 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)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ 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)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ 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)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ 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)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ 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)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@ namespace Standard.AI.OpenAI.Models.Services.Foundations.ChatCompletions.Excepti
{
public class InvalidChatCompletionException : Xeption
{
public InvalidChatCompletionException()
: base(
message: "Chat completion is invalid.")
{ }

public InvalidChatCompletionException(Exception innerException)
: base(
message: "Chat completion is invalid.",
innerException: innerException)
public InvalidChatCompletionException(string message)
: base(message)
{ }

public InvalidChatCompletionException(string message, Xeption innerException)
: base(message, innerException)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ 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)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ 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)
{ }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ 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)
{ }
}
}
}
Loading

0 comments on commit 9af6fc0

Please sign in to comment.