maven
<dependency>
<groupId>com.github.plexpt</groupId>
<artifactId>chatgpt</artifactId>
<version>1.1.2</version>
</dependency>
gradle
implementation group: 'com.github.plexpt', name: 'chatgpt', version: '1.1.2'
然后
Chatbot chatbot = new Chatbot("sessionToken","cf_clearance","user-agent");
Map<String, Object> chatResponse = chatbot.getChatResponse("hello");
System.out.println(chatResponse.get("message"));
注意:一个Chatbot实例为一个Session,会持有对话上下文,可以回复:继续 让机器人接着说。如果需要对话互相隔离,new 多个Chatbot实例即可。
https://github.com/acheong08/ChatGPT/wiki/Setup#token-authentication
注意:如果提示403. 请检查以上参数是否正确,是否过期。并且获取以上参数的浏览器要和本程序在同一IP地址
————
【技术框架】
————
【源码使用说明】
源码地址
https://gitee.com/itcode-itcode/chatgpt-java