The SendMessage method sends a text prompt to the model and
processes the response. This method performs a blocking operation. It
will not return until the request has completed, an error has occurred,
or the operation has timed out. It is recommended that the user interface
provide visual feedback to the user while waiting for the response.
An application which accepts prompts provided by a user should apply
appropriate validation, filtering, or normalization before sending
requests to the service provider. The ValidateText method verifies
that the prompt contains valid message text and the NormalizeText
method can be used to normalize text formatting.
The validation and normalization methods do not perform any semantic
analysis of the prompt and do not provide protection against malicious
or intentionally misleading input. It is the responsibility of the
application to ensure that user-provided input is appropriate for its
intended use. This includes considering scenarios where input may attempt
to override instructions, inject unintended prompts, or otherwise
influence the behavior of the model.
Line breaks in the response text are normalized before being stored
in the client history. 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.
Some models are capable of performing additional internal reasoning
before generating a response. The amount of reasoning performed and
whether it is exposed by the provider is model-specific. The control
returns the final response intended for the user and does not
currently expose model reasoning or intermediate processing steps.
This behavior ensures consistent results across providers, regardless
of how individual models implement or expose reasoning capabilities.
If the MessageId parameter is specified, it will receive
a unique identifier for the message within the current client session.
Message identifiers are assigned sequentially, but applications should
treat them as opaque values. They are only guaranteed to be unique
within a single session and should not be compared across different
client sessions. You can retrieve a specific message from the
conversation history using the GetMessage method.
This method automatically adds the message to the conversation
history for the session. Subsequent calls will include previous messages
as context, subject to any configured history or token limits. To clear
the conversation context, call the ClearHistory method.
The value of the Prompt and Response properties will
be updated when this method returns. See the Response property
for additional information about text formatting and Unicode handling
for model responses.
For simple request and response operations, applications can use the
Ask method instead of explicitly calling the Connect,
SendMessage and Disconnect methods.
LlmClient1.ProviderName = "Local"
LlmClient1.BaseUrl = "http://127.0.0.1:1234/v1/"
LlmClient1.ModelName = "mistralai/mistral-7b-instruct-v0.3"
If LlmClient1.Connect() Then
Dim strPrompt As String
Dim strResponse As String
Dim nMessageId As Long
strPrompt = "How do you calculate the volume of a sphere?"
If LlmClient1.SendMessage(strPrompt, strResponse, nMessageId) Then
MsgBox strResponse, vbInformation, "Message " & nMessageId
Else
MsgBox LlmClient1.LastErrorString, vbExclamation, "Error"
End If
LlmClient1.Disconnect
Else
MsgBox LlmClient1.LastErrorString, vbExclamation, "Error"
End If