Skip to content

Commit

Permalink
Merge pull request #581 from betalgo/573-audiocreatetranscriptionrequ…
Browse files Browse the repository at this point in the history
…est-if-specify-a-responseformat-that-isnt-json-then-responsesuccessful-is-not-set-correctly

Added support for chat LogProbs.
  • Loading branch information
kayhantolga authored Jun 3, 2024
2 parents 4f903fb + c7c39e4 commit ce08c34
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,17 @@ public IEnumerable<ValidationResult> Validate()
/// </summary>
[JsonPropertyName("user")]
public string User { get; set; }

/// <summary>
/// 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.
/// </summary>
[JsonPropertyName("logprobs")]
public bool? LogProbs { get; set; }


/// <summary>
/// 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.
/// </summary>
[JsonPropertyName("top_logprobs")]
public int? TopLogprobs { get; set; }
}
20 changes: 20 additions & 0 deletions OpenAI.SDK/ObjectModels/SharedModels/ChatChoiceResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,31 @@ 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")]
public string Type { get; set; }
[JsonPropertyName("stop")]
public string Stop { get; set; }
}

public record ChatLogProbsResponse
{
[JsonPropertyName("content")] public List<ContentItem> Content { get; set; }
}

public record ContentItemBase
{
[JsonPropertyName("token")] public string Token { get; set; }

[JsonPropertyName("logprob")] public double LogProb { get; set; }

[JsonPropertyName("bytes")] public List<int> Bytes { get; set; }
}
public record ContentItem : ContentItemBase
{
[JsonPropertyName("top_logprobs")] public List<ContentItemBase> TopLogProbs { get; set; }
}
}

0 comments on commit ce08c34

Please sign in to comment.