Class MotorExtractContentRequest
java.lang.Object
com.chatmotorapi.api.experimental.MotorExtractContentRequest
public class MotorExtractContentRequest extends Object
Handles the creation and execution of a content extraction request using the
ChatMotor
API. This API filters the input text to remove or alter
content related to specified topics or keywords, enhancing text sanitization
and customization.
It includes configuration for the text file to be the model to be used in
requests can be specified with the .aiModel setter directly on the
MotorFilterContentRequest 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:
String documentPath = "/path/to/my_document.html";
String responseFile = "/path/to/response_file.html";
// We assume that the env var MOTOR_API_KEY is set.
ChatMotor chatMotor = ChatMotor.builder().build();
List<String> topics = new ArrayList<String>();
topics.add("AI Generative);
topics.add("Machine learning);
MotorExtractContentRequest extractContentRequest = MotorExtractContentRequest.builder()
.chatMotor(chatMotor)
.topics(topics)
.filePath(documentPath)
.languageCode("fr")
.build();
MotorResponse motorResponse = extractContentRequest.execute();
if (motorResponse.isResponseOk()) {
System.out.println(motorResponse.getResponse());
} 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 translation request.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MotorExtractContentRequest.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 MotorExtractContentRequest.Builder
builder()
Returns a new builder instance for creating aMotorExtractContentRequest
.ChatMotor
chatMotor()
Gets the ChatMotor to be used in the request.MotorResponse
execute()
Executes the process of extracting from a specified file using a GPT model.MotorStreamStatus
executeAsStream(MotorResponseListener motorResponseListener)
Executes the process of extractting a cotnet from a specified file using a GPT model.String
filePath()
Gets the file path to be used in the request.String
languageCode()
Gets the language code to be used in the request for content extraction.List<String>
topics()
Gets the topics to be used in the request for content extraction.
-
Method Details
-
builder
Returns a new builder instance for creating aMotorExtractContentRequest
.- Returns:
- a new
MotorExtractContentRequest
builder
-
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
-
languageCode
Gets the language code to be used in the request for content extraction.- Returns:
- the language code to be used in the request for content extraction
-
topics
Gets the topics to be used in the request for content extraction.- Returns:
- the topics to be used in the request for content extraction
-
execute
Executes the process of extracting from a specified file using a GPT model. This method initializes a session with necessary configurations, reads the text file, and creates a summary. based on the text content.- Returns:
- the
MotorResponse
instance. - Throws:
MotorExecutionException
- if there is an error reading the file.
-
executeAsStream
Executes the process of extractting a cotnet from a specified file using a GPT model.
The configured request is executed as a stream.
This is valid only of request with a text format with less that 3000 words- Parameters:
motorResponseListener
- The listener that will handle the streamed data chunks.- Returns:
- An instance of
MotorStreamStatus
that contains information about the outcome of the streaming operation.
-