CLlmClient::GetNextMessage Method  
 
BOOL GetNextMessage(
  LPLLM_MESSAGE lpMessage,  
  LPLLM_RESPONSE lpResponse  
);

The GetNextMessage method returns the next available message in the client history.

Parameters

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 method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError. When the last message in the history is reached, the error code will be set to ST_ERROR_END_OF_MESSAGES.

Remarks

The GetNextMessage method 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 method. The dwSize member must be set to the size of the corresponding structure. This enables the method 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 GetFirstMessage to retrieve the first message in the client history. Subsequent messages can then be retrieved by calling GetNextMessage until the method 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

// Enumerate the message history and display message details
LLM_MESSAGE clientMessage = { sizeof(LLM_MESSAGE), 0 };
LLM_RESPONSE serverResponse = { sizeof(LLM_RESPONSE), 0 };

if (llmClient.GetFirstMessage(&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 (llmClient.GetNextMessage(&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