3 Star 38 Fork 18

gaoy/chatgpt-java

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Java ChatGPT

GitHub release Maven Central GitHub license

Java版本openai客户端,支持Spring boot快速开始。

Languages: 中文 | English

 

支持的APIs

快速使用

引入依赖


<dependency>
    <groupId>io.github.m9d2</groupId>
    <artifactId>chatgpt-spring-boot-starter</artifactId>
    <version>{release-version}</version>
</dependency>

 

application.yml 配置

chatpgt:
  config:
    api-key: "YOUR OWNER KEY"
    proxy:
      enable: true
      type: http
      hostname: 127.0.0.1
      port: 1087
    connect-timeout: 60000
    read-timeout: 60000

 

示例代码


@SpringBootApplication
public class SampleApplication implements ApplicationRunner {

    @Autowired
    private OpenAIService openAIService;

    public static void main(String[] args) {
        SpringApplication.run(SampleApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Completions completions = new Completions();
        List<Message> messages = new ArrayList<>();
        Message message = new Message();
        message.setContent("hello");
        message.setRole("user");
        messages.add(message);
        completions.setMessages(messages);
        CompletionsResponse response = openAIService.completions(completions);
        for (CompletionsResponse.Choice choice : response.getChoices()) {
            System.out.print(choice.getMessage().getContent());
        }
    }
}

空文件

简介

ChatGPT Spring boot starter - ChatGPT Java版本SDK,开箱即用,支持Spring Boot项目快速集成 展开 收起
README
Apache-2.0
取消

发行版 (3)

全部
2年前

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/m9d2/chatgpt-java.git
git@gitee.com:m9d2/chatgpt-java.git
m9d2
chatgpt-java
chatgpt-java
main

搜索帮助