Skip to content

Commit

Permalink
feat: Updated OpenAPI spec
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 13, 2024
1 parent 9511271 commit 5ea0edf
Show file tree
Hide file tree
Showing 15 changed files with 815 additions and 587 deletions.
3 changes: 2 additions & 1 deletion src/libs/Cohere/Generated/Cohere.CohereApi.Embed.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ partial void ProcessEmbedResponseContent(
/// - `"search_document"`: Used for embeddings stored in a vector database for search use-cases.<br/>
/// - `"search_query"`: Used for embeddings of search queries run against a vector DB to find relevant documents.<br/>
/// - `"classification"`: Used for embeddings passed through a text classifier.<br/>
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.<br/>
/// - `"image"`: Used for embeddings with image input.
/// </param>
/// <param name="embeddingTypes">
/// Specifies the types of embeddings you want to get back. Not required and default is None, which returns the Embed Floats response type. Can be one or more of the following types.<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ partial void ProcessCreateEmbedJobResponseContent(
/// - `"search_document"`: Used for embeddings stored in a vector database for search use-cases.<br/>
/// - `"search_query"`: Used for embeddings of search queries run against a vector DB to find relevant documents.<br/>
/// - `"classification"`: Used for embeddings passed through a text classifier.<br/>
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.<br/>
/// - `"image"`: Used for embeddings with image input.
/// </param>
/// <param name="name">
/// The name of the embed job.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public sealed partial class CreateEmbedJobRequest
/// - `"search_document"`: Used for embeddings stored in a vector database for search use-cases.<br/>
/// - `"search_query"`: Used for embeddings of search queries run against a vector DB to find relevant documents.<br/>
/// - `"classification"`: Used for embeddings passed through a text classifier.<br/>
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.<br/>
/// - `"image"`: Used for embeddings with image input.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("input_type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.EmbedInputTypeJsonConverter))]
Expand Down
9 changes: 8 additions & 1 deletion src/libs/Cohere/Generated/Cohere.Models.EmbedInputType.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace Cohere
/// - `"search_document"`: Used for embeddings stored in a vector database for search use-cases.<br/>
/// - `"search_query"`: Used for embeddings of search queries run against a vector DB to find relevant documents.<br/>
/// - `"classification"`: Used for embeddings passed through a text classifier.<br/>
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.<br/>
/// - `"image"`: Used for embeddings with image input.
/// </summary>
public enum EmbedInputType
{
Expand All @@ -28,6 +29,10 @@ public enum EmbedInputType
///
/// </summary>
Clustering,
/// <summary>
///
/// </summary>
Image,
}

/// <summary>
Expand All @@ -46,6 +51,7 @@ public static string ToValueString(this EmbedInputType value)
EmbedInputType.SearchQuery => "search_query",
EmbedInputType.Classification => "classification",
EmbedInputType.Clustering => "clustering",
EmbedInputType.Image => "image",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
Expand All @@ -60,6 +66,7 @@ public static string ToValueString(this EmbedInputType value)
"search_query" => EmbedInputType.SearchQuery,
"classification" => EmbedInputType.Classification,
"clustering" => EmbedInputType.Clustering,
"image" => EmbedInputType.Image,
_ => null,
};
}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/Cohere/Generated/Cohere.Models.EmbedRequest.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public sealed partial class EmbedRequest
/// - `"search_document"`: Used for embeddings stored in a vector database for search use-cases.<br/>
/// - `"search_query"`: Used for embeddings of search queries run against a vector DB to find relevant documents.<br/>
/// - `"classification"`: Used for embeddings passed through a text classifier.<br/>
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.
/// - `"clustering"`: Used for the embeddings run through a clustering algorithm.<br/>
/// - `"image"`: Used for embeddings with image input.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("input_type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.EmbedInputTypeJsonConverter))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public sealed partial class JSONResponseFormat2
/// When set to `"json_object"`, the model's output will be a valid JSON Object.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.ResponseFormatTypeJsonConverter))]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.ResponseFormatType2JsonConverter))]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::Cohere.ResponseFormatType Type { get; set; }
public required global::Cohere.ResponseFormatType2 Type { get; set; }

/// <summary>
/// [BETA] A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](/docs/structured-outputs-json#schema-constraints) for more information.<br/>
Expand Down
30 changes: 15 additions & 15 deletions src/libs/Cohere/Generated/Cohere.Models.ResponseFormat2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,35 @@ namespace Cohere
///
/// </summary>
#if NET6_0_OR_GREATER
public global::Cohere.TextResponseFormat? TextFormat { get; init; }
public global::Cohere.TextResponseFormat2? Text { get; init; }
#else
public global::Cohere.TextResponseFormat? TextFormat { get; }
public global::Cohere.TextResponseFormat2? Text { get; }
#endif

/// <summary>
///
/// </summary>
#if NET6_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(TextFormat))]
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Text))]
#endif
public bool IsTextFormat => TextFormat != null;
public bool IsText => Text != null;

/// <summary>
///
/// </summary>
public static implicit operator ResponseFormat2(global::Cohere.TextResponseFormat value) => new ResponseFormat2(value);
public static implicit operator ResponseFormat2(global::Cohere.TextResponseFormat2 value) => new ResponseFormat2(value);

/// <summary>
///
/// </summary>
public static implicit operator global::Cohere.TextResponseFormat?(ResponseFormat2 @this) => @this.TextFormat;
public static implicit operator global::Cohere.TextResponseFormat2?(ResponseFormat2 @this) => @this.Text;

