• Springboot接入ChatGPT


    项目地址

    https://gitee.com/Kindear/lucy-chat

    介绍

    lucy-chat是接入OpenAI-ChatGPT大模型人工智能的Java解决方案,大模型人工智能的发展是不可阻挡的趋势,我们环境无法创造工具,但是也要更好的使用工具,该包简化了接入流程,可以非常方便的引入并使用ChatGPT相关功能。

    接入方式

    lucy-chat提供了两种形式接入服务,完成集成或者独立部署后可以访问[部署地址]/doc.html调用相关接口。

    1. Jar引入

    准备

    在引入任何 Lucy系列依赖之前,需要完成jitpack镜像仓库的配置。

    copy
    <repositories> <repository> <id>jitpack.ioid> <url>https://www.jitpack.iourl> repository> repositories>

    引入

    根据版本号引入

    当前默认1.0.0-r4

    copy
    <dependency> <groupId>com.gitee.kindeargroupId> <artifactId>lucy-chatartifactId> <version>${version}version> dependency>

    启动类

    启用 knife4j 文档,需要在启动类上配置 @EnableKnife4j

    copy
    @EnableKnife4j @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(LucyAdminApplication.class, args); } }

    配置文件

    使用 lucy-chat需要配置如下文件信息

    copy
    spring.application.name=lucy-chat # 运行端口 server.port=8080 # swagger 匹配 spring.mvc.pathmatch.matching-strategy=ant_path_matcher # chat-gpt api-key # 申请地址 https://platform.openai.com/account/api-keys openai.chat.key= # chat-gpt proxy host # 配置代理地址 请参阅 https://www.v2ex.com/t/921689 openai.chat.host= # 连接池最大连接数 forest.max-connections=1000 # 连接超时时间,单位为毫秒 forest.connect-timeout=30000 # 数据读取超时时间,单位为毫秒 forest.read-timeout=30000

    2. 独立服务

    1. 从开源地址下载项目
    copy
    git clone https://gitee.com/Kindear/lucy-chat
    1. 修改POM文件中打包方式,即恢复 相关注释掉的内容
    copy
    <build> <plugins> <plugin> <groupId>org.apache.maven.pluginsgroupId> <artifactId>maven-compiler-pluginartifactId> <version>3.8.1version> <configuration> <source>1.8source> <target>1.8target> <encoding>UTF-8encoding> configuration> plugin> <plugin> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-maven-pluginartifactId> <version>${spring-boot.version}version> <executions> <execution> <goals> <goal>repackagegoal> goals> execution> executions> plugin> plugins> build>
    1. 修改相关配置文件, 参考上文的配置文件相关内容,项目中提供的 key为私人 key,随时会被替换。
    2. 打包项目并部署

    效果

    1. 对话

    2. 图像绘制

    3. 文本编辑

    开箱即用

    引入模板渲染

    技术交流
    kindear@foxmail.com

  • 相关阅读:
    数字孪生在工业制造中的应用领域及技术体系构建
    Linux Ulimit控制shell执行程序的资源
    代码,写的复杂点还是简单点?
    【flask】根据接口名称和请求参数进行缓存
    Java面试八股之线程池中submit和execute方法的区别
    加速LakeHouse ACID Upsert的新写时复制方案
    binlog的三种格式
    3.np.random
    C和C++教程
    gcc g++一些使用
  • 原文地址:https://www.cnblogs.com/masterchd/p/17233297.html