diff --git a/OpenAI.SDK/ObjectModels/RequestModels/ChatCompletionCreateRequest.cs b/OpenAI.SDK/ObjectModels/RequestModels/ChatCompletionCreateRequest.cs index 31d2be44..0202d6a3 100644 --- a/OpenAI.SDK/ObjectModels/RequestModels/ChatCompletionCreateRequest.cs +++ b/OpenAI.SDK/ObjectModels/RequestModels/ChatCompletionCreateRequest.cs @@ -263,4 +263,17 @@ public IEnumerable Validate() /// [JsonPropertyName("user")] public string User { get; set; } + + /// + /// Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message. + /// + [JsonPropertyName("logprobs")] + public bool? LogProbs { get; set; } + + + /// + /// An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used. + /// + [JsonPropertyName("top_logprobs")] + public int? TopLogprobs { get; set; } } \ No newline at end of file diff --git a/OpenAI.SDK/ObjectModels/SharedModels/ChatChoiceResponse.cs b/OpenAI.SDK/ObjectModels/SharedModels/ChatChoiceResponse.cs index 630f850e..ad4bf0ac 100644 --- a/OpenAI.SDK/ObjectModels/SharedModels/ChatChoiceResponse.cs +++ b/OpenAI.SDK/ObjectModels/SharedModels/ChatChoiceResponse.cs @@ -19,6 +19,8 @@ public ChatMessage Delta [JsonPropertyName("finish_reason")] public string FinishReason { get; set; } [JsonPropertyName("finish_details")] public FinishDetailsResponse? FinishDetails { get; set; } + + [JsonPropertyName("logprobs")] public ChatLogProbsResponse LogProbs { get; set; } public class FinishDetailsResponse { [JsonPropertyName("type")] @@ -26,4 +28,22 @@ public class FinishDetailsResponse [JsonPropertyName("stop")] public string Stop { get; set; } } + + public record ChatLogProbsResponse + { + [JsonPropertyName("content")] public List Content { get; set; } + } + + public record ContentItemBase + { + [JsonPropertyName("token")] public string Token { get; set; } + + [JsonPropertyName("logprob")] public double LogProb { get; set; } + + [JsonPropertyName("bytes")] public List Bytes { get; set; } + } + public record ContentItem : ContentItemBase + { + [JsonPropertyName("top_logprobs")] public List TopLogProbs { get; set; } + } } \ No newline at end of file