Completion method (LLMReq - Java)

Sends a chat completion request to a large language model (LLM) hosted by the Domino IQ server.

Defined in

LLMReq

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

LLMRes
Note: If the request not success, LLMRequest will throws an Exception and we do not receive LLMRes. The exception can be varied depend on situation cause the query does not success. For example, you will receive "Unable to find path to server" if your server parameter is not the server host DominoIQ server or "" Command not found in config database" if your Command parameter is not the command configure in DominoIQ configuration database.

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();
       }
   }
}