chatgpt java环境调用源码实现

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();
}
1、启动环境 开发工具: jdk1.8 maven3.5.0 命令行工具: curl php 2、创建工程 mvn archetype:generate -DgroupId=com.example.gpt -DartifactId=gpt-demo 3、编译工程 mvn compile 4、引入依赖 com.alibaba chatgpt 1.0.0 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(); }
经验分享 程序员 微信小程序 职场和发展