| |
| BOOL WINAPI LlmGetNextMessage( |
| |
HCLIENT hClient, |
|
| |
LPLLM_MESSAGE lpMessage, |
|
| |
LPLLM_RESPONSE lpResponse |
|
| ); |
The LlmGetNextMessage function returns the next available
message in the client history.
Parameters
- hClient
- A handle to the client session.
- lpMessage
- A pointer to an LLM_MESSAGE structure which receives information about
the next message in the client history. This parameter may be NULL if the
message information is not needed.
- lpResponse
- A pointer to an LLM_RESPONSE structure which receives information about
the response associated with the message. This parameter may be NULL if the
response information is not needed.
Return Value
If the function succeeds, the return value is non-zero. If the
function fails, the return value is zero. To get extended error
information, call LlmGetLastError. When the last message in
the history is reached, the error code will be set to
ST_ERROR_END_OF_MESSAGES.
Remarks
The LlmGetNextMessage function is used to enumerate the messages
stored in the client history. Each successful call advances the internal
enumeration position and returns information about the next message and, if
available, the response associated with that message.
If the lpMessage or lpResponse parameters are specified, the
structures must be initialized before calling this function. The dwSize
member must be set to the size of the corresponding structure. This enables
the function to validate the structure version and safely return the
requested information.
Either lpMessage or lpResponse may be NULL. This is useful
when an application only needs to enumerate the original messages or only
needs information about the responses. At least one of these parameters
should be specified.
To begin enumerating messages, call LlmGetFirstMessage to retrieve
the first message in the client history. Subsequent messages can then be
retrieved by calling LlmGetNextMessage until the function returns
zero and the last error code is set to ST_ERROR_END_OF_MESSAGES. This
condition indicates the enumeration has completed and should not be
treated as a failure.
Example
LLM_MESSAGE clientMessage = { sizeof(LLM_MESSAGE), 0 };
LLM_RESPONSE serverResponse = { sizeof(LLM_RESPONSE), 0 };
if (LlmGetFirstMessage(hClient, 0, &clientMessage, &serverResponse))
{
do
{
_tprintf(_T("\nMessage %u\n"), clientMessage.dwMessageId);
_tprintf(_T(" Input Tokens: %u\n"), clientMessage.nInputTokens);
_tprintf(_T(" Content Length: %u\n"), clientMessage.nContentLength);
_tprintf(_T(" Content: \"%s\"\n"), clientMessage.lpszContent);
_tprintf(_T("\nResponse %u\n"), serverResponse.dwMessageId);
_tprintf(_T(" Elapsed: %u ms\n"), serverResponse.dwElapsed);
_tprintf(_T(" Output Tokens: %u\n"), serverResponse.nOutputTokens);
_tprintf(_T(" Content Length: %u\n"), serverResponse.nContentLength);
_tprintf(_T(" Content: \"%s\"\n"), serverResponse.lpszContent);
_tprintf(_T(" Response ID: %s\n"), (serverResponse.lpszResponseId ? serverResponse.lpszResponseId : _T("None")));
_tprintf(_T(" Model Name: %s\n"), (serverResponse.lpszModelName ? serverResponse.lpszModelName : _T("None")));
_tprintf(_T(" Status Text: %s\n"), (serverResponse.lpszStatusText ? serverResponse.lpszStatusText : _T("None")));
}
while (LlmGetNextMessage(hClient, &clientMessage, &serverResponse));
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csllmv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
LlmClearHistory,
LlmGetFirstMessage,
LlmGetMessageCount,
LlmSendMessage,
LLM_MESSAGE,
LLM_RESPONSE
|
|