I would like to create a new GenerationConfig for Google Gemini, having this in my code:
public static void main(String[] args) throws Exception {
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.temperature = 0.9f;
configBuilder.topK = 16;
configBuilder.topP = 0.1f;
configBuilder.maxOutputTokens = 200;
configBuilder.stopSequences = Arrays.asList("red");
'Builder()' has private access in 'com.google.cloud.vertexai.api.GenerationConfig.Builder'
GenerationConfig generationConfig = configBuilder.build();
GenerativeModel gm = new GenerativeModel(
"MODEL_NAME",
BuildConfig.apiKey,
generationConfig
);
GenerativeModelFutures model = GenerativeModelFutures.from(gm);
but I have this compilation error:
'Builder()' has private access in 'com.google.cloud.vertexai.api.GenerationConfig.Builder'
my maven :
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vertexai</artifactId>
<version>0.1.0</version>
</dependency>
I think you are trying following the example provided in this page in the Android Google Documentation.
According to that documentation, you need to configure the following dependencies in your project, assuming you are using Gradle:
Please, note that the dependency
com.google.ai.client.generativeai:generativeai:0.1.1
is hosted in the Google Maven Repository, not in Maven Central.If you want to keep using Maven you can try using the following dependency:
instead of the one you provided:
As indicated, you probably will need to include a reference to the Google Maven Repository in your
pom.xml
:In any case, you can achieve similar results using the Vertex AI you already configured in your
pom.xml
using a code similar to the following one (based in the official documentation):Please, consider review this or this other blog entries, I think they could be of help as well.