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:Add new endpoints and modify existing schemas in Ultravox API #13

Merged
merged 1 commit into from
Dec 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public sealed partial class UltravoxV1BaseToolDefinition
[global::System.Text.Json.Serialization.JsonPropertyName("requirements")]
public global::Ultravox.UltravoxV1ToolRequirements? Requirements { get; set; }

/// <summary>
/// The maximum amount of time the tool is allowed for execution. The conversation is frozen<br/>
/// while tools run, so prefer sticking to the default unless you're comfortable with that<br/>
/// consequence. If your tool is too slow for the default and can't be made faster, still try to<br/>
/// keep this timeout as low as possible.<br/>
/// Note: For read APIs, 0s actually means unset (i.e. use the default).
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("timeout")]
public string? Timeout { get; set; }

/// <summary>
/// Details for an HTTP tool.
/// </summary>
Expand Down Expand Up @@ -85,6 +95,13 @@ public sealed partial class UltravoxV1BaseToolDefinition
/// <param name="requirements">
/// Requirements that must be fulfilled when creating a call for the tool to be used.
/// </param>
/// <param name="timeout">
/// The maximum amount of time the tool is allowed for execution. The conversation is frozen<br/>
/// while tools run, so prefer sticking to the default unless you're comfortable with that<br/>
/// consequence. If your tool is too slow for the default and can't be made faster, still try to<br/>
/// keep this timeout as low as possible.<br/>
/// Note: For read APIs, 0s actually means unset (i.e. use the default).
/// </param>
/// <param name="http">
/// Details for an HTTP tool.
/// </param>
Expand All @@ -100,6 +117,7 @@ public UltravoxV1BaseToolDefinition(
global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1StaticParameter>? staticParameters,
global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1AutomaticParameter>? automaticParameters,
global::Ultravox.UltravoxV1ToolRequirements? requirements,
string? timeout,
global::Ultravox.UltravoxV1BaseHttpToolDetails? http,
object? client)
{
Expand All @@ -109,6 +127,7 @@ public UltravoxV1BaseToolDefinition(
this.StaticParameters = staticParameters;
this.AutomaticParameters = automaticParameters;
this.Requirements = requirements;
this.Timeout = timeout;
this.Http = http;
this.Client = client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public sealed partial class UltravoxV1CallTool
[global::System.Text.Json.Serialization.JsonPropertyName("automaticParameters")]
public global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1AutomaticParameter>? AutomaticParameters { get; set; }

/// <summary>
/// The maximum amount of time the tool is allowed for execution. The conversation is frozen<br/>
/// while tools run, so prefer sticking to the default unless you're comfortable with that<br/>
/// consequence. If your tool is too slow for the default and can't be made faster, still try to<br/>
/// keep this timeout as low as possible.<br/>
/// Note: For read APIs, 0s actually means unset (i.e. use the default).
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("timeout")]
public string? Timeout { get; set; }

/// <summary>
/// Details for an HTTP tool.
/// </summary>
Expand Down Expand Up @@ -66,6 +76,13 @@ public sealed partial class UltravoxV1CallTool
/// <param name="automaticParameters">
/// Parameters automatically set by the system.
/// </param>
/// <param name="timeout">
/// The maximum amount of time the tool is allowed for execution. The conversation is frozen<br/>
/// while tools run, so prefer sticking to the default unless you're comfortable with that<br/>
/// consequence. If your tool is too slow for the default and can't be made faster, still try to<br/>
/// keep this timeout as low as possible.<br/>
/// Note: For read APIs, 0s actually means unset (i.e. use the default).
/// </param>
/// <param name="http">
/// Details for an HTTP tool.
/// </param>
Expand All @@ -79,13 +96,15 @@ public UltravoxV1CallTool(
global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1DynamicParameter>? dynamicParameters,
global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1StaticParameter>? staticParameters,
global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1AutomaticParameter>? automaticParameters,
string? timeout,
global::Ultravox.UltravoxV1HttpCallToolDetails? http,
object? client)
{
this.Description = description;
this.DynamicParameters = dynamicParameters;
this.StaticParameters = staticParameters;
this.AutomaticParameters = automaticParameters;
this.Timeout = timeout;
this.Http = http;
this.Client = client;
}
Expand Down
8 changes: 8 additions & 0 deletions src/libs/Ultravox/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,10 @@ components:
allOf:
- $ref: '#/components/schemas/ultravox.v1.ToolRequirements'
description: Requirements that must be fulfilled when creating a call for the tool to be used.
timeout:
pattern: '^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$'
type: string
description: "The maximum amount of time the tool is allowed for execution. The conversation is frozen\n while tools run, so prefer sticking to the default unless you're comfortable with that\n consequence. If your tool is too slow for the default and can't be made faster, still try to\n keep this timeout as low as possible.\n Note: For read APIs, 0s actually means unset (i.e. use the default)."
http:
allOf:
- $ref: '#/components/schemas/ultravox.v1.BaseHttpToolDetails'
Expand Down Expand Up @@ -1639,6 +1643,10 @@ components:
items:
$ref: '#/components/schemas/ultravox.v1.AutomaticParameter'
description: Parameters automatically set by the system.
timeout:
pattern: '^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$'
type: string
description: "The maximum amount of time the tool is allowed for execution. The conversation is frozen\n while tools run, so prefer sticking to the default unless you're comfortable with that\n consequence. If your tool is too slow for the default and can't be made faster, still try to\n keep this timeout as low as possible.\n Note: For read APIs, 0s actually means unset (i.e. use the default)."
Comment on lines +1646 to +1649
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider schema reuse for timeout definition.

The timeout field is duplicated between BaseToolDefinition and CallTool with identical pattern and description. Additionally, like its counterpart, it allows negative durations.

Consider:

  1. Creating a shared schema component for the timeout field
  2. Updating the pattern to disallow negative values
# Add to components.schemas
    DurationTimeout:
      pattern: '^(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$'
      type: string
      description: "The maximum amount of time the tool is allowed for execution. The conversation is frozen\n while tools run, so prefer sticking to the default unless you're comfortable with that\n consequence. If your tool is too slow for the default and can't be made faster, still try to\n keep this timeout as low as possible.\n Note: For read APIs, 0s actually means unset (i.e. use the default)."

# Then reference it in both schemas
    timeout:
      $ref: '#/components/schemas/DurationTimeout'

http:
allOf:
- $ref: '#/components/schemas/ultravox.v1.HttpCallToolDetails'
Expand Down
Loading