功能说明:
## 快速使用
### 一、引入依赖
```xml
cn.m9d2.chatgpt
chatgpt
0.0.2
```
### 二、application.yml 配置
```yaml
openai:
api-key: "YOUR OWNER KEY"
proxy:
enable: true
type: http
hostname: 127.0.0.1
port: 1087
connect-timeout: 10000
read-timeout: 30000
```
### 三、示例代码
```java
@SpringBootApplication
public class SampleApplication implements ApplicationRunner {
@Autowired
private ChatService chatService;
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
@Override
public void run(ApplicationArguments args) throws Exception {
Completions completions = new Completions();
List messages = new ArrayList<>();
Message message = new Message();
message.setContent("你好");
message.setRole("user");
messages.add(message);
completions.setMessages(messages);
CompletionsResponse response = chatService.completions(completions);
for (CompletionsResponse.Choice choice : response.getChoices()) {
System.out.print(choice.getMessage().getContent());
}
}
}
```
Github地址:https://github.com/m9d2/chatgpt
页面更新:2024-04-14
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号