diff --git a/src/AnthropicClient/Models/BaseMessageRequest.cs b/src/AnthropicClient/Models/BaseMessageRequest.cs index fb5413b..040f743 100644 --- a/src/AnthropicClient/Models/BaseMessageRequest.cs +++ b/src/AnthropicClient/Models/BaseMessageRequest.cs @@ -14,6 +14,11 @@ public abstract class BaseMessageRequest /// public string Model { get; init; } = string.Empty; + // TODO: I do not like this. I would prefer to have a single property that is a list of TextContent objects. + // This approach was taken to maintain compatibility with the API. As someone could be using the System property + // and changing it to a list of TextContent objects would break their code. + // However if an opportunity arises for a breaking change release, this should be changed. + /// /// Gets the system message that will be used as the system prompt if no system messages are provided. /// @@ -105,12 +110,33 @@ public abstract class BaseMessageRequest [JsonConstructor] internal BaseMessageRequest() { } - private BaseMessageRequest( + /// + /// Initializes a new instance of the class. + /// + /// The model ID to use for the request. + /// The messages to send to the model. + /// The maximum number of tokens to generate. + /// The system prompt to use for the request. + /// The metadata to include with the request. + /// The temperature to use for the request. + /// The top-K value to use for the request. + /// The top-P value to use for the request. + /// The tool choice mode to use for the request. + /// The tools to use for the request. + /// A value indicating whether the message should be streamed. + /// The prompt stop sequences. + /// The system messages to use for the request. + /// Thrown when the model ID is invalid. + /// Thrown when the model or messages is null. + /// Thrown when the messages contain no messages. + /// Thrown when the max tokens is less than one. + /// Thrown when the temperature is less than zero or greater than one. + /// A new instance of the class. + protected BaseMessageRequest( string model, List messages, int maxTokens, string? system, - List? systemMessages, Dictionary? metadata, decimal temperature, int? topK, @@ -118,7 +144,8 @@ public abstract class BaseMessageRequest ToolChoice? toolChoice, List? tools, bool stream, - List? stopSequences + List? stopSequences, + List? systemMessages ) { ArgumentValidator.ThrowIfNull(model, nameof(model)); @@ -158,108 +185,4 @@ public abstract class BaseMessageRequest Stream = stream; StopSequences = stopSequences ?? []; } - - /// - /// Initializes a new instance of the class. - /// - /// The model ID to use for the request. - /// The messages to send to the model. - /// The maximum number of tokens to generate. - /// The system prompt to use for the request. - /// The metadata to include with the request. - /// The temperature to use for the request. - /// The top-K value to use for the request. - /// The top-P value to use for the request. - /// The tool choice mode to use for the request. - /// The tools to use for the request. - /// A value indicating whether the message should be streamed. - /// The prompt stop sequences. - /// Thrown when the model ID is invalid. - /// Thrown when the model or messages is null. - /// Thrown when the messages contain no messages. - /// Thrown when the max tokens is less than one. - /// Thrown when the temperature is less than zero or greater than one. - /// A new instance of the class. - protected BaseMessageRequest( - string model, - List messages, - int maxTokens = 1024, - string? system = null, - Dictionary? metadata = null, - decimal temperature = 0.0m, - int? topK = null, - decimal? topP = null, - ToolChoice? toolChoice = null, - List? tools = null, - bool stream = false, - List? stopSequences = null - ) : this( - model, - messages, - maxTokens, - system, - null, - metadata, - temperature, - topK, - topP, - toolChoice, - tools, - stream, - stopSequences - ) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The model ID to use for the request. - /// The messages to send to the model. - /// The maximum number of tokens to generate. - /// The system messages to send to the model to be used as the system prompt. - /// The metadata to include with the request. - /// The temperature to use for the request. - /// The top-K value to use for the request. - /// The top-P value to use for the request. - /// The tool choice mode to use for the request. - /// The tools to use for the request. - /// A value indicating whether the message should be streamed. - /// The prompt stop sequences. - /// Thrown when the model ID is invalid. - /// Thrown when the model or messages is null. - /// Thrown when the messages contain no messages. - /// Thrown when the max tokens is less than one. - /// Thrown when the temperature is less than zero or greater than one. - /// A new instance of the class. - protected BaseMessageRequest( - string model, - List messages, - int maxTokens = 1024, - List? systemMessages = null, - Dictionary? metadata = null, - decimal temperature = 0.0m, - int? topK = null, - decimal? topP = null, - ToolChoice? toolChoice = null, - List? tools = null, - bool stream = false, - List? stopSequences = null - ) : this( - model, - messages, - maxTokens, - null, - systemMessages, - metadata, - temperature, - topK, - topP, - toolChoice, - tools, - stream, - stopSequences - ) - { - } } \ No newline at end of file diff --git a/src/AnthropicClient/Models/MessageRequest.cs b/src/AnthropicClient/Models/MessageRequest.cs index fab7af1..f091dbf 100644 --- a/src/AnthropicClient/Models/MessageRequest.cs +++ b/src/AnthropicClient/Models/MessageRequest.cs @@ -16,7 +16,7 @@ public class MessageRequest : BaseMessageRequest /// The model ID to use for the request. /// The messages to send to the model. /// The maximum number of tokens to generate. - /// The system ID to use for the request. + /// The system prompt to use for the request. /// The metadata to include with the request. /// The temperature to use for the request. /// The top-K value to use for the request. @@ -24,6 +24,7 @@ public class MessageRequest : BaseMessageRequest /// The tool choice mode to use for the request. /// The tools to use for the request. /// The prompt stop sequences. + /// The system messages to include with the request. /// Thrown when the model ID is invalid. /// Thrown when the model or messages is null. /// Thrown when the messages contain no messages. @@ -41,7 +42,8 @@ public class MessageRequest : BaseMessageRequest decimal? topP = null, ToolChoice? toolChoice = null, List? tools = null, - List? stopSequences = null + List? stopSequences = null, + List? systemMessages = null ) : base( model, messages, @@ -54,7 +56,8 @@ public class MessageRequest : BaseMessageRequest toolChoice, tools, false, - stopSequences + stopSequences, + systemMessages ) { } diff --git a/src/AnthropicClient/Models/StreamMessageRequest.cs b/src/AnthropicClient/Models/StreamMessageRequest.cs index 9ef0e0b..402075e 100644 --- a/src/AnthropicClient/Models/StreamMessageRequest.cs +++ b/src/AnthropicClient/Models/StreamMessageRequest.cs @@ -16,7 +16,7 @@ public class StreamMessageRequest : BaseMessageRequest /// The model ID to use for the request. /// The messages to send to the model. /// The maximum number of tokens to generate. - /// The system ID to use for the request. + /// The system prompt to use for the request. /// The metadata to include with the request. /// The temperature to use for the request. /// The top-K value to use for the request. @@ -24,6 +24,7 @@ public class StreamMessageRequest : BaseMessageRequest /// The tool choice mode to use for the request. /// The tools to use for the request. /// The prompt stop sequences. + /// The system messages to include with the request. /// Thrown when the model ID is invalid. /// Thrown when the model or messages is null. /// Thrown when the messages contain no messages. @@ -41,7 +42,8 @@ public class StreamMessageRequest : BaseMessageRequest decimal? topP = null, ToolChoice? toolChoice = null, List? tools = null, - List? stopSequences = null + List? stopSequences = null, + List? systemMessages = null ) : base( model, messages, @@ -54,7 +56,8 @@ public class StreamMessageRequest : BaseMessageRequest toolChoice, tools, true, - stopSequences + stopSequences, + systemMessages ) { }