Completion method (LLMReq - Java)
Sends a chat completion request to a large language model (LLM) hosted by the Domino IQ server.
Defined in
Data type
LLMRes
Syntax
public LLMRes completion(String server, String command, String userPrompt)
throws NotesException
Parameters
String server
The Domino Server IQ name that is needed to send the request. If empty, the request will be routed to the Domino IQ server configured to service the command.
String command
The name of a command document defined in the Domino IQ configuration database. The command document specifies a system prompt that guides the LLM behavior and responses.
String userPrompt
The user prompt is the specific input given by the caller of this method. This prompt is merged with the system prompt defined in the command document and then presented to the language model through the DominoIQ server.
Return value
Example
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
String cmd = "sampleCommand"; // System prompt is configured in domino IQ configure database
String userPrompt = "user prompt"; // User prompt send to dominoIQ
// (Your code goes here)
LLMReq llmreq = session.createLLMRequest();
if (llmreq.isCommandAvailable("Test", cmd))
{
// Send to Domino IQ server name Test
LLMRes llmres = llmreq.completion("Test", cmd, userPrompt);
if (llmres.getFinishReason() == LLMRes.FINISH_REASON_STOP)
System.out.print("Content: " + llmres.getContent());
else
System.out.print("Finish reason: " + llmres.getFinishReason());
} else {
System.out.print("The command is not in configure database");
}
} catch(Exception e) {
e.printStackTrace();
}
}
}