Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
db6b7e3
Initial speech to text abstractions
rogerbarreto Mar 18, 2025
4bdb7b9
Address some feedback (still more things to address)
stephentoub Mar 18, 2025
14c37c2
Merge branch 'main' of https://github.com/rogerbarreto/extensions int…
rogerbarreto Mar 29, 2025
fad8017
Resolve conflict
rogerbarreto Mar 29, 2025
3448daa
Ensure UT are working before further changes
rogerbarreto Mar 29, 2025
ef93211
Update method names Transcribe / Response to GetText
rogerbarreto Mar 29, 2025
43d610c
Update Test Names to new Method names
rogerbarreto Mar 29, 2025
ff4ae4a
Change interface from IList<IAsyncEnumerable> to one stream item at a…
rogerbarreto Mar 29, 2025
0831000
Update XmlDocs with corret definition, ensure correct naming
rogerbarreto Mar 29, 2025
8c893a9
Dropping the Choice / Message concept, flattering the Message with th…
rogerbarreto Mar 29, 2025
3d91982
Remove CultureInfo complexity from language properties
rogerbarreto Mar 30, 2025
009eeca
Adding Prompt property to options + UT
rogerbarreto Mar 30, 2025
305e7e4
Revert global.json changes
rogerbarreto Mar 30, 2025
1feac6d
Add missing experimental
rogerbarreto Mar 30, 2025
956097d
Fix UT
rogerbarreto Mar 30, 2025
0830a51
Address PR comments
rogerbarreto Mar 31, 2025
72407f2
Fix unit tests
rogerbarreto Mar 31, 2025
3c7e4ae
Fix UT
rogerbarreto Apr 1, 2025
8763c8c
Merge branch 'main' into audio-transcription-abstraction
rogerbarreto Apr 1, 2025
8d473cb
Merge branch 'audio-transcription-abstraction' of https://github.com/…
rogerbarreto Apr 1, 2025
c6c016e
Address PR comments
rogerbarreto Apr 1, 2025
b3d7819
Merge branch 'main' into audio-transcription-abstraction
rogerbarreto Apr 2, 2025
ca1338b
Remove async wrapping
rogerbarreto Apr 2, 2025
d3a14c9
Adjusting concat / text fields
rogerbarreto Apr 2, 2025
263f0e0
Start time and end time added to update + UT covering
rogerbarreto Apr 2, 2025
dd5ec14
AsISpeechToText renaming
rogerbarreto Apr 2, 2025
9eabb98
Remove OpenAIClient ctor + small fixes
rogerbarreto Apr 2, 2025
78e4ebb
Removing rawrepresentation impl from Update -> Response
rogerbarreto Apr 2, 2025
46acd1c
Merge branch 'main' into audio-transcription-abstraction
rogerbarreto Apr 2, 2025
8bf3389
Add missing AsISpeechToText UT
rogerbarreto Apr 2, 2025
c5c6e89
Add GetService UT
rogerbarreto Apr 2, 2025
977a0e5
Warning fix
rogerbarreto Apr 2, 2025
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
Prev Previous commit
Next Next commit
Remove OpenAIClient ctor + small fixes
  • Loading branch information
rogerbarreto committed Apr 2, 2025
commit 9eabb982682e268991549cc1d5daa79975c4f1f4
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,9 @@ internal sealed class OpenAISpeechToTextClient : ISpeechToTextClient
/// <summary>Metadata about the client.</summary>
private readonly SpeechToTextClientMetadata _metadata;

/// <summary>The underlying <see cref="OpenAIClient" />.</summary>
private readonly OpenAIClient? _openAIClient;

/// <summary>The underlying <see cref="AudioClient" />.</summary>
private readonly AudioClient _audioClient;

/// <summary>Initializes a new instance of the <see cref="OpenAISpeechToTextClient"/> class for the specified <see cref="OpenAIClient"/>.</summary>
/// <param name="openAIClient">The underlying client.</param>
/// <param name="modelId">The model to use.</param>
public OpenAISpeechToTextClient(OpenAIClient openAIClient, string modelId)
{
_ = Throw.IfNull(openAIClient);
_ = Throw.IfNullOrWhitespace(modelId);

_openAIClient = openAIClient;
_audioClient = openAIClient.GetAudioClient(modelId);

// https://github.com/openai/openai-dotnet/issues/215
// The endpoint isn't currently exposed, so use reflection to get at it, temporarily. Once packages
// implement the abstractions directly rather than providing adapters on top of the public APIs,
// the package can provide such implementations separate from what's exposed in the public API.
Uri providerUrl = typeof(OpenAIClient).GetField("_endpoint", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
?.GetValue(openAIClient) as Uri ?? _defaultOpenAIEndpoint;

_metadata = new("openai", providerUrl, modelId);
}

/// <summary>Initializes a new instance of the <see cref="OpenAISpeechToTextClient"/> class for the specified <see cref="AudioClient"/>.</summary>
/// <param name="audioClient">The underlying client.</param>
public OpenAISpeechToTextClient(AudioClient audioClient)
Expand Down Expand Up @@ -83,7 +59,6 @@ public OpenAISpeechToTextClient(AudioClient audioClient)
return
serviceKey is not null ? null :
serviceType == typeof(SpeechToTextClientMetadata) ? _metadata :
serviceType == typeof(OpenAIClient) ? _openAIClient :
serviceType == typeof(AudioClient) ? _audioClient :
serviceType.IsInstanceOfType(this) ? this :
null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public override async IAsyncEnumerable<SpeechToTextResponseUpdate> GetStreamingT
private partial void LogCompleted(string methodName);

[LoggerMessage(LogLevel.Trace, "{MethodName} completed: {SpeechToTextResponse}.")]
private partial void LogCompletedSensitive(string methodName, string SpeechToTextResponse);
private partial void LogCompletedSensitive(string methodName, string speechToTextResponse);

[LoggerMessage(LogLevel.Debug, "GetStreamingTextAsync received update.")]
private partial void LogStreamingUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task GetTextAsync_BasicRequestResponse(string? speechLanguage, stri
Assert.Contains("I finally got back to the gym the other day", response.Text);

Assert.NotNull(response.RawRepresentation);
Assert.IsType<OpenAI.Audio.AudioTranscription>(response.RawRepresentation);
Assert.IsType<AudioTranscription>(response.RawRepresentation);
}

[Fact]
Expand Down
Loading