我想为Google Gemini创建一个新的GenerationConfig,在我的代码中有:
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);
字符串
但我有这个编译错误:
'Builder()' has private access in 'com.google.cloud.vertexai.api.GenerationConfig.Builder'
型
我的Maven:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vertexai</artifactId>
<version>0.1.0</version>
</dependency>
型
1条答案
按热度按时间bmp9r5qi1#
我认为你正在尝试遵循Android Google文档中此页面提供的示例。
根据该文档,假设您使用的是Gradle,则需要在项目中配置以下依赖项:
字符串
请注意,依赖项
com.google.ai.client.generativeai:generativeai:0.1.1
托管在Google Maven Repository中,而不是Maven Central中。如果你想继续使用Maven,你可以尝试使用following dependency:
型
而不是你提供的那个
型
如上所述,您可能需要在
pom.xml
中包含对Google Maven Repository的引用:型
在任何情况下,您都可以使用已经在
pom.xml
中配置的Vertex AI实现类似的结果,使用类似于以下代码(基于official documentation):型
请考虑审查this或this other博客条目,我认为他们也可以帮助。