Skip to content

Commit

Permalink
Merge pull request #41 from tryAGI/bot/update-openapi_202409121519
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Sep 12, 2024
2 parents b8160d4 + 07ebb38 commit 74d0ca3
Show file tree
Hide file tree
Showing 7 changed files with 522 additions and 347 deletions.
9 changes: 9 additions & 0 deletions src/libs/Cohere/Generated/Cohere.CohereApi.Chat.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ public partial class CohereApi
partial void PrepareChatArguments(
global::System.Net.Http.HttpClient httpClient,
ref string? xClientName,
ref global::Cohere.ChatAccepts? accepts,
global::Cohere.ChatRequest request);
partial void PrepareChatRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string? xClientName,
global::Cohere.ChatAccepts? accepts,
global::Cohere.ChatRequest request);
partial void ProcessChatResponse(
global::System.Net.Http.HttpClient httpClient,
Expand All @@ -29,12 +31,14 @@ partial void ProcessChatResponseContent(
/// To learn how to use the Chat API with Streaming and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
/// </summary>
/// <param name="xClientName"></param>
/// <param name="accepts"></param>
/// <param name="request"></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::System.OneOf<global::Cohere.NonStreamedChatResponse, global::Cohere.StreamedChatResponse?>> ChatAsync(
global::Cohere.ChatRequest request,
string? xClientName = default,
global::Cohere.ChatAccepts? accepts = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand All @@ -44,6 +48,7 @@ partial void ProcessChatResponseContent(
PrepareChatArguments(
httpClient: _httpClient,
xClientName: ref xClientName,
accepts: ref accepts,
request: request);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
Expand All @@ -63,6 +68,7 @@ partial void ProcessChatResponseContent(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
xClientName: xClientName,
accepts: accepts,
request: request);

using var response = await _httpClient.SendAsync(
Expand Down Expand Up @@ -108,6 +114,7 @@ partial void ProcessChatResponseContent(
/// To learn how to use the Chat API with Streaming and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
/// </summary>
/// <param name="xClientName"></param>
/// <param name="accepts"></param>
/// <param name="message">
/// Text input for the model to respond to.<br/>
/// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
Expand Down Expand Up @@ -278,6 +285,7 @@ partial void ProcessChatResponseContent(
public async global::System.Threading.Tasks.Task<global::System.OneOf<global::Cohere.NonStreamedChatResponse, global::Cohere.StreamedChatResponse?>> ChatAsync(
string message,
string? xClientName = default,
global::Cohere.ChatAccepts? accepts = default,
string? model = default,
bool stream = default,
string? preamble = default,
Expand Down Expand Up @@ -335,6 +343,7 @@ partial void ProcessChatResponseContent(

return await ChatAsync(
xClientName: xClientName,
accepts: accepts,
request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
45 changes: 45 additions & 0 deletions src/libs/Cohere/Generated/Cohere.Models.ChatAccepts.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

#nullable enable

namespace Cohere
{
/// <summary>
///
/// </summary>
public enum ChatAccepts
{
/// <summary>
///
/// </summary>
TextEventStream,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class ChatAcceptsExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this ChatAccepts value)
{
return value switch
{
ChatAccepts.TextEventStream => "text/event-stream",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static ChatAccepts? ToEnum(string value)
{
return value switch
{
"text/event-stream" => ChatAccepts.TextEventStream,
_ => null,
};
}
}
}
49 changes: 49 additions & 0 deletions src/libs/Cohere/Generated/JsonConverters.ChatAccepts.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 ChatAcceptsJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Cohere.ChatAccepts>
{
/// <inheritdoc />
public override global::Cohere.ChatAccepts 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.ChatAcceptsExtensions.ToEnum(stringValue) ?? default;
}

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

return default;
}

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

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

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

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Cohere.ChatAccepts? 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.ChatAcceptsExtensions.ToValueString(value.Value));
}
}
}
}
2 changes: 2 additions & 0 deletions src/libs/Cohere/Generated/JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ namespace Cohere
typeof(global::OpenApiGenerator.JsonConverters.SummarizeRequestFormatNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.SummarizeRequestExtractivenessJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.SummarizeRequestExtractivenessNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.ChatAcceptsJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.ChatAcceptsNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.ClassifyResponseClassificationClassificationTypeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.ClassifyResponseClassificationClassificationTypeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.MessageJsonConverter),
Expand Down
Loading

0 comments on commit 74d0ca3

Please sign in to comment.