-
-
Notifications
You must be signed in to change notification settings - Fork 0
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:Add documents
parameter and Document
class to Cohere API
#50
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ public partial interface ICohereApi | |
/// A list of available tools (functions) that the model may suggest invoking before producing a text response.<br/> | ||
/// When `tools` is passed (without `tool_results`), the `text` content in the response will be empty and the `tool_calls` field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the `tool_calls` array will be empty. | ||
/// </param> | ||
/// <param name="documents"> | ||
/// A list of relevant documents that the model can cite to generate a more accurate reply. Each document is either a string or document object with content and metadata. | ||
/// </param> | ||
/// <param name="citationMode"> | ||
/// Defaults to `"accurate"`.<br/> | ||
/// Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results. | ||
|
@@ -89,6 +92,7 @@ public partial interface ICohereApi | |
string model, | ||
global::System.Collections.Generic.IList<global::Cohere.ChatMessage2> messages, | ||
global::System.Collections.Generic.IList<global::Cohere.Tool2>? tools = default, | ||
global::System.Collections.Generic.IList<global::Cohere.OneOf<string, global::Cohere.Document>>? documents = default, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider relocating the new optional parameter to maintain backward compatibility Adding the Apply this diff to move the public Task<OneOf<NonStreamedChatResponse2, StreamedChatResponse2?>> Chatv2Async(
string model,
IList<ChatMessage2> messages,
IList<Tool2>? tools = default,
Chatv2RequestCitationMode? citationMode = default,
ResponseFormat2? responseFormat = default,
Chatv2RequestSafetyMode? safetyMode = default,
int? maxTokens = default,
IList<string>? stopSequences = default,
float? temperature = default,
int? seed = default,
float? frequencyPenalty = default,
float? presencePenalty = default,
float? k = 0F,
float? p = 0.75F,
+ IList<OneOf<string, Document>>? documents = default,
CancellationToken cancellationToken = default);
|
||
global::Cohere.Chatv2RequestCitationMode? citationMode = default, | ||
global::Cohere.ResponseFormat2? responseFormat = default, | ||
global::Cohere.Chatv2RequestSafetyMode? safetyMode = default, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
#pragma warning disable CS0618 // Type or member is obsolete | ||
|
||
#nullable enable | ||
|
||
namespace Cohere | ||
|
@@ -30,6 +32,12 @@ public sealed partial class Chatv2Request | |
[global::System.Text.Json.Serialization.JsonPropertyName("tools")] | ||
public global::System.Collections.Generic.IList<global::Cohere.Tool2>? Tools { get; set; } | ||
|
||
/// <summary> | ||
/// A list of relevant documents that the model can cite to generate a more accurate reply. Each document is either a string or document object with content and metadata. | ||
/// </summary> | ||
[global::System.Text.Json.Serialization.JsonPropertyName("documents")] | ||
public global::System.Collections.Generic.IList<global::Cohere.OneOf<string, global::Cohere.Document>>? Documents { get; set; } | ||
Comment on lines
+35
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure proper serialization of The |
||
|
||
/// <summary> | ||
/// Defaults to `"accurate"`.<br/> | ||
/// Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results. | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||||||
|
||||||||||
#nullable enable | ||||||||||
|
||||||||||
namespace Cohere | ||||||||||
{ | ||||||||||
/// <summary> | ||||||||||
/// Relevant information that could be used by the model to generate a more accurate reply.<br/> | ||||||||||
/// The content of each document are generally short (should be under 300 words). Metadata should be used to provide additional information, both the key name and the value will be<br/> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix grammatical error in summary comment The sentence "The content of each document are generally short..." should be "The content of each document is generally short..." to maintain subject-verb agreement. Apply this diff to correct the grammatical error: -/// The content of each document are generally short (should be under 300 words). Metadata should be used to provide additional information, both the key name and the value will be passed to the model.
+/// The content of each document is generally short (should be under 300 words). Metadata should be used to provide additional information; both the key name and the value will be passed to the model. Committable suggestion
Suggested change
|
||||||||||
/// passed to the model. | ||||||||||
/// </summary> | ||||||||||
public sealed partial class Document | ||||||||||
{ | ||||||||||
/// <summary> | ||||||||||
/// A relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. | ||||||||||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct grammatical error in property summary The comment reads "A relevant documents that the model can cite..." which is grammatically incorrect. It should be "A relevant document that the model can cite..." Apply this diff to fix the grammatical error: -/// A relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.
+/// A relevant document that the model can cite to generate a more accurate reply. Each document is a dictionary of string-string pairs. Committable suggestion
Suggested change
|
||||||||||
/// </summary> | ||||||||||
[global::System.Text.Json.Serialization.JsonPropertyName("data")] | ||||||||||
[global::System.Text.Json.Serialization.JsonRequired] | ||||||||||
public required global::Cohere.DocumentData Data { get; set; } | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// Unique identifier for this document which will be referenced in citations. If not provided an ID will be automatically generated | ||||||||||
/// </summary> | ||||||||||
[global::System.Text.Json.Serialization.JsonPropertyName("id")] | ||||||||||
public string? Id { get; set; } | ||||||||||
|
||||||||||
/// <summary> | ||||||||||
/// Additional properties that are not explicitly defined in the schema | ||||||||||
/// </summary> | ||||||||||
[global::System.Text.Json.Serialization.JsonExtensionData] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allow for nullable values in To accommodate potential Apply this diff to update the type: -public global::System.Collections.Generic.IDictionary<string, object> AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary<string, object>();
+public global::System.Collections.Generic.IDictionary<string, object?> AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary<string, object?>();
|
||||||||||
public global::System.Collections.Generic.IDictionary<string, object> AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary<string, object>(); | ||||||||||
} | ||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||
|
||||||
#nullable enable | ||||||
|
||||||
namespace Cohere | ||||||
{ | ||||||
/// <summary> | ||||||
/// Document content. | ||||||
/// </summary> | ||||||
public sealed partial class DocumentContent | ||||||
{ | ||||||
/// <summary> | ||||||
/// | ||||||
/// </summary> | ||||||
[global::System.Text.Json.Serialization.JsonPropertyName("type")] | ||||||
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::Cohere.JsonConverters.DocumentContentTypeJsonConverter))] | ||||||
public global::Cohere.DocumentContentType Type { get; set; } | ||||||
|
||||||
/// <summary> | ||||||
/// Relevant information that could be used by the model to generate a more accurate reply.<br/> | ||||||
/// The content of each document are generally short (should be under 300 words). Metadata should be used to provide additional information, both the key name and the value will be<br/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix grammatical error in the documentation comment There is a grammatical error in the documentation. The sentence should use "is" instead of "are":
Apply this diff to correct the error: - /// The content of each document are generally short (should be under 300 words). Metadata should be used to provide additional information, both the key name and the value will be<br/>
+ /// The content of each document is generally short (should be under 300 words). Metadata should be used to provide additional information; both the key name and the value will be<br/> Committable suggestion
Suggested change
|
||||||
/// passed to the model. | ||||||
/// </summary> | ||||||
[global::System.Text.Json.Serialization.JsonPropertyName("document")] | ||||||
[global::System.Text.Json.Serialization.JsonRequired] | ||||||
public required global::Cohere.Document Document { 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>(); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
#nullable enable | ||
|
||
namespace Cohere | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public enum DocumentContentType | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
Document, | ||
} | ||
|
||
/// <summary> | ||
/// Enum extensions to do fast conversions without the reflection. | ||
/// </summary> | ||
public static class DocumentContentTypeExtensions | ||
{ | ||
/// <summary> | ||
/// Converts an enum to a string. | ||
/// </summary> | ||
public static string ToValueString(this DocumentContentType value) | ||
{ | ||
return value switch | ||
{ | ||
DocumentContentType.Document => "document", | ||
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), | ||
}; | ||
} | ||
/// <summary> | ||
/// Converts an string to a enum. | ||
/// </summary> | ||
public static DocumentContentType? ToEnum(string value) | ||
{ | ||
return value switch | ||
{ | ||
"document" => DocumentContentType.Document, | ||
_ => null, | ||
}; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||||||
|
||||||||||
#nullable enable | ||||||||||
|
||||||||||
namespace Cohere | ||||||||||
{ | ||||||||||
/// <summary> | ||||||||||
/// A relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. | ||||||||||
/// </summary> | ||||||||||
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the grammatical error in the summary comment. The summary comment has a grammatical error that should be corrected for clarity. Apply this diff to fix the typo: - /// A relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.
+ /// Relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. Committable suggestion
Suggested change
|
||||||||||
public sealed partial class DocumentData | ||||||||||
{ | ||||||||||
|
||||||||||
/// <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>(); | ||||||||||
} | ||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,166 @@ | ||||||||||||||||||||||||||||||||||||||
using System.Linq; | ||||||||||||||||||||||||||||||||||||||
#pragma warning disable CS0618 // Type or member is obsolete | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
#nullable enable | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
namespace Cohere | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// A content block which contains information about the content of a tool result | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public readonly partial struct ToolContent : global::System.IEquatable<ToolContent> | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// Text content of the message. | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
#if NET6_0_OR_GREATER | ||||||||||||||||||||||||||||||||||||||
public global::Cohere.TextContent? Text { get; init; } | ||||||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||||||
public global::Cohere.TextContent? Text { get; } | ||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
#if NET6_0_OR_GREATER | ||||||||||||||||||||||||||||||||||||||
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Text))] | ||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||
public bool IsText => Text != null; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public static implicit operator ToolContent(global::Cohere.TextContent value) => new ToolContent(value); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public static implicit operator global::Cohere.TextContent?(ToolContent @this) => @this.Text; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public ToolContent(global::Cohere.TextContent? value) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
Text = value; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// Document content. | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
#if NET6_0_OR_GREATER | ||||||||||||||||||||||||||||||||||||||
public global::Cohere.DocumentContent? Document { get; init; } | ||||||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||||||
public global::Cohere.DocumentContent? Document { get; } | ||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
#if NET6_0_OR_GREATER | ||||||||||||||||||||||||||||||||||||||
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Document))] | ||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||
public bool IsDocument => Document != null; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public static implicit operator ToolContent(global::Cohere.DocumentContent value) => new ToolContent(value); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public static implicit operator global::Cohere.DocumentContent?(ToolContent @this) => @this.Document; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public ToolContent(global::Cohere.DocumentContent? value) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
Document = value; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public ToolContent( | ||||||||||||||||||||||||||||||||||||||
global::Cohere.TextContent? text, | ||||||||||||||||||||||||||||||||||||||
global::Cohere.DocumentContent? document | ||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
Text = text; | ||||||||||||||||||||||||||||||||||||||
Document = document; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+86
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enforce assignment of either The constructor allows both Apply this diff to enforce the constraint: public ToolContent(
global::Cohere.TextContent? text,
global::Cohere.DocumentContent? document
)
{
+ if ((text == null) == (document == null))
+ throw new ArgumentException("Exactly one of 'text' or 'document' must be provided.");
Text = text;
Document = document;
} Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public object? Object => | ||||||||||||||||||||||||||||||||||||||
Document as object ?? | ||||||||||||||||||||||||||||||||||||||
Text as object | ||||||||||||||||||||||||||||||||||||||
; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public bool Validate() | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
return IsText && !IsDocument || !IsText && IsDocument; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+106
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the logic in the The current condition in the Apply this diff to simplify the method: public bool Validate()
{
- return IsText && !IsDocument || !IsText && IsDocument;
+ return IsText != IsDocument;
} Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public override int GetHashCode() | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
var fields = new object?[] | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
Text, | ||||||||||||||||||||||||||||||||||||||
typeof(global::Cohere.TextContent), | ||||||||||||||||||||||||||||||||||||||
Document, | ||||||||||||||||||||||||||||||||||||||
typeof(global::Cohere.DocumentContent), | ||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||
const int offset = unchecked((int)2166136261); | ||||||||||||||||||||||||||||||||||||||
const int prime = 16777619; | ||||||||||||||||||||||||||||||||||||||
static int HashCodeAggregator(int hashCode, object? value) => value == null | ||||||||||||||||||||||||||||||||||||||
? (hashCode ^ 0) * prime | ||||||||||||||||||||||||||||||||||||||
: (hashCode ^ value.GetHashCode()) * prime; | ||||||||||||||||||||||||||||||||||||||
return fields.Aggregate(offset, HashCodeAggregator); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public bool Equals(ToolContent other) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||||
global::System.Collections.Generic.EqualityComparer<global::Cohere.TextContent?>.Default.Equals(Text, other.Text) && | ||||||||||||||||||||||||||||||||||||||
global::System.Collections.Generic.EqualityComparer<global::Cohere.DocumentContent?>.Default.Equals(Document, other.Document) | ||||||||||||||||||||||||||||||||||||||
; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public static bool operator ==(ToolContent obj1, ToolContent obj2) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
return global::System.Collections.Generic.EqualityComparer<ToolContent>.Default.Equals(obj1, obj2); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+147
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the equality operator You can simplify the Apply this diff: public static bool operator ==(ToolContent obj1, ToolContent obj2)
{
- return global::System.Collections.Generic.EqualityComparer<ToolContent>.Default.Equals(obj1, obj2);
+ return obj1.Equals(obj2);
}
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public static bool operator !=(ToolContent obj1, ToolContent obj2) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
return !(obj1 == obj2); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+153
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the inequality operator Consistent with the Apply this diff: public static bool operator !=(ToolContent obj1, ToolContent obj2)
{
- return !(obj1 == obj2);
+ return !obj1.Equals(obj2);
} Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||
public override bool Equals(object? obj) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
return obj is ToolContent o && Equals(o); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider positioning the new optional parameter at the end of the parameter list to maintain API compatibility
Adding the new optional parameter
documents
in the middle of the parameters list may cause issues for users who call the method using positional arguments. To prevent breaking changes and maintain backward compatibility, it's recommended to add new optional parameters at the end of the parameter list.Apply this diff to move the
documents
parameter to the end:public async global::System.Threading.Tasks.Task<global::Cohere.OneOf<global::Cohere.NonStreamedChatResponse2, global::Cohere.StreamedChatResponse2?>> Chatv2Async( string model, global::System.Collections.Generic.IList<global::Cohere.ChatMessage2> messages, 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, int? seed = default, float? frequencyPenalty = default, float? presencePenalty = default, float? k = 0F, float? p = 0.75F, global::System.Threading.CancellationToken cancellationToken = default, + global::System.Collections.Generic.IList<global::Cohere.OneOf<string, global::Cohere.Document>>? documents = default)
And update the assignment accordingly.
Committable suggestion