-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat:Add strict language_detection_options to TranscriptOptionalParams #123
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #nullable enable | ||
|
|
||
| namespace AssemblyAI | ||
| { | ||
| public sealed partial class TranscriptOptionalParamsLanguageDetectionOptions | ||
| { | ||
| /// <summary> | ||
| /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. | ||
| /// </summary> | ||
| public string ToJson( | ||
| global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Serialize( | ||
| this, | ||
| this.GetType(), | ||
| jsonSerializerContext); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. | ||
| /// </summary> | ||
| #if NET8_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] | ||
| #endif | ||
| public string ToJson( | ||
| global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Serialize( | ||
| this, | ||
| jsonSerializerOptions); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON string using the provided JsonSerializerContext. | ||
| /// </summary> | ||
| public static global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions? FromJson( | ||
| string json, | ||
| global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Deserialize( | ||
| json, | ||
| typeof(global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions), | ||
| jsonSerializerContext) as global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON string using the provided JsonSerializerOptions. | ||
| /// </summary> | ||
| #if NET8_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] | ||
| #endif | ||
| public static global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions? FromJson( | ||
| string json, | ||
| global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.Deserialize<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions>( | ||
| json, | ||
| jsonSerializerOptions); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON stream using the provided JsonSerializerContext. | ||
| /// </summary> | ||
| public static async global::System.Threading.Tasks.ValueTask<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions?> FromJsonStreamAsync( | ||
| global::System.IO.Stream jsonStream, | ||
| global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) | ||
| { | ||
| return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( | ||
| jsonStream, | ||
| typeof(global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions), | ||
| jsonSerializerContext).ConfigureAwait(false)) as global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Deserializes a JSON stream using the provided JsonSerializerOptions. | ||
| /// </summary> | ||
| #if NET8_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] | ||
| [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] | ||
| #endif | ||
| public static global::System.Threading.Tasks.ValueTask<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions?> FromJsonStreamAsync( | ||
| global::System.IO.Stream jsonStream, | ||
| global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) | ||
| { | ||
| return global::System.Text.Json.JsonSerializer.DeserializeAsync<global::AssemblyAI.TranscriptOptionalParamsLanguageDetectionOptions?>( | ||
| jsonStream, | ||
| jsonSerializerOptions); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace AssemblyAI | ||
| { | ||
| /// <summary> | ||
| /// Specify options for Automatic Language Detection. | ||
| /// </summary> | ||
| public sealed partial class TranscriptOptionalParamsLanguageDetectionOptions | ||
| { | ||
| /// <summary> | ||
| /// List of languages expected in the audio file. | ||
| /// </summary> | ||
| [global::System.Text.Json.Serialization.JsonPropertyName("expected_languages")] | ||
| public byte[]? ExpectedLanguages { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score.<br/> | ||
| /// Default Value: auto | ||
| /// </summary> | ||
| [global::System.Text.Json.Serialization.JsonPropertyName("fallback_language")] | ||
| public string? FallbackLanguage { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Additional properties that are not explicitly defined in the schema | ||
| /// </summary> | ||
| [global::System.Text.Json.Serialization.JsonExtensionData] | ||
| public global::System.Collections.Generic.IDictionary<string, object> AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary<string, object>(); | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="TranscriptOptionalParamsLanguageDetectionOptions" /> class. | ||
| /// </summary> | ||
| /// <param name="expectedLanguages"> | ||
| /// List of languages expected in the audio file. | ||
| /// </param> | ||
| /// <param name="fallbackLanguage"> | ||
| /// If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score.<br/> | ||
| /// Default Value: auto | ||
| /// </param> | ||
| #if NET7_0_OR_GREATER | ||
| [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] | ||
| #endif | ||
| public TranscriptOptionalParamsLanguageDetectionOptions( | ||
| byte[]? expectedLanguages, | ||
| string? fallbackLanguage) | ||
| { | ||
| this.ExpectedLanguages = expectedLanguages; | ||
| this.FallbackLanguage = fallbackLanguage; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="TranscriptOptionalParamsLanguageDetectionOptions" /> class. | ||
| /// </summary> | ||
| public TranscriptOptionalParamsLanguageDetectionOptions() | ||
| { | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1253,6 +1253,26 @@ components: | |||||||||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||||||||||
| default: false | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| language_detection_options: | ||||||||||||||||||||||||||||||
| x-label: Specify options for Automatic Language Detection. | ||||||||||||||||||||||||||||||
| description: Specify options for Automatic Language Detection. | ||||||||||||||||||||||||||||||
| type: object | ||||||||||||||||||||||||||||||
| additionalProperties: false | ||||||||||||||||||||||||||||||
| properties: | ||||||||||||||||||||||||||||||
| expected_languages: | ||||||||||||||||||||||||||||||
| x-label: Minimum speakers expected | ||||||||||||||||||||||||||||||
| description: List of languages expected in the audio file. | ||||||||||||||||||||||||||||||
| type: array | ||||||||||||||||||||||||||||||
| objects: | ||||||||||||||||||||||||||||||
| x-label: language | ||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||
| fallback_language: | ||||||||||||||||||||||||||||||
| x-label: Fallback language | ||||||||||||||||||||||||||||||
| description: | | ||||||||||||||||||||||||||||||
| If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score. | ||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||
| default: "auto" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+1270
to
+1275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Align fallback_language description with type and constrain values. Doc says specify ["auto"] (array) but the field is a string. Use "auto" (no brackets) and constrain to either a language code or the literal "auto". - fallback_language:
- x-label: Fallback language
- description: |
- If the detected language of the audio file is not in the list of expected languages, the `fallback_language` is used. Specify `["auto"]` to let our model choose the fallback language from `expected_languages` with the highest confidence score.
- type: string
- default: "auto"
+ fallback_language:
+ x-label: Fallback language
+ description: |
+ If the detected language is not in `expected_languages`, this value is used. Set to "auto" to choose the highest-confidence language from `expected_languages`. Requires `expected_languages` to be non-empty when "auto" is used.
+ anyOf:
+ - $ref: "#/components/schemas/TranscriptLanguageCode"
+ - type: string
+ enum: ["auto"]
+ default: "auto"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| language_confidence_threshold: | ||||||||||||||||||||||||||||||
| x-label: Language confidence threshold | ||||||||||||||||||||||||||||||
| description: | | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix invalid OpenAPI: use items (not objects) and correct label/schema for expected_languages.
Array schemas must use items. Current use of objects will break validation/SDK generation. Also the x-label is incorrect.
Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents