Skip to content

Commit 95437ee

Browse files
committed
Ensure explicit operators from ClientResult for AudioTranscription
1 parent aa1c930 commit 95437ee

File tree

4 files changed

+9702
-9689
lines changed

4 files changed

+9702
-9689
lines changed

specification/base/typespec/audio/operations.tsp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "@typespec/openapi";
33

44
import "../common";
55
import "./models.tsp";
6+
import "../../../client/models/audio.models.tsp";
67

78
using TypeSpec.Http;
89
using TypeSpec.OpenAPI;
@@ -40,12 +41,7 @@ interface Audio {
4041
| CreateTranscriptionResponseVerboseJson
4142
| CreateTranscriptionResponseJson
4243
| SseResponseOf<CreateTranscriptionResponseStreamEvent>
43-
| {
44-
// TODO: This response is not defined in the OpenAPI spec.
45-
@header contentType: "text/plain";
46-
47-
@body responseBody: string;
48-
}
44+
| DotNetCombinedJsonTranscriptionResponse
4945
| ErrorResponse;
5046

5147
@route("translations")

src/Generated/Models/Audio/AudioTranscription.Serialization.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#nullable disable
44

55
using System;
6+
using System.ClientModel;
67
using System.ClientModel.Primitives;
78
using System.Collections.Generic;
89
using System.Diagnostics.CodeAnalysis;
@@ -246,5 +247,13 @@ protected virtual AudioTranscription PersistableModelCreateCore(BinaryData data,
246247
}
247248

248249
string IPersistableModel<AudioTranscription>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
250+
251+
[Experimental("OPENAI001")]
252+
public static explicit operator AudioTranscription(ClientResult result)
253+
{
254+
using PipelineResponse response = result.GetRawResponse();
255+
using JsonDocument document = JsonDocument.Parse(response.Content);
256+
return DeserializeAudioTranscription(document.RootElement, ModelSerializationExtensions.WireOptions);
257+
}
249258
}
250259
}

src/Generated/OpenAIModelFactory.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,23 @@ public static StreamingAudioTranscriptionTextDoneUpdate StreamingAudioTranscript
164164
return new StreamingAudioTranscriptionTextDoneUpdate(StreamingAudioTranscriptionUpdateKind.TranscriptTextDone, additionalBinaryDataProperties: null, text, transcriptionTokenLogProbabilities.ToList());
165165
}
166166

167+
public static AudioTranscription AudioTranscription(string task = default, string language = default, TimeSpan? duration = default, string text = default, IEnumerable<TranscribedWord> words = default, IEnumerable<TranscribedSegment> segments = default, IEnumerable<AudioTokenLogProbabilityDetails> transcriptionTokenLogProbabilities = default)
168+
{
169+
words ??= new ChangeTrackingList<TranscribedWord>();
170+
segments ??= new ChangeTrackingList<TranscribedSegment>();
171+
transcriptionTokenLogProbabilities ??= new ChangeTrackingList<AudioTokenLogProbabilityDetails>();
172+
173+
return new AudioTranscription(
174+
task,
175+
language,
176+
duration,
177+
text,
178+
words.ToList(),
179+
segments.ToList(),
180+
transcriptionTokenLogProbabilities.ToList(),
181+
additionalBinaryDataProperties: null);
182+
}
183+
167184
public static AudioTranslation AudioTranslation(string task = default, string language = default, TimeSpan? duration = default, string text = default, IEnumerable<TranscribedSegment> segments = default)
168185
{
169186
segments ??= new ChangeTrackingList<TranscribedSegment>();
@@ -1271,23 +1288,6 @@ public static RunStepCollectionOptions RunStepCollectionOptions(string afterId =
12711288
return new RunStepCollectionOptions(afterId, beforeId, pageSizeLimit, order, additionalBinaryDataProperties: null);
12721289
}
12731290

1274-
public static AudioTranscription AudioTranscription(string task = default, string language = default, TimeSpan? duration = default, string text = default, IEnumerable<TranscribedWord> words = default, IEnumerable<TranscribedSegment> segments = default, IEnumerable<AudioTokenLogProbabilityDetails> transcriptionTokenLogProbabilities = default)
1275-
{
1276-
words ??= new ChangeTrackingList<TranscribedWord>();
1277-
segments ??= new ChangeTrackingList<TranscribedSegment>();
1278-
transcriptionTokenLogProbabilities ??= new ChangeTrackingList<AudioTokenLogProbabilityDetails>();
1279-
1280-
return new AudioTranscription(
1281-
task,
1282-
language,
1283-
duration,
1284-
text,
1285-
words.ToList(),
1286-
segments.ToList(),
1287-
transcriptionTokenLogProbabilities.ToList(),
1288-
additionalBinaryDataProperties: null);
1289-
}
1290-
12911291
public static ChatCompletionCollectionOptions ChatCompletionCollectionOptions(string afterId = default, int? pageSizeLimit = default, ChatCompletionCollectionOrder? order = default, IDictionary<string, string> metadata = default, string model = default)
12921292
{
12931293
metadata ??= new ChangeTrackingDictionary<string, string>();

0 commit comments

Comments
 (0)