Skip to content
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
2 changes: 2 additions & 0 deletions src/libs/Cohere/Generated/Cohere..JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Cohere
typeof(global::Cohere.JsonConverters.CitationTypeNullableJsonConverter),
typeof(global::Cohere.JsonConverters.ChatTextContentTypeJsonConverter),
typeof(global::Cohere.JsonConverters.ChatTextContentTypeNullableJsonConverter),
typeof(global::Cohere.JsonConverters.ChatThinkingContentTypeJsonConverter),
typeof(global::Cohere.JsonConverters.ChatThinkingContentTypeNullableJsonConverter),
typeof(global::Cohere.JsonConverters.AssistantMessageResponseContentItemDiscriminatorTypeJsonConverter),
typeof(global::Cohere.JsonConverters.AssistantMessageResponseContentItemDiscriminatorTypeNullableJsonConverter),
typeof(global::Cohere.JsonConverters.AssistantMessageResponseRoleJsonConverter),
Expand Down
4 changes: 1 addition & 3 deletions src/libs/Cohere/Generated/Cohere.CohereClient.Chatv2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,7 @@ partial void ProcessChatv2ResponseContent(
/// Randomness can be further maximized by increasing the value of the `p` parameter.
/// </param>
/// <param name="thinking">
/// Thinking gives the model enhanced reasoning capabilities for complex tasks, while also providing transparency into its step-by-step thought process before it delivers its final answer.<br/>
/// When thinking is turned on, the model creates thinking content blocks where it outputs its internal reasoning. The model will incorporate insights from this reasoning before crafting a final response.<br/>
/// When thinking is used without tools, the API response will include both thinking and text content blocks. Meanwhile, when thinking is used alongside tools and the model makes tool calls, the API response will include the thinking content block and `tool_calls`.
/// Configuration for [reasoning features](https://docs.cohere.com/docs/reasoning).
/// </param>
/// <param name="toolChoice">
/// Used to control whether or not the model will be forced to use a tool when answering. When `REQUIRED` is specified, the model will be forced to use at least one of the user-defined tools, and the `tools` parameter must be passed in the request.<br/>
Expand Down
4 changes: 1 addition & 3 deletions src/libs/Cohere/Generated/Cohere.ICohereClient.Chatv2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ public partial interface ICohereClient
/// Randomness can be further maximized by increasing the value of the `p` parameter.
/// </param>
/// <param name="thinking">
/// Thinking gives the model enhanced reasoning capabilities for complex tasks, while also providing transparency into its step-by-step thought process before it delivers its final answer.<br/>
/// When thinking is turned on, the model creates thinking content blocks where it outputs its internal reasoning. The model will incorporate insights from this reasoning before crafting a final response.<br/>
/// When thinking is used without tools, the API response will include both thinking and text content blocks. Meanwhile, when thinking is used alongside tools and the model makes tool calls, the API response will include the thinking content block and `tool_calls`.
/// Configuration for [reasoning features](https://docs.cohere.com/docs/reasoning).
/// </param>
/// <param name="toolChoice">
/// Used to control whether or not the model will be forced to use a tool when answering. When `REQUIRED` is specified, the model will be forced to use at least one of the user-defined tools, and the `tools` parameter must be passed in the request.<br/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

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

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

return default;
}

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

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

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

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Cohere.ChatThinkingContentType? 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.ChatThinkingContentTypeExtensions.ToValueString(value.Value));
}
}
}
}
16 changes: 15 additions & 1 deletion src/libs/Cohere/Generated/Cohere.JsonConverters.ContentItem.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ public class ContentItemJsonConverter : global::System.Text.Json.Serialization.J
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Cohere.ChatTextContent)}");
text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
global::Cohere.ChatThinkingContent? thinking = default;
if (discriminator?.Type == global::Cohere.AssistantMessageResponseContentItemDiscriminatorType.Thinking)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.ChatThinkingContent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.ChatThinkingContent> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Cohere.ChatThinkingContent)}");
thinking = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}

var result = new global::Cohere.ContentItem(
discriminator?.Type,
text
text,
thinking
);

return result;
Expand All @@ -52,6 +60,12 @@ public override void Write(
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatTextContent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Text, typeInfo);
}
else if (value.IsThinking)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.ChatThinkingContent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.ChatThinkingContent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatThinkingContent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Thinking, typeInfo);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ public class ContentVariant2ItemJsonConverter : global::System.Text.Json.Seriali
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Cohere.ChatTextContent)}");
text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
global::Cohere.ChatThinkingContent? thinking = default;
if (discriminator?.Type == global::Cohere.AssistantMessageV2ContentVariant2ItemDiscriminatorType.Thinking)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.ChatThinkingContent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.ChatThinkingContent> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Cohere.ChatThinkingContent)}");
thinking = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}

var result = new global::Cohere.ContentVariant2Item(
discriminator?.Type,
text
text,
thinking
);

return result;
Expand All @@ -52,6 +60,12 @@ public override void Write(
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatTextContent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Text, typeInfo);
}
else if (value.IsThinking)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Cohere.ChatThinkingContent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Cohere.ChatThinkingContent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Cohere.ChatThinkingContent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Thinking, typeInfo);
}
}
}
}
Loading