Table of Contents

Class ChatCompletion

Namespace
Glitch9.AIDevKit

Response from a LLM (Large Language Model) for a chat completion request.

This class contains a list of ChatChoice objects, each representing a message generated by the model in response to a chat prompt.
ChatMessage can be accessed through the ChatChoice (e.g., Choices[0].Message).
If 'n' used in the request is greater than 1, this can contain multiple choices. Otherwise, it will always contain a single choice.

If this is a streamed response, the ChatChoice objects will contain ChatDelta instead of ChatMessage.

public class ChatCompletion : OpenAIModelBase, IGeneratedText, IGeneratedResult
Inheritance
object
ChatCompletion
Implements
Inherited Members

Properties

Choices

A list of chat completion choices. Can be more than one if n is greater than 1.

If this is 'ChatCompletionChunk' which is a streamed response, This can also be empty for the last chunk if you set stream_options: {"include_usage": true}.

public ChatChoice[] Choices { get; set; }

Property Value

ChatChoice[]

Count

public int Count { get; }

Property Value

int

IsEmpty

public bool IsEmpty { get; }

Property Value

bool

SystemFingerprint

This fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.

public string SystemFingerprint { get; set; }

Property Value

string

Methods

FirstContent()

public ChatContent FirstContent()

Returns

ChatContent

FirstDelta()

public ChatDelta FirstDelta()

Returns

ChatDelta

FirstResponseMessage()

public AssistantMessage FirstResponseMessage()

Returns

AssistantMessage

GetContents()

public ChatContent[] GetContents()

Returns

ChatContent[]

GetDeltaChunks()

public ChatDelta[] GetDeltaChunks()

Returns

ChatDelta[]

GetResponseMessages()

public AssistantMessage[] GetResponseMessages()

Returns

AssistantMessage[]

GetToolCalls()

public ToolCall[] GetToolCalls()

Returns

ToolCall[]

ToDeltaTextArray()

public string[] ToDeltaTextArray()

Returns

string[]

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ToStringArray()

public string[] ToStringArray()

Returns

string[]

Operators

implicit operator ChatContent(ChatCompletion)

public static implicit operator ChatContent(ChatCompletion chat)

Parameters

chat ChatCompletion

Returns

ChatContent

implicit operator string(ChatCompletion)

public static implicit operator string(ChatCompletion chat)

Parameters

chat ChatCompletion

Returns

string