This project provides a client for interacting with a generative language model API. The client allows users to send text-based requests and receive structured responses with dynamic properties and required fields.
- Configurable API key and model selection.
- Supports dynamic response schema with custom properties.
- Allows specifying required fields in the response.
- Uses HTTP for API communication.
Clone the repository and ensure you have Java 11 or higher installed.
git clone <repository_url>
cd <project_directory>
GenerativeClient generativeClient = new GenerativeClient.Builder()
.setApiKey("YOUR_API_KEY")
.setModel(GenerativeModel.GEMINI_2_PRO_EXPERIMENTAL)
.setTemperature(0.7)
.build();
Map<String, String> properties = new HashMap<>();
properties.put("solution_for_plant", "string");
properties.put("thoughts", "string");
properties.put("joke", "string");
GenerativeResponse generativeResponse = generativeClient.sendRequest(
"papatyalarim soluyor ne yapmaliyim?",
properties,
List.of("solution_for_plant"));
Sends a text request to the generative model and receives a structured response.
inputText
(String): The text input for the request.dynamicProperties
(Map<String, String>): A map of expected response properties with their types.requiredFields
(List): A list of required fields in the response.
GenerativeResponse
: A structured response from the model.
This project is licensed under the MIT License.