Class MotorLanguageGuesserRequest

java.lang.Object
com.chatmotorapi.api.functional.MotorLanguageGuesserRequest

public class MotorLanguageGuesserRequest
extends Object
Handles the creation and execution of language guessing requests using the ChatMotor API. This class is designed to determine the language of text documents using OpenAI's advanced language detection models configured through the ChatMotor. It includes configuration for the text file whose language is to be detected, timeout settings, and retry policies. The model to be used in requests can be specified with the .aiModel setter directly on the MotorLanguageGuesserRequest builder. If .aiModel is not called, the default model used is System.getenv("MOTOR_CHAT_MODEL"). If the environment variable is not set, the model used is MotorDefaultsModels.MOTOR_CHAT_MODEL

Usage example:

 
        // We assume that the env var MOTOR_API_KEY is set
        // Create a ChatMotor instance.
        ChatMotor chatMotor = ChatMotor.builder().build();

        // Make a request to the ChatMotor.
        MotorLanguageGuesserRequest motorRequest = MotorLanguageGuesserRequest.builder()
                .chatMotor(chatMotor)
                .filePath("/path/to/content.txt")
                .build();

        // Execute the request.
        MotorResponse motorResponse = motorRequest.execute();

        if (motorResponse.isResponseOk()) {
            String response = motorResponse.getResponse();
            System.out.println("Language: " + response);
        } else {
            // Treat errors
            // See the MotorResponse class for more details.
        }

 
 

This class uses a builder pattern to ensure a flexible and secure way to configure each language detection request.

  • Method Details

    • chatMotor

      public ChatMotor chatMotor()
      Gets the ChatMotor to be used in the request.
      Returns:
      the
    • aiOptions

      public MotorAiOptions aiOptions()
      Gets the AI options to be used in the request.
      Returns:
      the AI options to be used in the request
    • aiModel

      public String aiModel()
      Gets the AI model to be used in the request.
      Returns:
      the AI model to be used in the request
    • filePath

      public String filePath()
      Gets the file path to be used in the request.
      Returns:
      the file path to be used in the request
    • builder

      public static MotorLanguageGuesserRequest.Builder builder()
      Returns a new builder instance for creating a MotorLanguageGuesserRequest.
      Returns:
      a new MotorLanguageGuesserRequest builder
    • execute

      public MotorResponse execute()
      Executes the summarization request and returns the response.
      Returns:
      MotorImageResponse encapsulating the result of the summarization attempt.