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

feat:Enhance Ultravox OpenAPI with VadSettings schema for call management #19

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
140 changes: 72 additions & 68 deletions src/libs/Ultravox/Generated/JsonSerializerContextTypes.g.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ partial void ProcessCallsCreateResponseContent(
/// The medium to use for the call initially. May be altered by the client later.<br/>
/// Defaults to voice.
/// </param>
/// <param name="vadSettings">
/// VAD settings for the call.
/// </param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::Ultravox.Call> CallsCreateAsync(
Expand All @@ -246,6 +249,7 @@ partial void ProcessCallsCreateResponseContent(
global::Ultravox.UltravoxV1StartCallRequestFirstSpeaker? firstSpeaker = default,
bool? transcriptOptional = default,
global::Ultravox.UltravoxV1StartCallRequestInitialOutputMedium? initialOutputMedium = default,
global::Ultravox.UltravoxV1VadSettings? vadSettings = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ultravox.UltravoxV1StartCallRequest
Expand All @@ -267,6 +271,7 @@ partial void ProcessCallsCreateResponseContent(
FirstSpeaker = firstSpeaker,
TranscriptOptional = transcriptOptional,
InitialOutputMedium = initialOutputMedium,
VadSettings = vadSettings,
};

return await CallsCreateAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public partial interface ICallsClient
/// The medium to use for the call initially. May be altered by the client later.<br/>
/// Defaults to voice.
/// </param>
/// <param name="vadSettings">
/// VAD settings for the call.
/// </param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::Ultravox.Call> CallsCreateAsync(
Expand All @@ -96,6 +99,7 @@ public partial interface ICallsClient
global::Ultravox.UltravoxV1StartCallRequestFirstSpeaker? firstSpeaker = default,
bool? transcriptOptional = default,
global::Ultravox.UltravoxV1StartCallRequestInitialOutputMedium? initialOutputMedium = default,
global::Ultravox.UltravoxV1VadSettings? vadSettings = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
11 changes: 11 additions & 0 deletions src/libs/Ultravox/Generated/Ultravox.Models.Call.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ public sealed partial class Call
[global::System.Text.Json.Serialization.JsonPropertyName("errorCount")]
public int ErrorCount { get; set; } = default!;

/// <summary>
/// VAD settings for the call.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("vadSettings")]
public global::Ultravox.UltravoxV1VadSettings? VadSettings { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand Down Expand Up @@ -230,6 +236,9 @@ public sealed partial class Call
/// Default Value: 0<br/>
/// Included only in responses
/// </param>
/// <param name="vadSettings">
/// VAD settings for the call.
/// </param>
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public Call(
string? clientVersion,
Expand All @@ -248,6 +257,7 @@ public Call(
string? timeExceededMessage,
string? voice,
bool? transcriptOptional,
global::Ultravox.UltravoxV1VadSettings? vadSettings,
global::System.Guid callId = default!,
global::System.DateTime created = default!,
global::Ultravox.FirstSpeakerEnum firstSpeaker = default!,
Expand Down Expand Up @@ -275,6 +285,7 @@ public Call(
this.Voice = voice;
this.TranscriptOptional = transcriptOptional;
this.ErrorCount = errorCount;
this.VadSettings = vadSettings;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ public sealed partial class UltravoxV1StartCallRequest
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ultravox.JsonConverters.UltravoxV1StartCallRequestInitialOutputMediumJsonConverter))]
public global::Ultravox.UltravoxV1StartCallRequestInitialOutputMedium? InitialOutputMedium { get; set; }

/// <summary>
/// VAD settings for the call.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("vadSettings")]
public global::Ultravox.UltravoxV1VadSettings? VadSettings { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand Down Expand Up @@ -181,6 +187,9 @@ public sealed partial class UltravoxV1StartCallRequest
/// The medium to use for the call initially. May be altered by the client later.<br/>
/// Defaults to voice.
/// </param>
/// <param name="vadSettings">
/// VAD settings for the call.
/// </param>
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public UltravoxV1StartCallRequest(
string? systemPrompt,
Expand All @@ -199,7 +208,8 @@ public UltravoxV1StartCallRequest(
bool? recordingEnabled,
global::Ultravox.UltravoxV1StartCallRequestFirstSpeaker? firstSpeaker,
bool? transcriptOptional,
global::Ultravox.UltravoxV1StartCallRequestInitialOutputMedium? initialOutputMedium)
global::Ultravox.UltravoxV1StartCallRequestInitialOutputMedium? initialOutputMedium,
global::Ultravox.UltravoxV1VadSettings? vadSettings)
{
this.SystemPrompt = systemPrompt;
this.Temperature = temperature;
Expand All @@ -218,6 +228,7 @@ public UltravoxV1StartCallRequest(
this.FirstSpeaker = firstSpeaker;
this.TranscriptOptional = transcriptOptional;
this.InitialOutputMedium = initialOutputMedium;
this.VadSettings = vadSettings;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#nullable enable

namespace Ultravox
{
public sealed partial class UltravoxV1VadSettings
{
/// <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::Ultravox.UltravoxV1VadSettings? FromJson(
string json,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return global::System.Text.Json.JsonSerializer.Deserialize(
json,
typeof(global::Ultravox.UltravoxV1VadSettings),
jsonSerializerContext) as global::Ultravox.UltravoxV1VadSettings;
}

/// <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::Ultravox.UltravoxV1VadSettings? FromJson(
string json,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.Deserialize<global::Ultravox.UltravoxV1VadSettings>(
json,
jsonSerializerOptions);
}

/// <summary>
/// Deserializes a JSON stream using the provided JsonSerializerContext.
/// </summary>
public static async global::System.Threading.Tasks.ValueTask<global::Ultravox.UltravoxV1VadSettings?> FromJsonStreamAsync(
global::System.IO.Stream jsonStream,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return (await global::System.Text.Json.JsonSerializer.DeserializeAsync(
jsonStream,
typeof(global::Ultravox.UltravoxV1VadSettings),
jsonSerializerContext).ConfigureAwait(false)) as global::Ultravox.UltravoxV1VadSettings;
}

/// <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::Ultravox.UltravoxV1VadSettings?> FromJsonStreamAsync(
global::System.IO.Stream jsonStream,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.DeserializeAsync<global::Ultravox.UltravoxV1VadSettings?>(
jsonStream,
jsonSerializerOptions);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#nullable enable

namespace Ultravox
{
/// <summary>
/// Call-level VAD settings.
/// </summary>
public sealed partial class UltravoxV1VadSettings
{
/// <summary>
/// The delay to wait after the last speech frame before ending the user's "turn". Increasing<br/>
/// this value makes the agent wait longer before speaking after the user stops speaking.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("turnEndpointDelay")]
public string? TurnEndpointDelay { get; set; }

/// <summary>
/// The minimum duration of user speech required to be considered a user turn.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("minimumTurnDuration")]
public string? MinimumTurnDuration { get; set; }

/// <summary>
/// The minimum duration of user speech required to interrupt the agent.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("minimumInterruptionDuration")]
public string? MinimumInterruptionDuration { 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="UltravoxV1VadSettings" /> class.
/// </summary>
/// <param name="turnEndpointDelay">
/// The delay to wait after the last speech frame before ending the user's "turn". Increasing<br/>
/// this value makes the agent wait longer before speaking after the user stops speaking.
/// </param>
/// <param name="minimumTurnDuration">
/// The minimum duration of user speech required to be considered a user turn.
/// </param>
/// <param name="minimumInterruptionDuration">
/// The minimum duration of user speech required to interrupt the agent.
/// </param>
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public UltravoxV1VadSettings(
string? turnEndpointDelay,
string? minimumTurnDuration,
string? minimumInterruptionDuration)
{
this.TurnEndpointDelay = turnEndpointDelay;
this.MinimumTurnDuration = minimumTurnDuration;
this.MinimumInterruptionDuration = minimumInterruptionDuration;
}

/// <summary>
/// Initializes a new instance of the <see cref="UltravoxV1VadSettings" /> class.
/// </summary>
public UltravoxV1VadSettings()
{
}
}
}
25 changes: 25 additions & 0 deletions src/libs/Ultravox/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,11 @@ components:
description: The number of errors in this call.
default: 0
readOnly: true
vadSettings:
allOf:
- $ref: '#/components/schemas/ultravox.v1.VadSettings'
description: VAD settings for the call.
nullable: true
CallStage:
required:
- callId
Expand Down Expand Up @@ -1991,6 +1996,10 @@ components:
type: string
description: "The medium to use for the call initially. May be altered by the client later.\n Defaults to voice."
format: enum
vadSettings:
allOf:
- $ref: '#/components/schemas/ultravox.v1.VadSettings'
description: VAD settings for the call.
description: A request to start a call.
ultravox.v1.StaticParameter:
type: object
Expand Down Expand Up @@ -2045,6 +2054,22 @@ components:
type: string
description: Dynamic parameters that must be overridden with an explicit (static) value.
description: 'The requirements for using a tool, which must be satisfied when creating a call with the tool.'
ultravox.v1.VadSettings:
type: object
properties:
turnEndpointDelay:
pattern: '^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$'
type: string
description: "The delay to wait after the last speech frame before ending the user's \"turn\". Increasing\n this value makes the agent wait longer before speaking after the user stops speaking."
minimumTurnDuration:
pattern: '^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$'
type: string
description: The minimum duration of user speech required to be considered a user turn.
minimumInterruptionDuration:
pattern: '^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$'
type: string
description: The minimum duration of user speech required to interrupt the agent.
description: Call-level VAD settings.
securitySchemes:
apiKeyAuth:
type: apiKey
Expand Down
Loading