mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 20:27:21 +00:00
Added transcription of audio and video files to local data sources (#1081)
Co-authored-by: Paul Koudelka <106623909+PaulKoudelka@users.noreply.github.com>
This commit is contained in:
1 parent
8642ce2d81
commit
752f7d828a
82 files changed
+3231
-302
No files matched your search
@@ -0,0 +1,78 @@
|
||||
using System.Net;
|
||||
|
||||
using AIStudio.Provider;
|
||||
|
||||
namespace AIStudio.Tests.Provider;
|
||||
|
||||
/// <summary>
|
||||
/// Checks which answers of a transcription provider refuse the media file itself.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A data source records such a file for good, until it changes. An answer counted here by
|
||||
/// mistake keeps a file out of the index; one missed here uploads the file again with every run.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class MediaFileRejectionTests
|
||||
{
|
||||
private const string OPENAI_DAMAGED_FILE = """
|
||||
{
|
||||
"error": {
|
||||
"message": "Audio file might be corrupted or unsupported",
|
||||
"type": "invalid_request_error",
|
||||
"param": "file",
|
||||
"code": "invalid_value"
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private const string OPENAI_UNKNOWN_MODEL = """
|
||||
{
|
||||
"error": {
|
||||
"message": "Invalid model.",
|
||||
"type": "invalid_request_error",
|
||||
"param": "model",
|
||||
"code": "invalid_value"
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private const string UNDECODABLE_FORMAT = """
|
||||
{
|
||||
"error": {
|
||||
"message": "Could not decode the audio file.",
|
||||
"param": "file"
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
[Test]
|
||||
public void AFileTheProviderCannotReadIsRefused()
|
||||
{
|
||||
Assert.That(BaseProvider.IsMediaFileRejection(HttpStatusCode.BadRequest, OPENAI_DAMAGED_FILE), Is.True);
|
||||
}
|
||||
|
||||
[TestCase(HttpStatusCode.RequestEntityTooLarge)]
|
||||
[TestCase(HttpStatusCode.UnsupportedMediaType)]
|
||||
public void AFileTooLargeOrOfAnUnacceptedTypeIsRefused(HttpStatusCode statusCode)
|
||||
{
|
||||
Assert.That(BaseProvider.IsMediaFileRejection(statusCode, string.Empty), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AProviderWhichDecodesNoWebMRefusesNoSingleFile()
|
||||
{
|
||||
Assert.That(BaseProvider.IsMediaFileRejection(HttpStatusCode.BadRequest, UNDECODABLE_FORMAT), Is.False, "Every file fails the same way, and only another provider helps.");
|
||||
}
|
||||
|
||||
[TestCase(HttpStatusCode.BadRequest, OPENAI_UNKNOWN_MODEL)]
|
||||
[TestCase(HttpStatusCode.BadRequest, "Bad request")]
|
||||
[TestCase(HttpStatusCode.BadRequest, "")]
|
||||
[TestCase(HttpStatusCode.TooManyRequests, OPENAI_DAMAGED_FILE)]
|
||||
[TestCase(HttpStatusCode.Unauthorized, "")]
|
||||
[TestCase(HttpStatusCode.InternalServerError, "")]
|
||||
[TestCase(HttpStatusCode.ServiceUnavailable, "")]
|
||||
public void AFailureWhichMayPassRefusesNoFile(HttpStatusCode statusCode, string responseBody)
|
||||
{
|
||||
Assert.That(BaseProvider.IsMediaFileRejection(statusCode, responseBody), Is.False);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user