The LLM_RESPONSE structure represents the result of a request
submitted to a language model. It is typically returned by functions
such as LlmSendMessageEx and provides both the generated
response content and additional metadata describing how the request
was processed.
This structure is logically paired with the LLM_MESSAGE
structure. While the LLM_MESSAGE structure defines the input
provided to the model, the LLM_RESPONSE structure contains
the output generated by the model along with status and diagnostic
information. The dwMessageId member may be used to associate
the response with the originating request message.
The lpszContent member points to a null-terminated string
buffer which contains the response from the model. The
nContentLength member specifies how many characters are in the
response, not including the terminating null character. Line feed
and carriage return characters are converted to the standard Windows
CRLF end-of-line sequence, ensuring consistent formatting across
different providers and applications. This also helps ensure
compatibility with Windows common controls and other user interface
components.
The ANSI version of this structure uses UTF-8 encoded strings,
while the Unicode version uses UTF-16 encoded strings. Response text
returned by a provider may contain Unicode characters, including
international text, typographical symbols, emoji, mathematical
symbols, or other non-ASCII characters. Applications should ensure
that any user interface controls, files, or other components used to
display or process response text are capable of handling Unicode text
correctly.
Applications which cannot process Unicode text in the response can
provide a system prompt requesting that the model limit its output to
ASCII characters. However, because model output is non-deterministic,
applications should not assume that non-ASCII characters will never be
returned.
The dwStatus member indicates how the request completed.
A value of LLM_RESPONSE_COMPLETE indicates that the
response was generated normally, while other values may indicate
that the response was truncated due to token limits, cancelled,
timed out, or failed due to an error. Applications should always
check this value before processing the response content.
The dwElapsed member provides the total time required to
process the request, which can be useful for performance monitoring
or diagnostics. The nOutputTokens member, when available,
indicates the number of tokens generated by the model, which may be
useful for usage tracking or cost estimation.
The tTimestamp member is a standard 64-bit Unix time
value which indicates when the response was received from the service
provider. It can be used interchangeably with functions in the C standard
library such as gmtime or localtime. Because
it is a 64-bit integer, it is not impacted by the Year 2038 problem.
Timestamps can be converted into a local date and time using the
LlmConvertTimestamp function.
The string members, such as lpszContent, lpszResponseId,
lpszModelName, and lpszStatusText, are managed by the library.
Applications should treat these pointers as read-only and must not
attempt to modify the contents of the referenced strings. If an
application needs to retain or modify this data, it should create its
own copy.
Calling the LlmClearHistory or LlmResetSession functions
will invalidate these string pointers. Applications must not reference
these values after the session history has been cleared.
Unless otherwise documented, reserved members should be set to zero
before calling a function which accepts this structure.