1、启动环境
开发工具:
jdk1.8
maven3.5.0
命令行工具:
curl
php
2、创建工程
mvn archetype:generate -DgroupId=com.example.gpt -DartifactId=gpt-demo
3、编译工程
mvn compile
4、引入依赖
<dependency>
<groupId>com.alibaba</groupId> <artifactId>chatgpt</artifactId> <version>1.0.0</version> </dependency>
5、调用接口
String url = "http://localhost:8080/chatgpt/api/v1.0/user/sendmessage";
ChatGPT chatGPT = ChatGPT.create();
byte[] message = "Hello, world!";
try {
chatGPT.sendMessage(url, message);
} catch (Exception e) {
e.printStackTrace();
}