Skip to content

Commit

Permalink
Merge branch 'user/lezune/coderub-aifiles-upgrade-v2101' of https://g…
Browse files Browse the repository at this point in the history
…ithub.com/Lezune/Standard.AI.OpenAI into user/lezune/coderub-aifiles-upgrade-v2101

"Pulling remote branch"
  • Loading branch information
Lezune committed Jun 13, 2024
2 parents b36df9b + c719e83 commit 7b4b12a
Show file tree
Hide file tree
Showing 140 changed files with 919 additions and 832 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ private async Task ShouldThrowValidationExceptionOnRetrieveModelByNameIfModelNam
{
// given
var invalidAIModelException =
new InvalidAIModelException();
new InvalidAIModelException(
message: "AI Model is invalid.");

invalidAIModelException.AddData(
key: nameof(AIModel.Name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ private async Task ShouldThrowValidationExceptionOnSendIfAudioTranscriptionIsNul
// given
AudioTranscription audioTranscription = null;

var nullAudioTranscriptionException = new NullAudioTranscriptionException();
var nullAudioTranscriptionException = new NullAudioTranscriptionException(
message: "Audio transcription is null.");

var exceptedAudioTranscriptionValidationException =
new AudioTranscriptionValidationException(
Expand Down Expand Up @@ -56,7 +57,9 @@ private async Task ShouldThrowValidationExceptionOnSendIfAudioTranscriptionReque
Request = null
};

var invalidAudioTranscriptionException = new InvalidAudioTranscriptionException();
var invalidAudioTranscriptionException =
new InvalidAudioTranscriptionException(
message: "Audio transcription is invalid.");

invalidAudioTranscriptionException.AddData(
key: nameof(AudioTranscription.Request),
Expand Down Expand Up @@ -103,7 +106,9 @@ private async Task ShouldThrowValidationExceptionOnSendIfAudioTranscriptionReque
}
};

var invalidAudioTranscriptionException = new InvalidAudioTranscriptionException();
var invalidAudioTranscriptionException =
new InvalidAudioTranscriptionException(
message: "Audio transcription is invalid.");

invalidAudioTranscriptionException.AddData(
key: nameof(AudioTranscriptionRequest.FileName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using RESTFulSense.Exceptions;
using Standard.AI.OpenAI.Brokers.OpenAIs;
using Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions;
using Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions.Exceptions;
using Standard.AI.OpenAI.Models.Services.Foundations.ExternalAudioTranscriptions;
using Standard.AI.OpenAI.Services.Foundations.AudioTranscriptions;
using Tynamix.ObjectFiller;
Expand Down
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 @@ -20,7 +20,9 @@ private async Task ShouldThrowValidationExceptionOnPromptIfCompletionIsNullAsync
{
// given
Completion nullCompletion = null;
var nullCompletionException = new NullCompletionException();
var nullCompletionException =
new NullCompletionException(
message: "Completion is null.");

var exceptedCompletionValidationException =
new CompletionValidationException(
Expand Down Expand Up @@ -56,7 +58,7 @@ private async Task ShouldThrowValidationExceptionOnPromptIfRequestIsNullAsync()
invalidCompletion.Request = null;

var invalidCompletionException =
new InvalidCompletionException();
CreateInvalidCompletionException();

invalidCompletionException.AddData(
key: nameof(Completion.Request),
Expand Down Expand Up @@ -103,7 +105,8 @@ private async Task ShouldThrowValidationExceptionOnPromptIfCompletionIsInvalidAs
}
};

var invalidCompletionException = new InvalidCompletionException();
var invalidCompletionException =
CreateInvalidCompletionException();

invalidCompletionException.AddData(
key: nameof(CompletionRequest.Model),
Expand Down Expand Up @@ -146,7 +149,8 @@ private async Task ShouldThrowValidationExceptionOnPromptIfPromptIsEmptyAsync()
}
};

var invalidCompletionException = new InvalidCompletionException();
var invalidCompletionException =
CreateInvalidCompletionException();

invalidCompletionException.AddData(
key: nameof(CompletionRequest.Prompts),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Standard.AI.OpenAI.Brokers.DateTimes;
using Standard.AI.OpenAI.Brokers.OpenAIs;
using Standard.AI.OpenAI.Models.Services.Foundations.Completions;
using Standard.AI.OpenAI.Models.Services.Foundations.Completions.Exceptions;
using Standard.AI.OpenAI.Models.Services.Foundations.ExternalCompletions;
using Standard.AI.OpenAI.Services.Foundations.Completions;
using Tynamix.ObjectFiller;
Expand Down Expand Up @@ -141,5 +142,11 @@ private static Filler<Completion> CreateCompletionFiller()

return filler;
}

private static InvalidCompletionException CreateInvalidCompletionException()
{
return new InvalidCompletionException(
message: "Invalid completion error occurred, fix errors and try again.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private async Task ShouldThrowValidationExceptionOnSubmitIfFineTuneIsNullAsync()
FineTune nullFineTune = null;

var nullFineTuneException =
new NullFineTuneException();
new NullFineTuneException(
message: "Fine tune is null.");

var expectedFineTuneValidationException =
new FineTuneValidationException(
Expand Down Expand Up @@ -60,7 +61,7 @@ private async Task ShouldThrowValidationExceptionOnSubmitIfFineTuneRequestIsNull
fineTune.Request = nullFineTuneRequest;

var invalidFineTuneException =
new InvalidFineTuneException();
createInvalidFineTuneException();

invalidFineTuneException.AddData(
key: nameof(FineTune.Request),
Expand Down Expand Up @@ -104,7 +105,8 @@ private async Task ShouldThrowValidationExceptionOnSubmitIfFineTuneRequestIsInva
var invalidFineTune = new FineTune();
invalidFineTune.Request = new FineTuneRequest();
invalidFineTune.Request.FileId = invalidText;
var invalidFineTuneException = new InvalidFineTuneException();
var invalidFineTuneException =
createInvalidFineTuneException();

invalidFineTuneException.AddData(
key: nameof(FineTuneRequest.FileId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Standard.AI.OpenAI.Brokers.OpenAIs;
using Standard.AI.OpenAI.Models.Services.Foundations.ExternalFineTunes;
using Standard.AI.OpenAI.Models.Services.Foundations.FineTunes;
using Standard.AI.OpenAI.Models.Services.Foundations.FineTunes.Exceptions;
using Standard.AI.OpenAI.Services.Foundations.FineTunes;
using Tynamix.ObjectFiller;
using Xunit;
Expand Down Expand Up @@ -186,5 +187,11 @@ private static Filler<FineTune> CreateRandomFineTuneFiller()

return filler;
}

private InvalidFineTuneException createInvalidFineTuneException()
{
return new InvalidFineTuneException(
message: "Fine tune is invalid.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfImageGenerationIsNu
ImageGeneration nullImageGeneration = null;

var nullImageGenerationException =
new NullImageGenerationException();
new NullImageGenerationException(
message: "Image generation is null.");

var expectedImageGenerationValidationException =
new ImageGenerationValidationException(
Expand Down Expand Up @@ -58,7 +59,7 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsNullAsync(
invalidImageGeneration.Request = null;

var invalidImageGenerationException =
new InvalidImageGenerationException();
CreateInvalidImageGenerationException();

invalidImageGenerationException.AddData(
key: nameof(ImageGeneration.Request),
Expand Down Expand Up @@ -106,7 +107,7 @@ private async Task ShouldThrowValidationExceptionOnGenerateIfRequestIsInvalidAsy
};

var invalidImageGenerationException =
new InvalidImageGenerationException();
CreateInvalidImageGenerationException();

invalidImageGenerationException.AddData(
key: nameof(ImageGeneration.Request.Prompt),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Standard.AI.OpenAI.Brokers.OpenAIs;
using Standard.AI.OpenAI.Models.Services.Foundations.ExternalImageGenerations;
using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations;
using Standard.AI.OpenAI.Models.Services.Foundations.ImageGenerations.Exceptions;
using Standard.AI.OpenAI.Services.Foundations.ImageGenerations;
using Tynamix.ObjectFiller;
using Xunit;
Expand Down Expand Up @@ -107,5 +108,11 @@ public static TheoryData UnauthorizedExceptions()
new HttpResponseForbiddenException()
};
}

private static InvalidImageGenerationException CreateInvalidImageGenerationException()
{
return new InvalidImageGenerationException(
message: "Invalid image generation error occurred, fix errors and try again.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private void ShouldThrowValidationExceptionOnReadIfFilePathIsInvalid(
{
// given
var invalidFileException =
new InvalidLocalFileException();
new InvalidLocalFileException(
message: "Invalid local file error occurred, fix error and try again.");

invalidFileException.AddData(
key: "FilePath",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ private async Task ShouldThrowValidationExceptionOnRemoveFileIfFileIdIsInvalid(s
{
// given
var invalidAiFileOrchestrationException =
new InvalidAIFileOrchestrationException();
new InvalidAIFileOrchestrationException(
message: "AI file is invalid.");

invalidAiFileOrchestrationException.AddData(
key: nameof(AIFile.Response.Id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ private async Task ShouldThrowValidationExceptionOnUploadIfFileIsNullAsync()
AIFile nullAIFile = null;

var nullAIFileOrchestrationException =
new NullAIFileOrchestrationException();
new NullAIFileOrchestrationException(
message: "AI file is null.");

var expectedAIFileOrchestrationValidationException =
new AIFileOrchestrationValidationException(
Expand Down Expand Up @@ -59,8 +60,9 @@ private async Task ShouldThrowValidationExceptionOnUploadIfRequestIsNullAsync()
// given
var invalidAIFile = new AIFile();

var invalidAIFileOrchestrationException =
new InvalidAIFileOrchestrationException();
var invalidAIFileOrchestrationException =
new InvalidAIFileOrchestrationException(
message: "AI file is invalid.");

invalidAIFileOrchestrationException.AddData(
key: nameof(AIFileRequest),
Expand Down Expand Up @@ -110,7 +112,8 @@ private async Task ShouldThrowValidationExceptionIfRequestIsInvalidAsync(
invalidAIFile.Request.Name = invalidName;

var invalidAIFileOrchestrationException =
new InvalidAIFileOrchestrationException();
new InvalidAIFileOrchestrationException(
message: "AI file is invalid.");

invalidAIFileOrchestrationException.AddData(
key: nameof(AIFileRequest.Name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Standard.AI.OpenAI.Models.Services.Foundations.AIFiles;
using Standard.AI.OpenAI.Models.Services.Foundations.AIFiles.Exceptions;
using Standard.AI.OpenAI.Models.Services.Foundations.LocalFiles.Exceptions;
using Standard.AI.OpenAI.Models.Services.Orchestrations.AIFiles.Exceptions;
using Standard.AI.OpenAI.Services.Foundations.AIFiles;
using Standard.AI.OpenAI.Services.Foundations.LocalFiles;
using Standard.AI.OpenAI.Services.Orchestrations.AIFiles;
Expand Down Expand Up @@ -44,8 +45,13 @@ public static TheoryData DependencyValidationExceptions()

return new TheoryData<Xeption>
{
new LocalFileValidationException(someInnerException),
new LocalFileDependencyValidationException(someInnerException),
new LocalFileValidationException(
message: "Local file validation error occurred, fix error and try again.",
someInnerException),

new LocalFileDependencyValidationException(
message: "Local file dependency validation error occurred, fix the errors and try again.",
someInnerException),

new AIFileValidationException(
message: "AI file validation error occurred, fix errors and try again.",
Expand All @@ -63,9 +69,14 @@ public static TheoryData DependencyExceptions()

return new TheoryData<Xeption>
{
new LocalFileDependencyException(someInnerException),
new LocalFileServiceException(someInnerException),
new LocalFileDependencyException(
message: "Local file dependency error occurred, contact support.",
someInnerException),

new LocalFileServiceException(
message: "Local file service error occurred, contact support.",
someInnerException),

new AIFileDependencyException(
message: "AI file dependency error occurred, contact support.",
someInnerException),
Expand Down
Loading

0 comments on commit 7b4b12a

Please sign in to comment.