項目地址
https://gitee.com/Kindear/lucy-chat
介紹
lucy-chat
是接入OpenAI-ChatGPT
大模型人工智能的Java
解決方案,大模型人工智能的發展是不可阻擋的趨勢,我們環境無法創造工具,但是也要更好的使用工具,該包簡化了接入流程,可以非常方便的引入並使用ChatGPT
相關功能。
接入方式
lucy-chat
提供了兩種形式接入服務,完成集成或者獨立部署後可以訪問[部署地址]/doc.html
調用相關接口。
1. Jar引入
準備
在引入任何 Lucy
系列依賴之前,需要完成jitpack
鏡像倉庫的配置。
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://www.jitpack.io</url>
</repository>
</repositories>
引入
根據版本號引入
當前默認1.0.0-r4
<dependency>
<groupId>com.gitee.kindear</groupId>
<artifactId>lucy-chat</artifactId>
<version>${version}</version>
</dependency>
啓動類
啓用 knife4j
文檔,需要在啓動類上配置 @EnableKnife4j
@EnableKnife4j
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(LucyAdminApplication.class, args);
}
}
配置文件
使用 lucy-chat
需要配置如下文件信息
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. 獨立服務
- 從開源地址下載項目
git clone https://gitee.com/Kindear/lucy-chat
- 修改
POM
文件中打包方式,即恢復<build>
相關注釋掉的內容
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- 修改相關配置文件, 參考上文的配置文件相關內容,項目中提供的
key
爲私人key
,隨時會被替換。 - 打包項目並部署