/// <summary>
///
/// </summary>
public ResponseFormat2(global::Cohere.TextResponseFormat? value)
public ResponseFormat2(global::Cohere.TextResponseFormat2? value)
{
TextFormat = value;
Text = value;
}

/// <summary>
Expand Down Expand Up @@ -88,11 +88,11 @@ public ResponseFormat2(global::Cohere.JSONResponseFormat2? value)
///
/// </summary>
public ResponseFormat2(
global::Cohere.TextResponseFormat? textFormat,
global::Cohere.TextResponseFormat2? text,
global::Cohere.JSONResponseFormat2? jSON
)
{
TextFormat = textFormat;
Text = text;
JSON = jSON;
}

Expand All @@ -101,15 +101,15 @@ public ResponseFormat2(
/// </summary>
public object? Object =>
JSON as object ??
TextFormat as object
Text as object
;

/// <summary>
///
/// </summary>
public bool Validate()
{
return IsTextFormat && !IsJSON || !IsTextFormat && IsJSON;
return IsText && !IsJSON || !IsText && IsJSON;
}

/// <summary>
Expand All @@ -119,8 +119,8 @@ public override int GetHashCode()
{
var fields = new object?[]
{
TextFormat,
typeof(global::Cohere.TextResponseFormat),
Text,
typeof(global::Cohere.TextResponseFormat2),
JSON,
typeof(global::Cohere.JSONResponseFormat2),
};
Expand All @@ -138,7 +138,7 @@ static int HashCodeAggregator(int hashCode, object? value) => value == null
public bool Equals(ResponseFormat2 other)
{
return
global::System.Collections.Generic.EqualityComparer<global::Cohere.TextResponseFormat?>.Default.Equals(TextFormat, other.TextFormat) &&
global::System.Collections.Generic.EqualityComparer<global::Cohere.TextResponseFormat2?>.Default.Equals(Text, other.Text) &&
global::System.Collections.Generic.EqualityComparer<global::Cohere.JSONResponseFormat2?>.Default.Equals(JSON, other.JSON)
;
}
Expand Down
52 changes: 52 additions & 0 deletions src/libs/Cohere/Generated/Cohere.Models.ResponseFormatType2.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

#nullable enable

namespace Cohere
{
/// <summary>
/// Defaults to `"text"`.<br/>
/// When set to `"json_object"`, the model's output will be a valid JSON Object.
/// </summary>
public enum ResponseFormatType2
{
/// <summary>
///
/// </summary>
Text,
/// <summary>
///
/// </summary>
JsonObject,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class ResponseFormatType2Extensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this ResponseFormatType2 value)
{
return value switch
{
ResponseFormatType2.Text => "text",
ResponseFormatType2.JsonObject => "json_object",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static ResponseFormatType2? ToEnum(string value)
{
return value switch
{
"text" => ResponseFormatType2.Text,
"json_object" => ResponseFormatType2.JsonObject,
_ => null,
};
}
}
}
26 changes: 26 additions & 0 deletions src/libs/Cohere/Generated/Cohere.Models.TextResponseFormat2.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#nullable enable

namespace Cohere
{
/// <summary>
///
/// </summary>
public sealed partial class TextResponseFormat2
{
/// <summary>
/// Defaults to `"text"`.<br/>
/// When set to `"json_object"`, the model's output will be a valid JSON Object.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.ResponseFormatType2JsonConverter))]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::Cohere.ResponseFormatType2 Type { 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>();
}
}
24 changes: 12 additions & 12 deletions src/libs/Cohere/Generated/JsonConverters.ResponseFormat2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public class ResponseFormat2JsonConverter : global::System.Text.Json.Serializati

var
readerCopy = reader;
global::Cohere.TextResponseFormat? textFormat = default;
global::Cohere.TextResponseFormat2? text = default;
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.TextResponseFormat), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.TextResponseFormat> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.TextResponseFormat).Name}");
textFormat = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, typeInfo);
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.TextResponseFormat2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.TextResponseFormat2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.TextResponseFormat2).Name}");
text = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
Expand All @@ -41,14 +41,14 @@ public class ResponseFormat2JsonConverter : global::System.Text.Json.Serializati
}

var result = new global::Cohere.ResponseFormat2(
textFormat,
text,
jSON
);

if (textFormat != null)
if (text != null)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.TextResponseFormat), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.TextResponseFormat> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.TextResponseFormat).Name}");
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.TextResponseFormat2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.TextResponseFormat2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.TextResponseFormat2).Name}");
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
else if (jSON != null)
Expand All @@ -70,11 +70,11 @@ public override void Write(
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");

if (value.IsTextFormat)
if (value.IsText)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.TextResponseFormat), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.TextResponseFormat?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.TextResponseFormat).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.TextFormat, typeInfo);
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.TextResponseFormat2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.TextResponseFormat2?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.TextResponseFormat2).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Text, typeInfo);
}
else if (value.IsJSON)
{
Expand Down
49 changes: 49 additions & 0 deletions src/libs/Cohere/Generated/JsonConverters.ResponseFormatType2.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class ResponseFormatType2JsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Cohere.ResponseFormatType2>
{
/// <inheritdoc />
public override global::Cohere.ResponseFormatType2 Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Cohere.ResponseFormatType2Extensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Cohere.ResponseFormatType2)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Cohere.ResponseFormatType2 value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::Cohere.ResponseFormatType2Extensions.ToValueString(value));
}
}
}
Loading

0 comments on commit 5ea0edf

Please sign in to comment.