Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BROKERS/FOUNDATIONS/CLINETS/ACCEPTANCES/INTEGRATIONS: Post Audio Transcription #292

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
34a57af
DATA: External Audio Transcription Model
Mar 31, 2023
1fa45ad
BROKERS: Post Audio Transcription
Mar 31, 2023
4b514e2
ShouldSendAudioTranscriptionAsync -> FAIL
Mar 31, 2023
65b21c8
SendAudioTranscriptionAsync -> PASS
Mar 31, 2023
2f6064d
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionIsNullAsync -…
Mar 31, 2023
908a3d7
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionIsNullAsync -…
Mar 31, 2023
9b11bd1
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionRequestIsNull…
Mar 31, 2023
1ef3954
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionRequestIsNull…
Mar 31, 2023
975622e
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionRequestIsInva…
Mar 31, 2023
d9bde6f
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionRequestIsInva…
Mar 31, 2023
a4ddedc
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionRequestFilePa…
Mar 31, 2023
e537616
ShouldThrowValidationExceptionOnSendIfAudioTranscriptionRequestFilePa…
Mar 31, 2023
d70eb6c
ShouldThrowDependencyExceptionOnSendIfUrlNotFoundAsync -> FAIL
Catalin-Andronie Apr 2, 2023
75841bc
ShouldThrowDependencyExceptionOnSendIfUrlNotFoundAsync -> PASS
Catalin-Andronie Apr 2, 2023
8474279
ShouldThrowDependencyExceptionOnSendIfUnAuthorizedAsync -> FAIL
Catalin-Andronie Apr 2, 2023
227d187
ShouldThrowDependencyExceptionOnSendIfUnAuthorizedAsync -> PASS
Catalin-Andronie Apr 2, 2023
4fcf39c
ShouldThrowDependencyValidationExceptionOnSendIfAudioTranscriptionNot…
Catalin-Andronie Apr 2, 2023
548f21a
ShouldThrowDependencyValidationExceptionOnSendIfAudioTranscriptionNot…
Catalin-Andronie Apr 2, 2023
6462346
ShouldThrowDependencyValidationExceptionOnSendIfTooManyRequestsOccurr…
Catalin-Andronie Apr 2, 2023
37f12ae
ShouldThrowDependencyValidationExceptionOnSendIfTooManyRequestsOccurr…
Catalin-Andronie Apr 2, 2023
443d551
ShouldThrowDependencyExceptionOnSendIfHttpResponseErrorOccurredAsync …
Catalin-Andronie Apr 2, 2023
cd62b94
ShouldThrowDependencyExceptionOnSendIfHttpResponseErrorOccurredAsync …
Catalin-Andronie Apr 2, 2023
5cd2783
ShouldThrowServiceExceptionOnSendIfServiceErrorOccurredAsync -> FAIL
Catalin-Andronie Apr 2, 2023
de4646a
ShouldThrowServiceExceptionOnSendIfServiceErrorOccurredAsync -> PASS
Catalin-Andronie Apr 2, 2023
9bf897e
CLIENTS: Send Audio Transcription
Catalin-Andronie Apr 2, 2023
3405431
ShouldSendAudioTranscriptionAsync -> PASS
Catalin-Andronie Apr 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization, a coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System.Threading.Tasks;
using Standard.AI.OpenAI.Models.Services.Foundations.AudioTranscriptions;
using Xunit;

namespace Standard.AI.OpenAI.Tests.Integration.APIs.AudioTranscriptions
{
public partial class AudioTranscriptionsApiTests
{
[Theory(Skip = "This test is only for releases")]
[InlineData(@"APIs\AudioTranscriptions\assets\OPENAI000_Getting_Started_15_sec.mp3")]
[InlineData(@"APIs\AudioTranscriptions\assets\OPENAI000_Getting_Started_30_sec.mp3")]
public async Task ShouldSendAudioTranscriptionAsync(string filePath)
{
// given
var inputAudioTranscription = new AudioTranscription
{
Request = new AudioTranscriptionRequest
{
Model = AudioTranscriptionModel.Whisper1,
FilePath = filePath
}
};

// when
AudioTranscription responseAudioTranscription =
await this.openAIClient.AudioTranscriptions.SendAudioTranscriptionAsync(
inputAudioTranscription);

// then
Assert.NotNull(responseAudioTranscription.Response);
Assert.NotNull(responseAudioTranscription.Response.Text);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization, a coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System;
using Standard.AI.OpenAI.Clients.OpenAIs;
using Standard.AI.OpenAI.Models.Configurations;

namespace Standard.AI.OpenAI.Tests.Integration.APIs.AudioTranscriptions
{
public partial class AudioTranscriptionsApiTests
{
private readonly IOpenAIClient openAIClient;

public AudioTranscriptionsApiTests()
{
var openAIConfigurations = new OpenAIConfigurations
{
ApiKey = Environment.GetEnvironmentVariable("ApiKey"),
OrganizationId = Environment.GetEnvironmentVariable("OrgId"),
ApiUrl = "https://api.openai.com/"
};

this.openAIClient = new OpenAIClient(openAIConfigurations);
}
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<Content Include="APIs\AudioTranscriptions\assets\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Standard.AI.OpenAI\Standard.AI.OpenAI.csproj" />
</ItemGroup>
Expand Down
44 changes: 44 additions & 0 deletions Standard.AI.OpenAI.Tests.Unit/AutoRemovableFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ---------------------------------------------------------------
// Copyright (c) Coalition of the Good-Hearted Engineers
// ---------------------------------------------------------------

using System;
using System.IO;

namespace Standard.AI.OpenAI.Tests.Unit
{
internal sealed class AutoRemovableFile : IDisposable
{
public readonly string FilePath;

public AutoRemovableFile(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
throw new System.ArgumentException($"'{nameof(filePath)}' cannot be null or whitespace.", nameof(filePath));

this.FilePath = filePath;
EnsureFileCreated();
}

public void Dispose()
{
EnsureFileDeleted();
}

private void EnsureFileCreated()
{
if (Path.Exists(this.FilePath))
return;

File.WriteAllText(this.FilePath, "");
}

private void EnsureFileDeleted()
{
if (!Path.Exists(this.FilePath))
return;

File.Delete(this.FilePath);
}
}
}
Loading