1.文档地址:
https://platform.openai.com/docs/introduction
下载demo:
2. pom集成包
<dependency><groupId>com.theokanning.openai-gpt3-java</groupId><artifactId>client</artifactId><version>0.9.0</version></dependency>
3.domo 例子:
public static void main(String[] args) {OpenAiService openAiService = new OpenAiService("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");CompletionRequest completionRequest = CompletionRequest.builder().prompt("中印边境自卫反击战谁获胜了?").model(openAiService.listModels().get(1).id).echo(true).build();CompletionResult completionResult = openAiService.createCompletion(completionRequest);completionResult.getChoices().forEach(System.out::println);
}
4.OpenAiService获取model集合
public List<Model> listModels() {return api.listModels().blockingGet().data;
}
5.运行需要注意jdk版本