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:Title: Update documentation for API endpoints and usage examples #87

Merged
merged 1 commit into from
Sep 24, 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 @@ -3,10 +3,10 @@
namespace OpenAI.JsonConverters
{
/// <inheritdoc />
public sealed class CreateTranscriptionRequestResponseFormatJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenAI.CreateTranscriptionRequestResponseFormat>
public sealed class AudioResponseFormatJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenAI.AudioResponseFormat>
{
/// <inheritdoc />
public override global::OpenAI.CreateTranscriptionRequestResponseFormat Read(
public override global::OpenAI.AudioResponseFormat Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,15 +18,15 @@ public sealed class CreateTranscriptionRequestResponseFormatJsonConverter : glob
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenAI.CreateTranscriptionRequestResponseFormatExtensions.ToEnum(stringValue) ?? default;
return global::OpenAI.AudioResponseFormatExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenAI.CreateTranscriptionRequestResponseFormat)numValue;
return (global::OpenAI.AudioResponseFormat)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -38,12 +38,12 @@ public sealed class CreateTranscriptionRequestResponseFormatJsonConverter : glob
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenAI.CreateTranscriptionRequestResponseFormat value,
global::OpenAI.AudioResponseFormat value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::OpenAI.CreateTranscriptionRequestResponseFormatExtensions.ToValueString(value));
writer.WriteStringValue(global::OpenAI.AudioResponseFormatExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace OpenAI.JsonConverters
{
/// <inheritdoc />
public sealed class CreateTranscriptionRequestResponseFormatNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenAI.CreateTranscriptionRequestResponseFormat?>
public sealed class AudioResponseFormatNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenAI.AudioResponseFormat?>
{
/// <inheritdoc />
public override global::OpenAI.CreateTranscriptionRequestResponseFormat? Read(
public override global::OpenAI.AudioResponseFormat? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,15 +18,15 @@ public sealed class CreateTranscriptionRequestResponseFormatNullableJsonConverte
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::OpenAI.CreateTranscriptionRequestResponseFormatExtensions.ToEnum(stringValue);
return global::OpenAI.AudioResponseFormatExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::OpenAI.CreateTranscriptionRequestResponseFormat)numValue;
return (global::OpenAI.AudioResponseFormat)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -38,7 +38,7 @@ public sealed class CreateTranscriptionRequestResponseFormatNullableJsonConverte
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenAI.CreateTranscriptionRequestResponseFormat? value,
global::OpenAI.AudioResponseFormat? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));
Expand All @@ -49,7 +49,7 @@ public override void Write(
}
else
{
writer.WriteStringValue(global::OpenAI.CreateTranscriptionRequestResponseFormatExtensions.ToValueString(value.Value));
writer.WriteStringValue(global::OpenAI.AudioResponseFormatExtensions.ToValueString(value.Value));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/OpenAI/Generated/JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ namespace OpenAI
typeof(global::OpenAI.JsonConverters.CreateEmbeddingResponseObjectNullableJsonConverter),
typeof(global::OpenAI.JsonConverters.CreateTranscriptionRequestModelJsonConverter),
typeof(global::OpenAI.JsonConverters.CreateTranscriptionRequestModelNullableJsonConverter),
typeof(global::OpenAI.JsonConverters.CreateTranscriptionRequestResponseFormatJsonConverter),
typeof(global::OpenAI.JsonConverters.CreateTranscriptionRequestResponseFormatNullableJsonConverter),
typeof(global::OpenAI.JsonConverters.AudioResponseFormatJsonConverter),
typeof(global::OpenAI.JsonConverters.AudioResponseFormatNullableJsonConverter),
typeof(global::OpenAI.JsonConverters.CreateTranscriptionRequestTimestampGranularitieJsonConverter),
typeof(global::OpenAI.JsonConverters.CreateTranscriptionRequestTimestampGranularitieNullableJsonConverter),
typeof(global::OpenAI.JsonConverters.CreateTranslationRequestModelJsonConverter),
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OpenAI/Generated/JsonSerializerContextTypes.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ public sealed partial class JsonSerializerContextTypes
/// <summary>
///
/// </summary>
public global::OpenAI.CreateTranscriptionRequestResponseFormat? Type237 { get; set; }
public global::OpenAI.AudioResponseFormat? Type237 { get; set; }
/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ partial void ProcessCreateTranscriptionResponseContent(
content: new global::System.Net.Http.StringContent($"{request.Prompt}"),
name: "prompt");
}
if (request.ResponseFormat != global::OpenAI.CreateTranscriptionRequestResponseFormat.Json)
if (request.ResponseFormat != global::OpenAI.AudioResponseFormat.Json)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"),
Expand Down Expand Up @@ -157,7 +157,7 @@ partial void ProcessCreateTranscriptionResponseContent(
/// An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
/// </param>
/// <param name="responseFormat">
/// The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// Default Value: json
/// </param>
/// <param name="temperature">
Expand All @@ -176,7 +176,7 @@ partial void ProcessCreateTranscriptionResponseContent(
global::OpenAI.AnyOf<string, global::OpenAI.CreateTranscriptionRequestModel?> model,
string? language = default,
string? prompt = default,
global::OpenAI.CreateTranscriptionRequestResponseFormat? responseFormat = global::OpenAI.CreateTranscriptionRequestResponseFormat.Json,
global::OpenAI.AudioResponseFormat? responseFormat = global::OpenAI.AudioResponseFormat.Json,
double? temperature = 0,
global::System.Collections.Generic.IList<global::OpenAI.CreateTranscriptionRequestTimestampGranularitie>? timestampGranularities = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ partial void ProcessCreateTranslationResponseContent(
content: new global::System.Net.Http.StringContent($"{request.Prompt}"),
name: "prompt");
}
if (request.ResponseFormat != "json")
if (request.ResponseFormat != global::OpenAI.AudioResponseFormat.Json)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"{request.ResponseFormat}"),
content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"),
name: "response_format");
}
if (request.Temperature != 0)
Expand Down Expand Up @@ -142,7 +142,7 @@ partial void ProcessCreateTranslationResponseContent(
/// An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
/// </param>
/// <param name="responseFormat">
/// The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// Default Value: json
/// </param>
/// <param name="temperature">
Expand All @@ -156,7 +156,7 @@ partial void ProcessCreateTranslationResponseContent(
string filename,
global::OpenAI.AnyOf<string, global::OpenAI.CreateTranslationRequestModel?> model,
string? prompt = default,
string? responseFormat = "json",
global::OpenAI.AudioResponseFormat? responseFormat = global::OpenAI.AudioResponseFormat.Json,
double? temperature = 0,
global::System.Threading.CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public partial interface IAudioClient
/// An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
/// </param>
/// <param name="responseFormat">
/// The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// Default Value: json
/// </param>
/// <param name="temperature">
Expand All @@ -53,7 +53,7 @@ public partial interface IAudioClient
global::OpenAI.AnyOf<string, global::OpenAI.CreateTranscriptionRequestModel?> model,
string? language = default,
string? prompt = default,
global::OpenAI.CreateTranscriptionRequestResponseFormat? responseFormat = global::OpenAI.CreateTranscriptionRequestResponseFormat.Json,
global::OpenAI.AudioResponseFormat? responseFormat = global::OpenAI.AudioResponseFormat.Json,
double? temperature = 0,
global::System.Collections.Generic.IList<global::OpenAI.CreateTranscriptionRequestTimestampGranularitie>? timestampGranularities = default,
global::System.Threading.CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial interface IAudioClient
/// An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
/// </param>
/// <param name="responseFormat">
/// The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// Default Value: json
/// </param>
/// <param name="temperature">
Expand All @@ -45,7 +45,7 @@ public partial interface IAudioClient
string filename,
global::OpenAI.AnyOf<string, global::OpenAI.CreateTranslationRequestModel?> model,
string? prompt = default,
string? responseFormat = "json",
global::OpenAI.AudioResponseFormat? responseFormat = global::OpenAI.AudioResponseFormat.Json,
double? temperature = 0,
global::System.Threading.CancellationToken cancellationToken = default);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
namespace OpenAI
{
/// <summary>
/// The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// Default Value: json
/// </summary>
public enum CreateTranscriptionRequestResponseFormat
public enum AudioResponseFormat
{
/// <summary>
/// `json`, `text`, `srt`, `verbose_json`, or `vtt`.
Expand All @@ -34,35 +34,35 @@ public enum CreateTranscriptionRequestResponseFormat
/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class CreateTranscriptionRequestResponseFormatExtensions
public static class AudioResponseFormatExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this CreateTranscriptionRequestResponseFormat value)
public static string ToValueString(this AudioResponseFormat value)
{
return value switch
{
CreateTranscriptionRequestResponseFormat.Json => "json",
CreateTranscriptionRequestResponseFormat.Text => "text",
CreateTranscriptionRequestResponseFormat.Srt => "srt",
CreateTranscriptionRequestResponseFormat.VerboseJson => "verbose_json",
CreateTranscriptionRequestResponseFormat.Vtt => "vtt",
AudioResponseFormat.Json => "json",
AudioResponseFormat.Text => "text",
AudioResponseFormat.Srt => "srt",
AudioResponseFormat.VerboseJson => "verbose_json",
AudioResponseFormat.Vtt => "vtt",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static CreateTranscriptionRequestResponseFormat? ToEnum(string value)
public static AudioResponseFormat? ToEnum(string value)
{
return value switch
{
"json" => CreateTranscriptionRequestResponseFormat.Json,
"text" => CreateTranscriptionRequestResponseFormat.Text,
"srt" => CreateTranscriptionRequestResponseFormat.Srt,
"verbose_json" => CreateTranscriptionRequestResponseFormat.VerboseJson,
"vtt" => CreateTranscriptionRequestResponseFormat.Vtt,
"json" => AudioResponseFormat.Json,
"text" => AudioResponseFormat.Text,
"srt" => AudioResponseFormat.Srt,
"verbose_json" => AudioResponseFormat.VerboseJson,
"vtt" => AudioResponseFormat.Vtt,
_ => null,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public sealed partial class CreateTranscriptionRequest
public string? Prompt { get; set; }

/// <summary>
/// The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// Default Value: json
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("response_format")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenAI.JsonConverters.CreateTranscriptionRequestResponseFormatJsonConverter))]
public global::OpenAI.CreateTranscriptionRequestResponseFormat? ResponseFormat { get; set; } = global::OpenAI.CreateTranscriptionRequestResponseFormat.Json;
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenAI.JsonConverters.AudioResponseFormatJsonConverter))]
public global::OpenAI.AudioResponseFormat? ResponseFormat { get; set; } = global::OpenAI.AudioResponseFormat.Json;

/// <summary>
/// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ public sealed partial class CreateTranslationRequest
public string? Prompt { get; set; }

/// <summary>
/// The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.<br/>
/// Default Value: json
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("response_format")]
public string? ResponseFormat { get; set; } = "json";
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenAI.JsonConverters.AudioResponseFormatJsonConverter))]
public global::OpenAI.AudioResponseFormat? ResponseFormat { get; set; } = global::OpenAI.AudioResponseFormat.Json;

/// <summary>
/// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.<br/>
Expand Down
Loading
Loading