using Microsoft.TypeSpec.Generator.Customizations;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace OpenAI.Chat;
/// A chat completion generated by the model.
[CodeGenType("CreateChatCompletionResponse")]
public partial class ChatCompletion
{
private IReadOnlyList _contentTokenLogProbabilities;
private IReadOnlyList _refusalTokenLogProbabilities;
// CUSTOM: Made private. This property does not add value in the context of a strongly-typed class.
/// The object type, which is always `chat.completion`.
[CodeGenMember("Object")]
internal string Object { get; } = "chat.completion";
// CUSTOM: Made internal. We only get back a single choice, and instead we flatten the structure for usability.
[CodeGenMember("Choices")]
internal IReadOnlyList Choices { get; }
// CUSTOM: Renamed.
/// The timestamp when the chat completion was created.
[CodeGenMember("Created")]
public DateTimeOffset CreatedAt { get; }
// CUSTOM: Flattened choice property.
///
/// The reason the model stopped generating tokens. This will be:
///
/// -
/// if the model hit a natural stop point or a provided stop sequence
///
/// -
/// if the maximum number of tokens specified in the request was reached
///
/// -
/// if content was omitted due to a flag from our content filters
///
/// -
/// if the model called a tool
///
/// -
/// (obsolete) if the model called a function
///
///
///
public ChatFinishReason FinishReason => Choices[0].FinishReason;
// CUSTOM: Flattened choice logprobs property.
/// The message content tokens with log probability information.
public IReadOnlyList ContentTokenLogProbabilities =>
_contentTokenLogProbabilities
??= Choices[0].Logprobs?.Content
?? new ChangeTrackingList();
// CUSTOM: Flattened choice logprobs property.
/// The message refusal tokens with log probability information.
public IReadOnlyList RefusalTokenLogProbabilities =>
_refusalTokenLogProbabilities
??= Choices[0].Logprobs?.Refusal
?? new ChangeTrackingList();
// CUSTOM: Flattened choice message property.
/// The role of the author of this message.
public ChatMessageRole Role => Choices[0].Message.Role;
// CUSTOM: Flattened choice message property.
/// The contents of the message.
public ChatMessageContent Content => Choices[0].Message.Content;
// CUSTOM: Flattened choice message property.
/// The tool calls generated by the model, such as function calls.
public IReadOnlyList ToolCalls => Choices[0].Message.ToolCalls;
// CUSTOM: Flattened choice message property.
/// The refusal message generated by the model.
public string Refusal => Choices[0].Message.Refusal;
// CUSTOM: Flattened choice message property.
[Obsolete($"This property is obsolete. Please use {nameof(ToolCalls)} instead.")]
public ChatFunctionCall FunctionCall => Choices[0].Message.FunctionCall;
// CUSTOM: Added Experimental attribute.
/// The audio response generated by the model.
[Experimental("OPENAI001")]
public ChatOutputAudio OutputAudio => Choices[0].Message.Audio;
// CUSTOM: Added Experimental attribute.
[Experimental("OPENAI001")]
public IReadOnlyList Annotations => [.. Choices[0].Message.Annotations];
}