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:Update README with installation instructions and usage examples #40

Merged
merged 1 commit into from
Sep 9, 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
9 changes: 9 additions & 0 deletions src/libs/Cohere/Generated/Cohere.CohereApi.Chatv2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ partial void ProcessChatv2ResponseContent(
/// **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.<br/>
/// **Limitation**: The parameter is not supported in RAG mode (when any of `connectors`, `documents`, `tools`, `tool_results` are provided).
/// </param>
/// <param name="safetyMode">
/// Used to select the [safety instruction](/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`.<br/>
/// When `NONE` is specified, the safety instruction will be omitted.<br/>
/// Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.<br/>
/// **Note**: This parameter is only compatible with models [Command R 08-2024](/docs/command-r#august-2024-release), [Command R+ 08-2024](/docs/command-r-plus#august-2024-release) and newer.<br/>
/// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
/// </param>
/// <param name="maxTokens">
/// The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.
/// </param>
Expand Down Expand Up @@ -164,6 +171,7 @@ partial void ProcessChatv2ResponseContent(
global::System.Collections.Generic.IList<global::Cohere.Tool2>? tools = default,
global::Cohere.Chatv2RequestCitationMode? citationMode = default,
global::Cohere.ResponseFormat2? responseFormat = default,
global::Cohere.Chatv2RequestSafetyMode? safetyMode = default,
int maxTokens = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
float temperature = default,
Expand All @@ -181,6 +189,7 @@ partial void ProcessChatv2ResponseContent(
Tools = tools,
CitationMode = citationMode,
ResponseFormat = responseFormat,
SafetyMode = safetyMode,
MaxTokens = maxTokens,
StopSequences = stopSequences,
Temperature = temperature,
Expand Down
11 changes: 11 additions & 0 deletions src/libs/Cohere/Generated/Cohere.Models.Chatv2Request.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ public sealed partial class Chatv2Request
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.ResponseFormat2JsonConverter))]
public global::Cohere.ResponseFormat2? ResponseFormat { get; set; }

/// <summary>
/// Used to select the [safety instruction](/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`.<br/>
/// When `NONE` is specified, the safety instruction will be omitted.<br/>
/// Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.<br/>
/// **Note**: This parameter is only compatible with models [Command R 08-2024](/docs/command-r#august-2024-release), [Command R+ 08-2024](/docs/command-r-plus#august-2024-release) and newer.<br/>
/// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("safety_mode")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.Chatv2RequestSafetyModeJsonConverter))]
public global::Cohere.Chatv2RequestSafetyMode? SafetyMode { get; set; }

/// <summary>
/// The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

#nullable enable

namespace Cohere
{
/// <summary>
/// Used to select the [safety instruction](/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`.<br/>
/// When `NONE` is specified, the safety instruction will be omitted.<br/>
/// Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.<br/>
/// **Note**: This parameter is only compatible with models [Command R 08-2024](/docs/command-r#august-2024-release), [Command R+ 08-2024](/docs/command-r-plus#august-2024-release) and newer.<br/>
/// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
/// </summary>
public enum Chatv2RequestSafetyMode
{
/// <summary>
///
/// </summary>
CONTEXTUAL,
/// <summary>
///
/// </summary>
STRICT,
/// <summary>
///
/// </summary>
NONE,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class Chatv2RequestSafetyModeExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this Chatv2RequestSafetyMode value)
{
return value switch
{
Chatv2RequestSafetyMode.CONTEXTUAL => "CONTEXTUAL",
Chatv2RequestSafetyMode.STRICT => "STRICT",
Chatv2RequestSafetyMode.NONE => "NONE",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static Chatv2RequestSafetyMode? ToEnum(string value)
{
return value switch
{
"CONTEXTUAL" => Chatv2RequestSafetyMode.CONTEXTUAL,
"STRICT" => Chatv2RequestSafetyMode.STRICT,
"NONE" => Chatv2RequestSafetyMode.NONE,
_ => null,
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

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

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

return default;
}

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

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

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

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Cohere.Chatv2RequestSafetyMode? 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.Chatv2RequestSafetyModeExtensions.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 @@ -93,6 +93,8 @@ namespace Cohere
typeof(global::OpenApiGenerator.JsonConverters.ChatRequestSafetyModeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.Chatv2RequestCitationModeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.Chatv2RequestCitationModeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.Chatv2RequestSafetyModeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.Chatv2RequestSafetyModeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.GenerateRequestTruncateJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.GenerateRequestTruncateNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.GenerateRequestReturnLikelihoodsJsonConverter),
Expand Down
Loading
Loading