Package com.chatmotorapi.api.functional
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.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MotorLanguageGuesserRequest.Builder
Builder class forMotorSummaryRequest
. -
Method Summary
Modifier and Type Method Description String
aiModel()
Gets the AI model to be used in the request.MotorAiOptions
aiOptions()
Gets the AI options to be used in the request.static MotorLanguageGuesserRequest.Builder
builder()
Returns a new builder instance for creating aMotorLanguageGuesserRequest
.ChatMotor
chatMotor()
Gets the ChatMotor to be used in the request.MotorResponse
execute()
Executes the summarization request and returns the response.String
filePath()
Gets the file path to be used in the request.
-
Method Details
-
chatMotor
Gets the ChatMotor to be used in the request.- Returns:
- the
-
aiOptions
Gets the AI options to be used in the request.- Returns:
- the AI options to be used in the request
-
aiModel
Gets the AI model to be used in the request.- Returns:
- the AI model to be used in the request
-
filePath
Gets the file path to be used in the request.- Returns:
- the file path to be used in the request
-
builder
Returns a new builder instance for creating aMotorLanguageGuesserRequest
.- Returns:
- a new
MotorLanguageGuesserRequest
builder
-
execute
Executes the summarization request and returns the response.- Returns:
MotorImageResponse
encapsulating the result of the summarization attempt.
-