Skip to content

Commit

Permalink
Merge pull request #141 from tryAGI/bot/update-openapi_202501171824
Browse files Browse the repository at this point in the history
feat:Add CitationType enum to OpenAPI specification for citations
  • Loading branch information
github-actions[bot] authored Jan 17, 2025
2 parents e2a3694 + d961db1 commit 32e0413
Show file tree
Hide file tree
Showing 11 changed files with 1,037 additions and 673 deletions.
14 changes: 13 additions & 1 deletion src/libs/Cohere/Generated/Cohere.Models.ChatCitation.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public sealed partial class ChatCitation
[global::System.Text.Json.Serialization.JsonRequired]
public required global::System.Collections.Generic.IList<string> DocumentIds { get; set; }

/// <summary>
/// The type of citation which indicates what part of the response the citation is for.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::Cohere.JsonConverters.ChatCitationTypeJsonConverter))]
public global::Cohere.ChatCitationType? Type { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand All @@ -57,17 +64,22 @@ public sealed partial class ChatCitation
/// <param name="documentIds">
/// Identifiers of documents cited by this section of the generated reply.
/// </param>
/// <param name="type">
/// The type of citation which indicates what part of the response the citation is for.
/// </param>
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public ChatCitation(
int start,
int end,
string text,
global::System.Collections.Generic.IList<string> documentIds)
global::System.Collections.Generic.IList<string> documentIds,
global::Cohere.ChatCitationType? type)
{
this.Start = start;
this.End = end;
this.Text = text ?? throw new global::System.ArgumentNullException(nameof(text));
this.DocumentIds = documentIds ?? throw new global::System.ArgumentNullException(nameof(documentIds));
this.Type = type;
}

/// <summary>
Expand Down
51 changes: 51 additions & 0 deletions src/libs/Cohere/Generated/Cohere.Models.ChatCitationType.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

#nullable enable

namespace Cohere
{
/// <summary>
/// The type of citation which indicates what part of the response the citation is for.
/// </summary>
public enum ChatCitationType
{
/// <summary>
///
/// </summary>
TEXTCONTENT,
/// <summary>
///
/// </summary>
PLAN,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class ChatCitationTypeExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this ChatCitationType value)
{
return value switch
{
ChatCitationType.TEXTCONTENT => "TEXT_CONTENT",
ChatCitationType.PLAN => "PLAN",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static ChatCitationType? ToEnum(string value)
{
return value switch
{
"TEXT_CONTENT" => ChatCitationType.TEXTCONTENT,
"PLAN" => ChatCitationType.PLAN,
_ => null,
};
}
}
}
14 changes: 13 additions & 1 deletion src/libs/Cohere/Generated/Cohere.Models.Citation.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public sealed partial class Citation
[global::System.Text.Json.Serialization.JsonPropertyName("sources")]
public global::System.Collections.Generic.IList<global::Cohere.Source>? Sources { get; set; }

/// <summary>
/// The type of citation which indicates what part of the response the citation is for.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("type")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::Cohere.JsonConverters.CitationTypeJsonConverter))]
public global::Cohere.CitationType? Type { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand All @@ -51,17 +58,22 @@ public sealed partial class Citation
/// Text snippet that is being cited.
/// </param>
/// <param name="sources"></param>
/// <param name="type">
/// The type of citation which indicates what part of the response the citation is for.
/// </param>
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public Citation(
int? start,
int? end,
string? text,
global::System.Collections.Generic.IList<global::Cohere.Source>? sources)
global::System.Collections.Generic.IList<global::Cohere.Source>? sources,
global::Cohere.CitationType? type)
{
this.Start = start;
this.End = end;
this.Text = text;
this.Sources = sources;
this.Type = type;
}

/// <summary>
Expand Down
51 changes: 51 additions & 0 deletions src/libs/Cohere/Generated/Cohere.Models.CitationType.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

#nullable enable

namespace Cohere
{
/// <summary>
/// The type of citation which indicates what part of the response the citation is for.
/// </summary>
public enum CitationType
{
/// <summary>
///
/// </summary>
TEXTCONTENT,
/// <summary>
///
/// </summary>
PLAN,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class CitationTypeExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this CitationType value)
{
return value switch
{
CitationType.TEXTCONTENT => "TEXT_CONTENT",
CitationType.PLAN => "PLAN",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static CitationType? ToEnum(string value)
{
return value switch
{
"TEXT_CONTENT" => CitationType.TEXTCONTENT,
"PLAN" => CitationType.PLAN,
_ => null,
};
}
}
}
49 changes: 49 additions & 0 deletions src/libs/Cohere/Generated/JsonConverters.ChatCitationType.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

namespace Cohere.JsonConverters
{
/// <inheritdoc />
public sealed class ChatCitationTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Cohere.ChatCitationType>
{
/// <inheritdoc />
public override global::Cohere.ChatCitationType 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.ChatCitationTypeExtensions.ToEnum(stringValue) ?? default;
}

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

return default;
}

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

writer.WriteStringValue(global::Cohere.ChatCitationTypeExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable

namespace Cohere.JsonConverters
{
/// <inheritdoc />
public sealed class ChatCitationTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Cohere.ChatCitationType?>
{
/// <inheritdoc />
public override global::Cohere.ChatCitationType? 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.ChatCitationTypeExtensions.ToEnum(stringValue);
}

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

return default;
}

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

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::Cohere.ChatCitationTypeExtensions.ToValueString(value.Value));
}
}
}
}
49 changes: 49 additions & 0 deletions src/libs/Cohere/Generated/JsonConverters.CitationType.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

namespace Cohere.JsonConverters
{
/// <inheritdoc />
public sealed class CitationTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Cohere.CitationType>
{
/// <inheritdoc />
public override global::Cohere.CitationType 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.CitationTypeExtensions.ToEnum(stringValue) ?? default;
}

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

return default;
}

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

writer.WriteStringValue(global::Cohere.CitationTypeExtensions.ToValueString(value));
}
}
}
56 changes: 56 additions & 0 deletions src/libs/Cohere/Generated/JsonConverters.CitationTypeNullable.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable

namespace Cohere.JsonConverters
{
/// <inheritdoc />
public sealed class CitationTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Cohere.CitationType?>
{
/// <inheritdoc />
public override global::Cohere.CitationType? 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.CitationTypeExtensions.ToEnum(stringValue);
}

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

return default;
}

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

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::Cohere.CitationTypeExtensions.ToValueString(value.Value));
}
}
}
}
Loading

0 comments on commit 32e0413

Please sign in to comment.