Compare commits
10 Commits
f11f5e7656
...
138ee140e1
| Author | SHA1 | Date | |
|---|---|---|---|
| 138ee140e1 | |||
| e2d69bc6e8 | |||
| b9d707dc8f | |||
| 44d1473c6b | |||
| 9c658afbd7 | |||
| e3f86e6497 | |||
| 256c8c6bd5 | |||
| b627c91acb | |||
| 7fb490778a | |||
| d4d5aede31 |
@@ -1,14 +1,12 @@
|
||||
import {cd, path} from 'zx'
|
||||
import {trim} from "licia";
|
||||
import {run_deploy, run_package, run_upload_normal} from '../../bin/library.js'
|
||||
import {run_deploy} from '../../bin/library.js'
|
||||
|
||||
// 切换目录
|
||||
cd(trim(path.dirname(import.meta.dirname)))
|
||||
// 执行流程
|
||||
try {
|
||||
await run_deploy('service-ai-core')
|
||||
await run_package('service-ai-chat')
|
||||
await run_upload_normal('service-ai-chat')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import {cd, path} from 'zx'
|
||||
import {trim} from "licia";
|
||||
import {run_deploy, run_package, run_upload_normal} from '../../bin/library.js'
|
||||
|
||||
// 切换目录
|
||||
cd(trim(path.dirname(import.meta.dirname)))
|
||||
// 执行流程
|
||||
try {
|
||||
await run_deploy('service-ai-core')
|
||||
await run_package('service-ai-knowledge')
|
||||
await run_upload_normal('service-ai-knowledge')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
21
service-ai/bin/build-ai-web.js
Normal file
21
service-ai/bin/build-ai-web.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
cd,
|
||||
path,
|
||||
} from 'zx'
|
||||
import {trim} from "licia";
|
||||
import {
|
||||
run_deploy,
|
||||
run_package,
|
||||
run_upload_normal,
|
||||
} from '../../bin/library.js'
|
||||
|
||||
// 切换目录
|
||||
cd(trim(path.dirname(import.meta.dirname)))
|
||||
// 执行流程
|
||||
try {
|
||||
await run_deploy('service-ai-core')
|
||||
await run_package('service-ai-web')
|
||||
await run_upload_normal('service-ai-web')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
11
service-ai/database/service_ai_feedback.sql
Normal file
11
service-ai/database/service_ai_feedback.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE `service_ai_feedback`
|
||||
(
|
||||
`id` bigint NOT NULL,
|
||||
`source` longtext NOT NULL,
|
||||
`analysis_short` longtext,
|
||||
`analysis` longtext,
|
||||
`pictures` longtext,
|
||||
`status` varchar(50) NOT NULL DEFAULT 'ANALYSIS_PROCESSING',
|
||||
`created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) DEFAULT CHARSET = utf8mb4;
|
||||
@@ -11,8 +11,7 @@
|
||||
<description>Hudi AI服务集合</description>
|
||||
<modules>
|
||||
<module>service-ai-core</module>
|
||||
<module>service-ai-chat</module>
|
||||
<module>service-ai-knowledge</module>
|
||||
<module>service-ai-web</module>
|
||||
<module>service-ai-cli</module>
|
||||
</modules>
|
||||
|
||||
@@ -32,6 +31,13 @@
|
||||
<hutool.version>5.8.27</hutool.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- 当前项目依赖 -->
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>service-ai</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-ai-chat</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.lanyuanxiaoyao</groupId>
|
||||
<artifactId>service-ai-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-deepseek</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-openai</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-ai</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-ai-dialect-openai</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat.entity;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250516
|
||||
*/
|
||||
public class MessageVO {
|
||||
private String role;
|
||||
private String content;
|
||||
private String reason;
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MessageVO{" +
|
||||
"role='" + role + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
", reason='" + reason + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
spring:
|
||||
application:
|
||||
name: service-ai-chat
|
||||
profiles:
|
||||
include: random-port,common,discovery,metrics,forest
|
||||
ai:
|
||||
deepseek:
|
||||
base-url: http://132.121.206.65:10086/v1
|
||||
api-key: ENC(K+Hff9QGC+fcyi510VIDd9CaeK/IN5WBJ9rlkUsHEdDgIidW+stHHJlsK0lLPUXXREha+ToQZqqDXJrqSE+GUKCXklFhelD8bRHFXBIeP/ZzT2cxhzgKUXgjw3S0Qw2R)
|
||||
chat:
|
||||
options:
|
||||
model: 'Qwen3/qwen3-1.7b'
|
||||
mvc:
|
||||
async:
|
||||
request-timeout: 3600000
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250606
|
||||
*/
|
||||
public class TestDatetimeFormat {
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(LocalDate.parse("20250606", FORMATTER).format(FORMATTER));
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.tools.TableTool;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.tools.YarnTool;
|
||||
import java.net.http.HttpClient;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.deepseek.DeepSeekChatModel;
|
||||
import org.springframework.ai.deepseek.DeepSeekChatOptions;
|
||||
import org.springframework.ai.deepseek.api.DeepSeekApi;
|
||||
import org.springframework.http.client.JdkClientHttpRequestFactory;
|
||||
import org.springframework.http.client.reactive.JdkClientHttpConnector;
|
||||
import org.springframework.web.client.RestClient;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
public class TestLlmPlan {
|
||||
public static void main(String[] args) {
|
||||
ChatClient client = ChatClient.builder(
|
||||
DeepSeekChatModel.builder()
|
||||
.deepSeekApi(
|
||||
DeepSeekApi.builder()
|
||||
.baseUrl("http://127.0.0.1:1234/v1")
|
||||
.apiKey("nopassword")
|
||||
.restClientBuilder(restClientBuilder())
|
||||
.webClientBuilder(webClientBuilder())
|
||||
.build()
|
||||
)
|
||||
.defaultOptions(
|
||||
DeepSeekChatOptions.builder()
|
||||
.model("qwen/qwen3-1.7b")
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.defaultSystem(StrUtil.format(
|
||||
"""
|
||||
你是一名专业的AI运维助手,专职负责“Hudi数据同步服务”的平台运维工作。你的核心职责是:
|
||||
1.友好解答:积极、专业地解答用户(通常是平台管理员或用户)关于该平台运维工作的疑问。
|
||||
2.知识驱动:在解答时,应尽可能通过各种方式(知识库、上下文、外部工具等)全面获取准确知识和数据来支持回答。
|
||||
3.诚实守界:
|
||||
对于无法通过已有知识或数据确认的问题,必须明确告知用户你无法解答,切勿捏造信息或提供不确定的答案。
|
||||
对于与该Hudi数据同步服务平台运维工作无关的问题,需委婉拒绝用户,并明确说明超出你的职责和能力范围。
|
||||
|
||||
对话语言:中文
|
||||
|
||||
{}
|
||||
""",
|
||||
Prompts.hudi
|
||||
))
|
||||
.defaultTools(
|
||||
new TableTool(),
|
||||
new YarnTool()
|
||||
)
|
||||
.build();
|
||||
System.out.println(client.prompt("""
|
||||
我需要大模型帮我检查系统整体运行状态,帮我设计详细的指导大模型具体操作的操作步骤
|
||||
避免使用上下文中没有提到的外部工具
|
||||
""").call().content());
|
||||
}
|
||||
|
||||
private static HttpClient httpClient() {
|
||||
return HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static RestClient.Builder restClientBuilder() {
|
||||
return RestClient.builder()
|
||||
.requestFactory(new JdkClientHttpRequestFactory(httpClient()));
|
||||
}
|
||||
|
||||
private static WebClient.Builder webClientBuilder() {
|
||||
return WebClient.builder()
|
||||
.clientConnector(new JdkClientHttpConnector(httpClient()));
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.io.IOException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.noear.solon.ai.rag.Document;
|
||||
import org.noear.solon.ai.reranking.RerankingModel;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.document.MetadataMode;
|
||||
import org.springframework.ai.embedding.EmbeddingModel;
|
||||
import org.springframework.ai.openai.OpenAiChatModel;
|
||||
import org.springframework.ai.openai.OpenAiChatOptions;
|
||||
import org.springframework.ai.openai.OpenAiEmbeddingModel;
|
||||
import org.springframework.ai.openai.OpenAiEmbeddingOptions;
|
||||
import org.springframework.ai.openai.api.OpenAiApi;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.client.JdkClientHttpRequestFactory;
|
||||
import org.springframework.http.client.reactive.JdkClientHttpConnector;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.web.client.RestClient;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250514
|
||||
*/
|
||||
public class TestModel {
|
||||
public static void main(String[] args) throws IOException {
|
||||
// testChatModel();
|
||||
testVisualModel();
|
||||
testEmbeddingModel();
|
||||
testRerankingModel();
|
||||
}
|
||||
|
||||
private static void testChatModel() {
|
||||
for (String model : List.of(
|
||||
"Qwen3/qwen3-0.6b",
|
||||
"Qwen3/qwen3-1.7b",
|
||||
"Qwen3/qwen3-4b",
|
||||
"Qwen3/qwen3-4b-q4km",
|
||||
"Qwen3/qwen3-8b-q4km"
|
||||
)) {
|
||||
System.out.println(model);
|
||||
long start = System.currentTimeMillis();
|
||||
ChatClient client = chatClient(model);
|
||||
String content = client.prompt()
|
||||
.user("你好,详细介绍一下是谁,能帮我做什么?")
|
||||
.call()
|
||||
.content();
|
||||
System.out.println(content.length() * 1000.0 / (System.currentTimeMillis() - start));
|
||||
}
|
||||
}
|
||||
|
||||
private static void testVisualModel() {
|
||||
for (String model : List.of(
|
||||
"Qwen2.5/qwen2.5-vl-7b",
|
||||
"Qwen2.5/qwen2.5-vl-7b-q4km",
|
||||
"Qwen2.5/qwen2.5-vl-3b-instruct",
|
||||
"Qwen2.5/qwen2.5-vl-7b-instruct",
|
||||
"MiniCPM/minicpm-o-2.6-7.6b",
|
||||
"MiniCPM/minicpm-o-2.6-7.6b-q4km"
|
||||
|
||||
)) {
|
||||
ChatClient client = chatClient(model);
|
||||
String content = client.prompt()
|
||||
.user(spec -> spec.text("根据图片中的内容编一个童话小故事").media(MimeTypeUtils.IMAGE_PNG, new FileSystemResource("/Users/lanyuanxiaoyao/Pictures/deepseek.png")))
|
||||
.call()
|
||||
.content();
|
||||
System.out.println(StrUtil.trim(content));
|
||||
}
|
||||
}
|
||||
|
||||
private static void testEmbeddingModel() {
|
||||
for (String model : List.of(
|
||||
"Qwen3/qwen3-embedding-0.6b",
|
||||
"Qwen3/qwen3-embedding-4b",
|
||||
"Qwen3/qwen3-embedding-4b-q4km",
|
||||
"Qwen3/qwen3-embedding-8b-q4km",
|
||||
"BGE/bge-m3",
|
||||
"BGE/bge-m3-q4km"
|
||||
)) {
|
||||
EmbeddingModel embeddingModel = embeddingModel(model);
|
||||
float[] worlds = embeddingModel.embed("Hello world");
|
||||
System.out.println(Arrays.toString(worlds));
|
||||
}
|
||||
}
|
||||
|
||||
private static void testRerankingModel() throws IOException {
|
||||
for (String model : List.of(
|
||||
"BGE/beg-reranker-v2",
|
||||
"BGE/beg-reranker-v2-q4km"
|
||||
)) {
|
||||
System.out.println(model);
|
||||
RerankingModel rerankingModel = rerankingModel(model);
|
||||
List<Document> list = rerankingModel.rerank(
|
||||
"你好",
|
||||
List.of(
|
||||
new Document("go go go,滚犊子"),
|
||||
new Document("我是tom,你最近过得好吗?"),
|
||||
new Document("666,你就是大聪明")
|
||||
)
|
||||
);
|
||||
list.forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
|
||||
private static ChatClient chatClient(String model) {
|
||||
return ChatClient.builder(
|
||||
OpenAiChatModel.builder()
|
||||
.openAiApi(
|
||||
OpenAiApi.builder()
|
||||
.baseUrl("http://132.121.206.65:10086")
|
||||
.apiKey("*XMySqV%>hR&v>>g*NwCs3tpQ5FVMFEF2VHVTj<MYQd$&@$sY7CgqNyea4giJi4")
|
||||
.restClientBuilder(restClientBuilder())
|
||||
.webClientBuilder(webClientBuilder())
|
||||
.build()
|
||||
)
|
||||
.defaultOptions(
|
||||
OpenAiChatOptions.builder()
|
||||
.model(model)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static EmbeddingModel embeddingModel(String model) {
|
||||
return new OpenAiEmbeddingModel(
|
||||
OpenAiApi.builder()
|
||||
.baseUrl("http://132.121.206.65:10086")
|
||||
.apiKey("*XMySqV%>hR&v>>g*NwCs3tpQ5FVMFEF2VHVTj<MYQd$&@$sY7CgqNyea4giJi4")
|
||||
.restClientBuilder(restClientBuilder())
|
||||
.webClientBuilder(webClientBuilder())
|
||||
.build(),
|
||||
MetadataMode.EMBED,
|
||||
OpenAiEmbeddingOptions.builder()
|
||||
.model(model)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private static RerankingModel rerankingModel(String model) {
|
||||
return RerankingModel.of("http://132.121.206.65:10086/v1/rerank")
|
||||
.model(model)
|
||||
.apiKey("*XMySqV%>hR&v>>g*NwCs3tpQ5FVMFEF2VHVTj<MYQd$&@$sY7CgqNyea4giJi4")
|
||||
.timeout(Duration.ofMinutes(10))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static HttpClient httpClient() {
|
||||
return HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static RestClient.Builder restClientBuilder() {
|
||||
return RestClient.builder()
|
||||
.requestFactory(new JdkClientHttpRequestFactory(httpClient()));
|
||||
}
|
||||
|
||||
private static WebClient.Builder webClientBuilder() {
|
||||
return WebClient.builder()
|
||||
.clientConnector(new JdkClientHttpConnector(httpClient()));
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.net.http.HttpClient;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.openai.OpenAiChatModel;
|
||||
import org.springframework.ai.openai.OpenAiChatOptions;
|
||||
import org.springframework.ai.openai.api.OpenAiApi;
|
||||
import org.springframework.ai.tool.annotation.Tool;
|
||||
import org.springframework.ai.tool.annotation.ToolParam;
|
||||
import org.springframework.http.client.JdkClientHttpRequestFactory;
|
||||
import org.springframework.http.client.reactive.JdkClientHttpConnector;
|
||||
import org.springframework.web.client.RestClient;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.Disposable;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250613
|
||||
*/
|
||||
public class TestSpringAiTools {
|
||||
public static void main(String[] args) {
|
||||
ChatClient client = ChatClient.builder(
|
||||
OpenAiChatModel.builder()
|
||||
.openAiApi(
|
||||
OpenAiApi.builder()
|
||||
.baseUrl("http://132.121.206.65:10086")
|
||||
.apiKey("*XMySqV%>hR&v>>g*NwCs3tpQ5FVMFEF2VHVTj<MYQd$&@$sY7CgqNyea4giJi4")
|
||||
.restClientBuilder(restClientBuilder())
|
||||
.webClientBuilder(webClientBuilder())
|
||||
.build()
|
||||
)
|
||||
.defaultOptions(
|
||||
OpenAiChatOptions.builder()
|
||||
.model("Qwen3/qwen3-1.7b")
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
Disposable disposable = client.prompt()
|
||||
.tools(new TestTool())
|
||||
.user("调用submit工具生成一个关于「猪」的笑话")
|
||||
.stream()
|
||||
.content()
|
||||
.subscribe(System.out::println);
|
||||
while (!disposable.isDisposed()) {
|
||||
}
|
||||
}
|
||||
|
||||
private static HttpClient httpClient() {
|
||||
return HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static RestClient.Builder restClientBuilder() {
|
||||
return RestClient.builder()
|
||||
.requestFactory(new JdkClientHttpRequestFactory(httpClient()));
|
||||
}
|
||||
|
||||
private static WebClient.Builder webClientBuilder() {
|
||||
return WebClient.builder()
|
||||
.clientConnector(new JdkClientHttpConnector(httpClient()));
|
||||
}
|
||||
|
||||
public static final class TestTool {
|
||||
@Tool(description = "传入任意动物名称,返回一个关于这个动物的笑话")
|
||||
public String submit(@ToolParam(description = "动物名称") String animalName) {
|
||||
return StrUtil.format("{}掉沟里了", animalName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.lanyuanxiaoyao.service.ai.core.configuration;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* 使用雪花算法作为ID生成器
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-14
|
||||
*/
|
||||
public class SnowflakeId {
|
||||
/**
|
||||
* 起始的时间戳
|
||||
*/
|
||||
private final static long START_TIMESTAMP = 1;
|
||||
|
||||
/**
|
||||
* 序列号占用的位数
|
||||
*/
|
||||
private final static long SEQUENCE_BIT = 11;
|
||||
|
||||
/**
|
||||
* 序列号最大值
|
||||
*/
|
||||
private final static long MAX_SEQUENCE_BIT = ~(-1 << SEQUENCE_BIT);
|
||||
|
||||
/**
|
||||
* 时间戳值向左位移
|
||||
*/
|
||||
private final static long TIMESTAMP_OFFSET = SEQUENCE_BIT;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
private static long sequence = 0;
|
||||
/**
|
||||
* 上一次时间戳
|
||||
*/
|
||||
private static long lastTimestamp = -1;
|
||||
|
||||
public static synchronized long next() {
|
||||
long currentTimestamp = nowTimestamp();
|
||||
if (currentTimestamp < lastTimestamp) {
|
||||
throw new RuntimeException("Clock have moved backwards.");
|
||||
}
|
||||
|
||||
if (currentTimestamp == lastTimestamp) {
|
||||
// 相同毫秒内, 序列号自增
|
||||
sequence = (sequence + 1) & MAX_SEQUENCE_BIT;
|
||||
// 同一毫秒的序列数已经达到最大
|
||||
if (sequence == 0) {
|
||||
currentTimestamp = nextTimestamp();
|
||||
}
|
||||
} else {
|
||||
// 不同毫秒内, 序列号置为0
|
||||
sequence = 0;
|
||||
}
|
||||
|
||||
lastTimestamp = currentTimestamp;
|
||||
return (currentTimestamp - START_TIMESTAMP) << TIMESTAMP_OFFSET | sequence;
|
||||
}
|
||||
|
||||
private static long nextTimestamp() {
|
||||
long milli = nowTimestamp();
|
||||
while (milli <= lastTimestamp) {
|
||||
milli = nowTimestamp();
|
||||
}
|
||||
return milli;
|
||||
}
|
||||
|
||||
private static long nowTimestamp() {
|
||||
return Instant.now().toEpochMilli();
|
||||
}
|
||||
}
|
||||
@@ -17,22 +17,30 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
*/
|
||||
@Configuration
|
||||
public class WebClientConfiguration {
|
||||
private HttpClient httpClient() {
|
||||
return HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public RestClient.Builder restClientBuilder() {
|
||||
return RestClient.builder()
|
||||
.requestFactory(new JdkClientHttpRequestFactory(httpClient()));
|
||||
return generateRestClientBuilder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public WebClient.Builder webClientBuilder() {
|
||||
return generateWebClientBuilder();
|
||||
}
|
||||
|
||||
private static HttpClient httpClient() {
|
||||
return HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static RestClient.Builder generateRestClientBuilder() {
|
||||
return RestClient.builder()
|
||||
.requestFactory(new JdkClientHttpRequestFactory(httpClient()));
|
||||
}
|
||||
|
||||
public static WebClient.Builder generateWebClientBuilder() {
|
||||
return WebClient.builder()
|
||||
.clientConnector(new JdkClientHttpConnector(httpClient()));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
@@ -20,11 +21,15 @@ import org.springframework.security.web.SecurityFilterChain;
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SecurityConfig.class);
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
return http.authorizeHttpRequests(registry -> registry.anyRequest().authenticated())
|
||||
return http.authorizeHttpRequests(
|
||||
registry -> registry
|
||||
.requestMatchers(HttpMethod.OPTIONS, "/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
)
|
||||
.httpBasic(Customizer.withDefaults())
|
||||
.cors(AbstractHttpConfigurer::disable)
|
||||
.csrf(AbstractHttpConfigurer::disable)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge;
|
||||
|
||||
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250515
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = "com.lanyuanxiaoyao.service")
|
||||
@EnableDiscoveryClient
|
||||
@EnableConfigurationProperties
|
||||
@EnableEncryptableProperties
|
||||
@EnableRetry
|
||||
@EnableScheduling
|
||||
public class KnowledgeApplication implements ApplicationRunner {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(KnowledgeApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.configuration;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250527
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "knowledge")
|
||||
public class KnowledgeConfiguration {
|
||||
private String downloadPrefix;
|
||||
private String uploadPath;
|
||||
|
||||
public String getDownloadPrefix() {
|
||||
return downloadPrefix;
|
||||
}
|
||||
|
||||
public void setDownloadPrefix(String downloadPrefix) {
|
||||
this.downloadPrefix = downloadPrefix;
|
||||
}
|
||||
|
||||
public String getUploadPath() {
|
||||
return uploadPath;
|
||||
}
|
||||
|
||||
public void setUploadPath(String uploadPath) {
|
||||
this.uploadPath = uploadPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KnowledgeConfiguration{" +
|
||||
"downloadPrefix='" + downloadPrefix + '\'' +
|
||||
", uploadPath='" + uploadPath + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.configuration;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.noear.solon.ai.reranking.RerankingModel;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250604
|
||||
*/
|
||||
@Configuration
|
||||
public class SolonConfiguration {
|
||||
@Bean
|
||||
public RerankingModel rerankingModel(SolonProperties solonProperties) {
|
||||
return RerankingModel.of(StrUtil.format("{}{}", solonProperties.getBaseUrl(), solonProperties.getRerank().getEndpoint()))
|
||||
.apiKey(solonProperties.getApiKey())
|
||||
.model(solonProperties.getRerank().getModel())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.configuration;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250604
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "solon")
|
||||
public class SolonProperties {
|
||||
private String baseUrl;
|
||||
private String apiKey;
|
||||
private Rerank rerank;
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public Rerank getRerank() {
|
||||
return rerank;
|
||||
}
|
||||
|
||||
public void setRerank(Rerank rerank) {
|
||||
this.rerank = rerank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SolonProperties{" +
|
||||
"baseUrl='" + baseUrl + '\'' +
|
||||
", apiKey='" + apiKey + '\'' +
|
||||
", rerank=" + rerank +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static final class Rerank {
|
||||
private String model;
|
||||
private String endpoint;
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public void setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Rerank{" +
|
||||
"model='" + model + '\'' +
|
||||
", endpoint='" + endpoint + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
import org.springframework.ai.document.Document;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250523
|
||||
*/
|
||||
public class EmbeddingContext {
|
||||
private Long vectorSourceId;
|
||||
private Long groupId;
|
||||
private Config config;
|
||||
private String content;
|
||||
private String file;
|
||||
private String fileFormat;
|
||||
private List<Document> documents = Lists.mutable.empty();
|
||||
private Map<String, Object> metadata = Maps.mutable.empty();
|
||||
|
||||
private EmbeddingContext(Builder builder) {
|
||||
setVectorSourceId(builder.vectorSourceId);
|
||||
setGroupId(builder.groupId);
|
||||
setConfig(builder.config);
|
||||
setContent(builder.content);
|
||||
setFile(builder.file);
|
||||
setFileFormat(builder.fileFormat);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Long getVectorSourceId() {
|
||||
return vectorSourceId;
|
||||
}
|
||||
|
||||
public void setVectorSourceId(Long vectorSourceId) {
|
||||
this.vectorSourceId = vectorSourceId;
|
||||
}
|
||||
|
||||
public Config getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Config config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getFileFormat() {
|
||||
return fileFormat;
|
||||
}
|
||||
|
||||
public void setFileFormat(String fileFormat) {
|
||||
this.fileFormat = fileFormat;
|
||||
}
|
||||
|
||||
public List<Document> getDocuments() {
|
||||
return documents;
|
||||
}
|
||||
|
||||
public void setDocuments(List<Document> documents) {
|
||||
this.documents = documents;
|
||||
}
|
||||
|
||||
public Map<String, Object> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(Map<String, Object> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EmbeddingContext{" +
|
||||
"vectorSourceId=" + vectorSourceId +
|
||||
", groupId=" + groupId +
|
||||
", config=" + config +
|
||||
", content='" + content + '\'' +
|
||||
", file='" + file + '\'' +
|
||||
", fileFormat='" + fileFormat + '\'' +
|
||||
", documents=" + documents +
|
||||
", metadata=" + metadata +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static final class Config {
|
||||
private SplitStrategy splitStrategy = SplitStrategy.NORMAL;
|
||||
|
||||
private Config(Builder builder) {setSplitStrategy(builder.splitStrategy);}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public SplitStrategy getSplitStrategy() {
|
||||
return splitStrategy;
|
||||
}
|
||||
|
||||
public void setSplitStrategy(SplitStrategy splitStrategy) {
|
||||
this.splitStrategy = splitStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Config{" +
|
||||
"splitStrategy=" + splitStrategy +
|
||||
'}';
|
||||
}
|
||||
|
||||
public enum SplitStrategy {
|
||||
NORMAL, LLM, QA
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private SplitStrategy splitStrategy;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder splitStrategy(SplitStrategy val) {
|
||||
splitStrategy = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config build() {
|
||||
return new Config(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private Long vectorSourceId;
|
||||
private Long groupId;
|
||||
private Config config;
|
||||
private String content;
|
||||
private String file;
|
||||
private String fileFormat;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder vectorSourceId(Long val) {
|
||||
vectorSourceId = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder groupId(Long val) {
|
||||
groupId = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder config(Config val) {
|
||||
config = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder content(String val) {
|
||||
content = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder file(String val) {
|
||||
file = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fileFormat(String val) {
|
||||
fileFormat = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbeddingContext build() {
|
||||
return new EmbeddingContext(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.entity;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250527
|
||||
*/
|
||||
public class Group {
|
||||
private String id;
|
||||
private String name;
|
||||
private String status;
|
||||
private Long createdTime;
|
||||
private Long modifiedTime;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public void setCreatedTime(Long createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public Long getModifiedTime() {
|
||||
return modifiedTime;
|
||||
}
|
||||
|
||||
public void setModifiedTime(Long modifiedTime) {
|
||||
this.modifiedTime = modifiedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupVO{" +
|
||||
"id='" + id + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", createdTime=" + createdTime +
|
||||
", modifiedTime=" + modifiedTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.entity;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250522
|
||||
*/
|
||||
public class Knowledge {
|
||||
private Long id;
|
||||
private Long vectorSourceId;
|
||||
private String name;
|
||||
private String strategy;
|
||||
private Long createdTime;
|
||||
private Long modifiedTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVectorSourceId() {
|
||||
return vectorSourceId;
|
||||
}
|
||||
|
||||
public void setVectorSourceId(Long vectorSourceId) {
|
||||
this.vectorSourceId = vectorSourceId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStrategy() {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
public void setStrategy(String strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public Long getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public void setCreatedTime(Long createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public Long getModifiedTime() {
|
||||
return modifiedTime;
|
||||
}
|
||||
|
||||
public void setModifiedTime(Long modifiedTime) {
|
||||
this.modifiedTime = modifiedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Knowledge{" +
|
||||
"id=" + id +
|
||||
", vectorSourceId=" + vectorSourceId +
|
||||
", name='" + name + '\'' +
|
||||
", strategy='" + strategy + '\'' +
|
||||
", createdTime=" + createdTime +
|
||||
", modifiedTime=" + modifiedTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.entity.vo;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250527
|
||||
*/
|
||||
public class DataFileVO {
|
||||
private String id;
|
||||
private String filename;
|
||||
private Long size;
|
||||
private String md5;
|
||||
private String path;
|
||||
private String type;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getMd5() {
|
||||
return md5;
|
||||
}
|
||||
|
||||
public void setMd5(String md5) {
|
||||
this.md5 = md5;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataFile{" +
|
||||
"id='" + id + '\'' +
|
||||
", filename='" + filename + '\'' +
|
||||
", size=" + size +
|
||||
", md5='" + md5 + '\'' +
|
||||
", path='" + path + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.entity.vo;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250516
|
||||
*/
|
||||
public class KnowledgeVO {
|
||||
private String id;
|
||||
private String vectorSourceId;
|
||||
private String name;
|
||||
private String strategy;
|
||||
private Long size;
|
||||
private Long points;
|
||||
private Long segments;
|
||||
private String status;
|
||||
private Long createdTime;
|
||||
private Long modifiedTime;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getVectorSourceId() {
|
||||
return vectorSourceId;
|
||||
}
|
||||
|
||||
public void setVectorSourceId(String vectorSourceId) {
|
||||
this.vectorSourceId = vectorSourceId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStrategy() {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
public void setStrategy(String strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Long getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(Long points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public Long getSegments() {
|
||||
return segments;
|
||||
}
|
||||
|
||||
public void setSegments(Long segments) {
|
||||
this.segments = segments;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public void setCreatedTime(Long createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public Long getModifiedTime() {
|
||||
return modifiedTime;
|
||||
}
|
||||
|
||||
public void setModifiedTime(Long modifiedTime) {
|
||||
this.modifiedTime = modifiedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KnowledgeVO{" +
|
||||
"id='" + id + '\'' +
|
||||
", vectorSourceId='" + vectorSourceId + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", strategy='" + strategy + '\'' +
|
||||
", size=" + size +
|
||||
", points=" + points +
|
||||
", segments=" + segments +
|
||||
", status='" + status + '\'' +
|
||||
", createdTime=" + createdTime +
|
||||
", modifiedTime=" + modifiedTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.entity.vo;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250516
|
||||
*/
|
||||
public class SegmentVO {
|
||||
private String id;
|
||||
private String text;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PointVO{" +
|
||||
"id='" + id + '\'' +
|
||||
", text='" + text + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
spring:
|
||||
application:
|
||||
name: service-ai-knowledge
|
||||
profiles:
|
||||
include: random-port,common,discovery,metrics,forest
|
||||
ai:
|
||||
openai:
|
||||
base-url: http://132.121.206.65:10086
|
||||
api-key: ENC(K+Hff9QGC+fcyi510VIDd9CaeK/IN5WBJ9rlkUsHEdDgIidW+stHHJlsK0lLPUXXREha+ToQZqqDXJrqSE+GUKCXklFhelD8bRHFXBIeP/ZzT2cxhzgKUXgjw3S0Qw2R)
|
||||
chat:
|
||||
options:
|
||||
model: 'Qwen3/qwen3-1.7b'
|
||||
embedding:
|
||||
options:
|
||||
model: 'Qwen3/qwen3-embedding-4b'
|
||||
vectorstore:
|
||||
qdrant:
|
||||
host: 132.121.206.65
|
||||
port: 29463
|
||||
api-key: ENC(0/0UkIKeAvyV17yNqSU3v04wmm8CdWKe4BYSSJa2FuBtK12TcZRJPdwk+ZpYnpISv+KmVTUrrmFBzAYrDR3ysA==)
|
||||
liteflow:
|
||||
rule-source: config/flow.xml
|
||||
print-banner: false
|
||||
check-node-exists: false
|
||||
solon:
|
||||
base-url: http://132.121.206.65:10086
|
||||
api-key: ENC(K+Hff9QGC+fcyi510VIDd9CaeK/IN5WBJ9rlkUsHEdDgIidW+stHHJlsK0lLPUXXREha+ToQZqqDXJrqSE+GUKCXklFhelD8bRHFXBIeP/ZzT2cxhzgKUXgjw3S0Qw2R)
|
||||
rerank:
|
||||
model: 'Bge-reranker-v2-vllm'
|
||||
endpoint: '/v1/rerank'
|
||||
@@ -1,34 +0,0 @@
|
||||
<configuration>
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
|
||||
<springProperty scope="context" name="LOKI_PUSH_URL" source="loki.url"/>
|
||||
<springProperty scope="context" name="LOGGING_PARENT" source="logging.parent"/>
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %clr(%5p) %clr([${HOSTNAME}]){yellow} %clr([%t]){magenta} %clr(%logger{40}){cyan} #@# %m%n%wEx</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOGGING_PARENT:-.}/${APP_NAME:-run}.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOGGING_PARENT:-.}/archive/${APP_NAME:-run}-%d{yyyy-MM-dd}.gz</fileNamePattern>
|
||||
<MaxHistory>7</MaxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [${HOSTNAME}] [%t] %logger #@# %m%n%wEx</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="com.zaxxer.hikari" level="ERROR"/>
|
||||
<logger name="com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver" level="WARN"/>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="Console"/>
|
||||
<appender-ref ref="RollingFile"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -9,7 +9,7 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-ai-knowledge</artifactId>
|
||||
<artifactId>service-ai-web</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -26,6 +26,10 @@
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-openai</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-deepseek</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-vector-store-qdrant</artifactId>
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat;
|
||||
package com.lanyuanxiaoyao.service.ai.web;
|
||||
|
||||
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -9,29 +11,35 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250514
|
||||
* @version 20250515
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = "com.lanyuanxiaoyao.service")
|
||||
@EnableDiscoveryClient
|
||||
@EnableConfigurationProperties
|
||||
@EnableEncryptableProperties
|
||||
@EnableRetry
|
||||
public class AiChatApplication implements ApplicationContextAware {
|
||||
@EnableScheduling
|
||||
public class WebApplication implements ApplicationRunner, ApplicationContextAware {
|
||||
private static ApplicationContext context;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AiChatApplication.class, args);
|
||||
SpringApplication.run(WebApplication.class, args);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return context.getBean(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext context) throws BeansException {
|
||||
AiChatApplication.context = context;
|
||||
WebApplication.context = context;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.configuration;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250527
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "file-store")
|
||||
public class FileStoreConfiguration {
|
||||
private String downloadPrefix;
|
||||
private String uploadPath;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.configuration;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.time.Duration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.noear.solon.ai.reranking.RerankingModel;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.deepseek.DeepSeekChatModel;
|
||||
import org.springframework.ai.deepseek.DeepSeekChatOptions;
|
||||
import org.springframework.ai.deepseek.api.DeepSeekApi;
|
||||
import org.springframework.ai.document.MetadataMode;
|
||||
import org.springframework.ai.embedding.EmbeddingModel;
|
||||
import org.springframework.ai.openai.OpenAiChatModel;
|
||||
import org.springframework.ai.openai.OpenAiChatOptions;
|
||||
import org.springframework.ai.openai.OpenAiEmbeddingModel;
|
||||
import org.springframework.ai.openai.OpenAiEmbeddingOptions;
|
||||
import org.springframework.ai.openai.api.OpenAiApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestClient;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class LlmConfiguration {
|
||||
@Bean("chat")
|
||||
public ChatClient.Builder chatClientBuilder(LlmProperties llmProperties, WebClient.Builder webClientBuilder, RestClient.Builder restClientBuilder) {
|
||||
Assert.notNull(llmProperties.getChat(), "chat properties is null");
|
||||
DeepSeekApi.Builder apiBuilder = DeepSeekApi.builder()
|
||||
.baseUrl(StrUtil.firstNonBlank(llmProperties.getChat().getBaseUrl(), llmProperties.getBaseUrl()))
|
||||
.apiKey(StrUtil.firstNonBlank(llmProperties.getChat().getApiKey(), llmProperties.getApiKey()))
|
||||
.webClientBuilder(webClientBuilder)
|
||||
.restClientBuilder(restClientBuilder);
|
||||
if (StrUtil.isNotBlank(llmProperties.getChat().getEndpoint())) {
|
||||
apiBuilder.completionsPath(llmProperties.getChat().getEndpoint());
|
||||
}
|
||||
return ChatClient.builder(
|
||||
DeepSeekChatModel.builder()
|
||||
.deepSeekApi(apiBuilder.build())
|
||||
.defaultOptions(
|
||||
DeepSeekChatOptions.builder()
|
||||
.model(llmProperties.getChat().getModel())
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Bean("visual")
|
||||
public ChatClient.Builder visualClientBuilder(LlmProperties llmProperties, WebClient.Builder webClientBuilder, RestClient.Builder restClientBuilder) {
|
||||
Assert.notNull(llmProperties.getVisual(), "visual properties is null");
|
||||
OpenAiApi.Builder apiBuilder = OpenAiApi.builder()
|
||||
.baseUrl(StrUtil.firstNonBlank(llmProperties.getVisual().getBaseUrl(), llmProperties.getBaseUrl()))
|
||||
.apiKey(StrUtil.firstNonBlank(llmProperties.getVisual().getApiKey(), llmProperties.getApiKey()))
|
||||
.webClientBuilder(webClientBuilder)
|
||||
.restClientBuilder(restClientBuilder);
|
||||
if (StrUtil.isNotBlank(llmProperties.getVisual().getEndpoint())) {
|
||||
apiBuilder.completionsPath(llmProperties.getVisual().getEndpoint());
|
||||
}
|
||||
return ChatClient.builder(
|
||||
OpenAiChatModel.builder()
|
||||
.openAiApi(apiBuilder.build())
|
||||
.defaultOptions(
|
||||
OpenAiChatOptions.builder()
|
||||
.model(llmProperties.getChat().getModel())
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EmbeddingModel embeddingModel(LlmProperties llmProperties, WebClient.Builder webClientBuilder, RestClient.Builder restClientBuilder) {
|
||||
Assert.notNull(llmProperties.getEmbedding(), "embedding properties is null");
|
||||
OpenAiApi.Builder apiBuilder = OpenAiApi.builder()
|
||||
.baseUrl(StrUtil.firstNonBlank(llmProperties.getEmbedding().getBaseUrl(), llmProperties.getBaseUrl()))
|
||||
.apiKey(StrUtil.firstNonBlank(llmProperties.getEmbedding().getApiKey(), llmProperties.getApiKey()))
|
||||
.webClientBuilder(webClientBuilder)
|
||||
.restClientBuilder(restClientBuilder);
|
||||
if (StrUtil.isNotBlank(llmProperties.getEmbedding().getEndpoint())) {
|
||||
apiBuilder.embeddingsPath(llmProperties.getEmbedding().getEndpoint());
|
||||
}
|
||||
return new OpenAiEmbeddingModel(
|
||||
apiBuilder.build(),
|
||||
MetadataMode.EMBED,
|
||||
OpenAiEmbeddingOptions.builder()
|
||||
.model(llmProperties.getEmbedding().getModel())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RerankingModel rerankingModel(LlmProperties llmProperties) {
|
||||
Assert.notNull(llmProperties.getReranker(), "reranker properties is null");
|
||||
String url = llmProperties.getBaseUrl();
|
||||
if (StrUtil.isNotBlank(llmProperties.getReranker().getBaseUrl())) {
|
||||
url = llmProperties.getReranker().getBaseUrl();
|
||||
}
|
||||
if (StrUtil.isNotBlank(llmProperties.getReranker().getEndpoint())) {
|
||||
url += llmProperties.getReranker().getEndpoint();
|
||||
} else {
|
||||
url += "/v1/rerank";
|
||||
}
|
||||
return RerankingModel.of(url)
|
||||
.apiKey(StrUtil.firstNonBlank(llmProperties.getReranker().getApiKey(), llmProperties.getApiKey()))
|
||||
.model(llmProperties.getReranker().getModel())
|
||||
.timeout(Duration.ofMinutes(10))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.configuration;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "spring.llm")
|
||||
public class LlmProperties {
|
||||
private String baseUrl;
|
||||
private String apiKey;
|
||||
private ChatProperties chat;
|
||||
private ChatProperties visual;
|
||||
private ChatProperties embedding;
|
||||
private ChatProperties reranker;
|
||||
|
||||
@Data
|
||||
public static class ChatProperties {
|
||||
private String baseUrl;
|
||||
private String apiKey;
|
||||
private String model;
|
||||
private String endpoint;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat;
|
||||
package com.lanyuanxiaoyao.service.ai.web.configuration;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.controller;
|
||||
package com.lanyuanxiaoyao.service.ai.web.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
@@ -7,9 +7,9 @@ import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.configuration.KnowledgeConfiguration;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.DataFileVO;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.service.DataFileService;
|
||||
import com.lanyuanxiaoyao.service.ai.web.configuration.FileStoreConfiguration;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.vo.DataFileVO;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.DataFileService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -17,9 +17,11 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -35,22 +37,21 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/upload")
|
||||
public class DataFileController {
|
||||
private static final Logger log = LoggerFactory.getLogger(DataFileController.class);
|
||||
|
||||
private final KnowledgeConfiguration knowledgeConfiguration;
|
||||
private final FileStoreConfiguration fileStoreConfiguration;
|
||||
private final DataFileService dataFileService;
|
||||
private final String uploadFolderPath;
|
||||
private final String cacheFolderPath;
|
||||
private final String sliceFolderPath;
|
||||
|
||||
public DataFileController(KnowledgeConfiguration knowledgeConfiguration, DataFileService dataFileService) {
|
||||
this.knowledgeConfiguration = knowledgeConfiguration;
|
||||
public DataFileController(FileStoreConfiguration fileStoreConfiguration, DataFileService dataFileService) {
|
||||
this.fileStoreConfiguration = fileStoreConfiguration;
|
||||
this.dataFileService = dataFileService;
|
||||
|
||||
this.uploadFolderPath = knowledgeConfiguration.getUploadPath();
|
||||
this.uploadFolderPath = fileStoreConfiguration.getUploadPath();
|
||||
this.cacheFolderPath = StrUtil.format("{}/cache", uploadFolderPath);
|
||||
this.sliceFolderPath = StrUtil.format("{}/slice", uploadFolderPath);
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class DataFileController {
|
||||
public AmisResponse<FinishResponse> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
String filename = file.getOriginalFilename();
|
||||
Long id = dataFileService.initialDataFile(filename);
|
||||
String url = StrUtil.format("{}/upload/download/{}", knowledgeConfiguration.getDownloadPrefix(), id);
|
||||
String url = StrUtil.format("{}/upload/download/{}", fileStoreConfiguration.getDownloadPrefix(), id);
|
||||
byte[] bytes = file.getBytes();
|
||||
String originMd5 = SecureUtil.md5(new ByteArrayInputStream(bytes));
|
||||
File targetFile = new File(StrUtil.format("{}/{}", uploadFolderPath, originMd5));
|
||||
@@ -156,7 +157,7 @@ public class DataFileController {
|
||||
request.uploadId,
|
||||
request.filename,
|
||||
request.uploadId.toString(),
|
||||
StrUtil.format("{}/upload/download/{}", knowledgeConfiguration.getDownloadPrefix(), request.uploadId)
|
||||
StrUtil.format("{}/upload/download/{}", fileStoreConfiguration.getDownloadPrefix(), request.uploadId)
|
||||
));
|
||||
} else {
|
||||
throw new RuntimeException("合并文件失败");
|
||||
@@ -169,213 +170,48 @@ public class DataFileController {
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static final class StartRequest {
|
||||
private String name;
|
||||
private String filename;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StartRequest{" +
|
||||
"name='" + name + '\'' +
|
||||
", filename='" + filename + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static final class StartResponse {
|
||||
private String uploadId;
|
||||
|
||||
public StartResponse() {
|
||||
}
|
||||
|
||||
public StartResponse(String uploadId) {
|
||||
this.uploadId = uploadId;
|
||||
}
|
||||
|
||||
public String getUploadId() {
|
||||
return uploadId;
|
||||
}
|
||||
|
||||
public void setUploadId(String uploadId) {
|
||||
this.uploadId = uploadId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StartResponse{" +
|
||||
"uploadId='" + uploadId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static final class SliceResponse {
|
||||
@JsonProperty("eTag")
|
||||
private String eTag;
|
||||
|
||||
public SliceResponse() {
|
||||
}
|
||||
|
||||
public SliceResponse(String eTag) {
|
||||
this.eTag = eTag;
|
||||
}
|
||||
|
||||
public String geteTag() {
|
||||
return eTag;
|
||||
}
|
||||
|
||||
public void seteTag(String eTag) {
|
||||
this.eTag = eTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SliceResponse{" +
|
||||
"eTag='" + eTag + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static final class FinishRequest {
|
||||
private String filename;
|
||||
private Long uploadId;
|
||||
private ImmutableList<Part> partList;
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public Long getUploadId() {
|
||||
return uploadId;
|
||||
}
|
||||
|
||||
public void setUploadId(Long uploadId) {
|
||||
this.uploadId = uploadId;
|
||||
}
|
||||
|
||||
public ImmutableList<Part> getPartList() {
|
||||
return partList;
|
||||
}
|
||||
|
||||
public void setPartList(ImmutableList<Part> partList) {
|
||||
this.partList = partList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinishRequest{" +
|
||||
"filename='" + filename + '\'' +
|
||||
", uploadId=" + uploadId +
|
||||
", partList=" + partList +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Data
|
||||
public static final class Part {
|
||||
private Integer partNumber;
|
||||
@JsonProperty("eTag")
|
||||
private String eTag;
|
||||
|
||||
public Integer getPartNumber() {
|
||||
return partNumber;
|
||||
}
|
||||
|
||||
public void setPartNumber(Integer partNumber) {
|
||||
this.partNumber = partNumber;
|
||||
}
|
||||
|
||||
public String geteTag() {
|
||||
return eTag;
|
||||
}
|
||||
|
||||
public void seteTag(String eTag) {
|
||||
this.eTag = eTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Part{" +
|
||||
"partNumber=" + partNumber +
|
||||
", eTag='" + eTag + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static final class FinishResponse {
|
||||
private Long id;
|
||||
private String filename;
|
||||
private String value;
|
||||
private String url;
|
||||
|
||||
public FinishResponse() {
|
||||
}
|
||||
|
||||
public FinishResponse(Long id, String filename, String value, String url) {
|
||||
this.id = id;
|
||||
this.filename = filename;
|
||||
this.value = value;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinishResponse{" +
|
||||
"id=" + id +
|
||||
", filename='" + filename + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat.controller;
|
||||
package com.lanyuanxiaoyao.service.ai.web.controller.caht;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.Prompts;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.entity.MessageVO;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.tools.ChartTool;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.tools.KnowledgeTool;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.tools.TableTool;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.tools.YarnTool;
|
||||
import com.lanyuanxiaoyao.service.ai.web.configuration.Prompts;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.vo.MessageVO;
|
||||
import com.lanyuanxiaoyao.service.ai.web.tools.ChartTool;
|
||||
import com.lanyuanxiaoyao.service.ai.web.tools.TableTool;
|
||||
import com.lanyuanxiaoyao.service.ai.web.tools.YarnTool;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -22,11 +20,11 @@ import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.ai.chat.model.Generation;
|
||||
import org.springframework.ai.deepseek.DeepSeekAssistantMessage;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
@@ -46,11 +44,11 @@ public class ChatController {
|
||||
|
||||
private final ChatClient chatClient;
|
||||
|
||||
public ChatController(ChatClient.Builder builder) {
|
||||
public ChatController(@Qualifier("chat") ChatClient.Builder builder) {
|
||||
this.chatClient = builder.build();
|
||||
}
|
||||
|
||||
private ChatClient.ChatClientRequestSpec buildRequest(Long knowledgeId, ImmutableList<MessageVO> messages) {
|
||||
private ChatClient.ChatClientRequestSpec buildRequest(ImmutableList<MessageVO> messages) {
|
||||
ChatClient.ChatClientRequestSpec spec = chatClient.prompt()
|
||||
.system(
|
||||
StrUtil.format("""
|
||||
@@ -79,9 +77,6 @@ public class ChatController {
|
||||
.collect(message -> (Message) message)
|
||||
.toList()
|
||||
);
|
||||
if (ObjectUtil.isNotNull(knowledgeId)) {
|
||||
spec.tools(new KnowledgeTool(knowledgeId));
|
||||
}
|
||||
spec.tools(
|
||||
new TableTool(),
|
||||
new YarnTool(),
|
||||
@@ -93,10 +88,9 @@ public class ChatController {
|
||||
@PostMapping("sync")
|
||||
@ResponseBody
|
||||
public MessageVO chatSync(
|
||||
@RequestParam(value = "knowledge_id", required = false) Long knowledgeId,
|
||||
@RequestBody ImmutableList<MessageVO> messages
|
||||
) {
|
||||
ChatResponse response = buildRequest(knowledgeId, messages)
|
||||
ChatResponse response = buildRequest(messages)
|
||||
.call()
|
||||
.chatResponse();
|
||||
return toMessage(response);
|
||||
@@ -104,11 +98,10 @@ public class ChatController {
|
||||
|
||||
@PostMapping("async")
|
||||
public SseEmitter chatAsync(
|
||||
@RequestParam(value = "knowledge_id", required = false) Long knowledgeId,
|
||||
@RequestBody ImmutableList<MessageVO> messages
|
||||
) {
|
||||
SseEmitter emitter = new SseEmitter();
|
||||
buildRequest(knowledgeId, messages)
|
||||
buildRequest(messages)
|
||||
.stream()
|
||||
.chatResponse()
|
||||
.subscribe(
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.controller.feedback;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.feedback.FeedbackService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("feedback")
|
||||
public class FeedbackController {
|
||||
private final FeedbackService feedbackService;
|
||||
|
||||
public FeedbackController(FeedbackService feedbackService) {
|
||||
this.feedbackService = feedbackService;
|
||||
}
|
||||
|
||||
@PostMapping("add")
|
||||
public void add(
|
||||
@RequestParam("source") String source,
|
||||
@RequestParam(value = "pictures", required = false) ImmutableList<Long> pictures
|
||||
) {
|
||||
feedbackService.add(source, ObjectUtil.defaultIfNull(pictures, Lists.immutable.empty()));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public AmisResponse<?> list() {
|
||||
return AmisResponse.responseCrudData(feedbackService.list());
|
||||
}
|
||||
|
||||
@GetMapping("delete")
|
||||
public void delete(@RequestParam("id") Long id) {
|
||||
feedbackService.remove(id);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.controller;
|
||||
package com.lanyuanxiaoyao.service.ai.web.controller.knowledge;
|
||||
|
||||
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.service.GroupService;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.knowledge.GroupService;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -14,11 +13,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250528
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("group")
|
||||
@RequestMapping("knowledge/group")
|
||||
public class GroupController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(GroupController.class);
|
||||
|
||||
private final GroupService groupService;
|
||||
|
||||
public GroupController(GroupService groupService) {
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.controller;
|
||||
package com.lanyuanxiaoyao.service.ai.web.controller.knowledge;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisMapResponse;
|
||||
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.SegmentVO;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.service.EmbeddingService;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.service.KnowledgeBaseService;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.vo.SegmentVO;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.EmbeddingService;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.knowledge.KnowledgeBaseService;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -23,11 +22,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250515
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("knowledge")
|
||||
public class KnowledgeBaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(KnowledgeBaseController.class);
|
||||
|
||||
private final KnowledgeBaseService knowledgeBaseService;
|
||||
private final EmbeddingService embeddingService;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.controller;
|
||||
package com.lanyuanxiaoyao.service.ai.web.controller.knowledge;
|
||||
|
||||
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.service.SegmentService;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.knowledge.SegmentService;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -14,11 +13,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250528
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("segment")
|
||||
@RequestMapping("knowledge/segment")
|
||||
public class SegmentController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SegmentController.class);
|
||||
|
||||
private final SegmentService segmentService;
|
||||
|
||||
public SegmentController(SegmentService segmentService) {
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
|
||||
@Data
|
||||
public class Feedback {
|
||||
private Long id;
|
||||
private String source;
|
||||
private String analysisShort;
|
||||
private String analysis;
|
||||
private ImmutableList<String> pictureIds;
|
||||
private Status status;
|
||||
private Long createdTime;
|
||||
private Long modifiedTime;
|
||||
|
||||
public enum Status {
|
||||
ANALYSIS_PROCESSING,
|
||||
ANALYSIS_SUCCESS,
|
||||
FINISHED,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250527
|
||||
*/
|
||||
@Data
|
||||
public class Group {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String status;
|
||||
private Long createdTime;
|
||||
private Long modifiedTime;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250522
|
||||
*/
|
||||
@Data
|
||||
public class Knowledge {
|
||||
private Long id;
|
||||
private Long vectorSourceId;
|
||||
private String name;
|
||||
private String strategy;
|
||||
private Long createdTime;
|
||||
private Long modifiedTime;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity.context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
import org.springframework.ai.document.Document;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250523
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class EmbeddingContext {
|
||||
private Long vectorSourceId;
|
||||
private Long groupId;
|
||||
private Config config;
|
||||
private String content;
|
||||
private String file;
|
||||
private String fileFormat;
|
||||
@Builder.Default
|
||||
private List<Document> documents = Lists.mutable.empty();
|
||||
@Builder.Default
|
||||
private Map<String, Object> metadata = Maps.mutable.empty();
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public static final class Config {
|
||||
@Builder.Default
|
||||
private SplitStrategy splitStrategy = SplitStrategy.NORMAL;
|
||||
|
||||
public enum SplitStrategy {
|
||||
NORMAL, LLM, QA
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250527
|
||||
*/
|
||||
@Data
|
||||
public class DataFileVO {
|
||||
private String id;
|
||||
private String filename;
|
||||
private Long size;
|
||||
private String md5;
|
||||
private String path;
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250516
|
||||
*/
|
||||
@Data
|
||||
public class KnowledgeVO {
|
||||
private Long id;
|
||||
private Long vectorSourceId;
|
||||
private String name;
|
||||
private String strategy;
|
||||
private Long size;
|
||||
private Long points;
|
||||
private Long segments;
|
||||
private String status;
|
||||
private Long createdTime;
|
||||
private Long modifiedTime;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250516
|
||||
*/
|
||||
@Data
|
||||
public class MessageVO {
|
||||
private String role;
|
||||
private String content;
|
||||
private String reason;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250516
|
||||
*/
|
||||
@Data
|
||||
public class SegmentVO {
|
||||
private String id;
|
||||
private String text;
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.service;
|
||||
package com.lanyuanxiaoyao.service.ai.web.service;
|
||||
|
||||
import club.kingon.sql.builder.SqlBuilder;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.DataFileVO;
|
||||
import com.lanyuanxiaoyao.service.ai.core.configuration.SnowflakeId;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.vo.DataFileVO;
|
||||
import com.lanyuanxiaoyao.service.common.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -16,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@Service
|
||||
public class DataFileService {
|
||||
private static final Logger log = LoggerFactory.getLogger(DataFileService.class);
|
||||
private static final String DATA_FILE_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_file";
|
||||
|
||||
private final JdbcTemplate template;
|
||||
@@ -47,7 +44,7 @@ public class DataFileService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long initialDataFile(String filename) {
|
||||
long id = IdUtil.getSnowflakeNextId();
|
||||
long id = SnowflakeId.next();
|
||||
template.update(
|
||||
SqlBuilder.insertInto(DATA_FILE_TABLE_NAME, "id", "filename")
|
||||
.values()
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.service;
|
||||
package com.lanyuanxiaoyao.service.ai.web.service;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.EmbeddingContext;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.Knowledge;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.DataFileVO;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.Knowledge;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.context.EmbeddingContext;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.vo.DataFileVO;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.knowledge.GroupService;
|
||||
import com.lanyuanxiaoyao.service.ai.web.service.knowledge.KnowledgeBaseService;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
@@ -15,8 +17,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -26,8 +26,6 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class EmbeddingService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmbeddingService.class);
|
||||
|
||||
private final DataFileService dataFileService;
|
||||
private final FlowExecutor executor;
|
||||
private final KnowledgeBaseService knowledgeBaseService;
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.service.feedback;
|
||||
|
||||
import club.kingon.sql.builder.SqlBuilder;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.core.configuration.SnowflakeId;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.Feedback;
|
||||
import com.lanyuanxiaoyao.service.common.Constants;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class FeedbackService {
|
||||
public static final String FEEDBACK_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_feedback";
|
||||
private static final RowMapper<Feedback> feedbackMapper = (rs, row) -> {
|
||||
Feedback feedback = new Feedback();
|
||||
feedback.setId(rs.getLong(1));
|
||||
feedback.setSource(rs.getString(2));
|
||||
feedback.setAnalysisShort(rs.getString(3));
|
||||
feedback.setAnalysis(rs.getString(4));
|
||||
feedback.setPictureIds(
|
||||
StrUtil.isBlank(rs.getString(5))
|
||||
? Lists.immutable.empty()
|
||||
: Lists.immutable.ofAll(StrUtil.split(rs.getString(5), ","))
|
||||
);
|
||||
feedback.setStatus(EnumUtil.fromString(Feedback.Status.class, rs.getString(6)));
|
||||
feedback.setCreatedTime(rs.getTimestamp(7).getTime());
|
||||
feedback.setModifiedTime(rs.getTimestamp(8).getTime());
|
||||
return feedback;
|
||||
};
|
||||
private final JdbcTemplate template;
|
||||
|
||||
public FeedbackService(JdbcTemplate template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(String source, ImmutableList<Long> pictureIds) {
|
||||
template.update(
|
||||
SqlBuilder.insertInto(FEEDBACK_TABLE_NAME, "id", "source", "pictures")
|
||||
.values()
|
||||
.addValue("?", "?", "?")
|
||||
.precompileSql(),
|
||||
SnowflakeId.next(),
|
||||
source,
|
||||
ObjectUtil.isEmpty(pictureIds)
|
||||
? null
|
||||
: pictureIds.makeString(",")
|
||||
);
|
||||
}
|
||||
|
||||
public ImmutableList<Feedback> list() {
|
||||
return template.query(
|
||||
SqlBuilder.select("id", "source", "analysis_short", "analysis", "pictures", "status", "created_time", "modified_time")
|
||||
.from(FEEDBACK_TABLE_NAME)
|
||||
.orderByDesc("created_time")
|
||||
.build(),
|
||||
feedbackMapper
|
||||
)
|
||||
.stream()
|
||||
.collect(Collectors.toCollection(Lists.mutable::empty))
|
||||
.toImmutable();
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void remove(Long id) {
|
||||
template.update(
|
||||
SqlBuilder.delete(FEEDBACK_TABLE_NAME)
|
||||
.whereEq("id", id)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.service;
|
||||
package com.lanyuanxiaoyao.service.ai.web.service.knowledge;
|
||||
|
||||
import club.kingon.sql.builder.SqlBuilder;
|
||||
import club.kingon.sql.builder.entry.Alias;
|
||||
import club.kingon.sql.builder.entry.Column;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.Group;
|
||||
import com.lanyuanxiaoyao.service.ai.core.configuration.SnowflakeId;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.Group;
|
||||
import com.lanyuanxiaoyao.service.common.Constants;
|
||||
import io.qdrant.client.ConditionFactory;
|
||||
import io.qdrant.client.QdrantClient;
|
||||
@@ -13,8 +13,6 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
@@ -28,10 +26,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
public class GroupService {
|
||||
public static final String GROUP_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_group";
|
||||
private static final Logger logger = LoggerFactory.getLogger(GroupService.class);
|
||||
private static final RowMapper<Group> groupMapper = (rs, row) -> {
|
||||
Group vo = new Group();
|
||||
vo.setId(String.valueOf(rs.getLong(1)));
|
||||
vo.setId(rs.getLong(1));
|
||||
vo.setName(rs.getString(2));
|
||||
vo.setStatus(rs.getString(3));
|
||||
vo.setCreatedTime(rs.getTimestamp(4).getTime());
|
||||
@@ -60,7 +57,7 @@ public class GroupService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(Long knowledgeId, String name) {
|
||||
long id = IdUtil.getSnowflakeNextId();
|
||||
long id = SnowflakeId.next();
|
||||
template.update(
|
||||
SqlBuilder.insertInto(GROUP_TABLE_NAME, "id", "knowledge_id", "name", "status")
|
||||
.values()
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.service;
|
||||
package com.lanyuanxiaoyao.service.ai.web.service.knowledge;
|
||||
|
||||
import club.kingon.sql.builder.SqlBuilder;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.Knowledge;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.KnowledgeVO;
|
||||
import com.lanyuanxiaoyao.service.ai.core.configuration.SnowflakeId;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.Knowledge;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.vo.KnowledgeVO;
|
||||
import com.lanyuanxiaoyao.service.common.Constants;
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.grpc.Collections;
|
||||
@@ -15,9 +15,6 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.noear.solon.ai.reranking.RerankingModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.embedding.EmbeddingModel;
|
||||
import org.springframework.ai.vectorstore.SearchRequest;
|
||||
@@ -35,7 +32,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
public class KnowledgeBaseService {
|
||||
public static final String KNOWLEDGE_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_knowledge";
|
||||
private static final Logger logger = LoggerFactory.getLogger(KnowledgeBaseService.class);
|
||||
private static final RowMapper<Knowledge> knowledgeMapper = (rs, row) -> {
|
||||
Knowledge knowledge = new Knowledge();
|
||||
knowledge.setId(rs.getLong(1));
|
||||
@@ -50,14 +46,12 @@ public class KnowledgeBaseService {
|
||||
private final EmbeddingModel model;
|
||||
private final QdrantClient client;
|
||||
private final GroupService groupService;
|
||||
private final RerankingModel rerankingModel;
|
||||
|
||||
public KnowledgeBaseService(JdbcTemplate template, EmbeddingModel model, VectorStore vectorStore, GroupService groupService, RerankingModel rerankingModel) {
|
||||
public KnowledgeBaseService(JdbcTemplate template, EmbeddingModel model, VectorStore vectorStore, GroupService groupService) {
|
||||
this.template = template;
|
||||
this.model = model;
|
||||
this.client = (QdrantClient) vectorStore.getNativeClient().orElseThrow();
|
||||
this.groupService = groupService;
|
||||
this.rerankingModel = rerankingModel;
|
||||
}
|
||||
|
||||
public Knowledge get(Long id) {
|
||||
@@ -85,8 +79,8 @@ public class KnowledgeBaseService {
|
||||
throw new RuntimeException("名称已存在");
|
||||
}
|
||||
|
||||
long id = IdUtil.getSnowflakeNextId();
|
||||
long vectorSourceId = IdUtil.getSnowflakeNextId();
|
||||
long id = SnowflakeId.next();
|
||||
long vectorSourceId = SnowflakeId.next();
|
||||
template.update(
|
||||
SqlBuilder.insertInto(KNOWLEDGE_TABLE_NAME, "id", "vector_source_id", "name", "strategy")
|
||||
.values()
|
||||
@@ -130,8 +124,8 @@ public class KnowledgeBaseService {
|
||||
try {
|
||||
Collections.CollectionInfo info = client.getCollectionInfoAsync(String.valueOf(knowledge.getVectorSourceId())).get();
|
||||
KnowledgeVO vo = new KnowledgeVO();
|
||||
vo.setId(String.valueOf(knowledge.getId()));
|
||||
vo.setVectorSourceId(String.valueOf(knowledge.getVectorSourceId()));
|
||||
vo.setId(knowledge.getId());
|
||||
vo.setVectorSourceId(knowledge.getVectorSourceId());
|
||||
vo.setName(knowledge.getName());
|
||||
vo.setPoints(info.getPointsCount());
|
||||
vo.setSegments(info.getSegmentsCount());
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.service;
|
||||
package com.lanyuanxiaoyao.service.ai.web.service.knowledge;
|
||||
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.Knowledge;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.SegmentVO;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.Knowledge;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.vo.SegmentVO;
|
||||
import io.qdrant.client.ConditionFactory;
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.grpc.Points;
|
||||
@@ -10,8 +10,6 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -21,8 +19,6 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class SegmentService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SegmentService.class);
|
||||
|
||||
private final KnowledgeBaseService knowledgeBaseService;
|
||||
private final QdrantClient client;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge.service.node;
|
||||
package com.lanyuanxiaoyao.service.ai.web.service.node;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.knowledge.entity.EmbeddingContext;
|
||||
import com.lanyuanxiaoyao.service.ai.web.entity.context.EmbeddingContext;
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.annotation.LiteflowMethod;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
@@ -31,21 +32,21 @@ import org.springframework.ai.reader.tika.TikaDocumentReader;
|
||||
import org.springframework.ai.transformer.splitter.TokenTextSplitter;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.ai.vectorstore.qdrant.QdrantVectorStore;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.io.PathResource;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250523
|
||||
*/
|
||||
@Slf4j
|
||||
@LiteflowComponent
|
||||
public class EmbeddingNodes {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmbeddingNodes.class);
|
||||
|
||||
private final ChatClient chatClient;
|
||||
private final QdrantClient qdrantClient;
|
||||
private final EmbeddingModel embeddingModel;
|
||||
|
||||
public EmbeddingNodes(ChatClient.Builder builder, VectorStore vectorStore, EmbeddingModel embeddingModel) {
|
||||
public EmbeddingNodes(@Qualifier("chat") ChatClient.Builder builder, VectorStore vectorStore, EmbeddingModel embeddingModel) {
|
||||
this.chatClient = builder.build();
|
||||
this.qdrantClient = (QdrantClient) vectorStore.getNativeClient().orElseThrow();
|
||||
this.embeddingModel = embeddingModel;
|
||||
@@ -195,7 +196,6 @@ public class EmbeddingNodes {
|
||||
.call()
|
||||
.content();
|
||||
Assert.notBlank(response, "LLM response is empty");
|
||||
logger.info("LLM response: \n{}", response);
|
||||
// noinspection DataFlowIssue
|
||||
return Arrays.stream(StrUtil.trim(response).split("---"))
|
||||
.map(text -> text.replaceAll("(?!^.+) +$", ""))
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.lanyuanxiaoyao.service.ai.web.service.node;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
@LiteflowComponent
|
||||
public class FeedbackNodes {
|
||||
private final ChatClient.Builder chatClientBuilder;
|
||||
|
||||
public FeedbackNodes(@Qualifier("chat") ChatClient.Builder chatClientBuilder) {
|
||||
this.chatClientBuilder = chatClientBuilder;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat.tools;
|
||||
package com.lanyuanxiaoyao.service.ai.web.tools;
|
||||
|
||||
import com.lanyuanxiaoyao.service.ai.chat.AiChatApplication;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.lanyuanxiaoyao.service.ai.web.WebApplication;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.tool.annotation.Tool;
|
||||
import org.springframework.ai.tool.annotation.ToolParam;
|
||||
@@ -13,9 +12,8 @@ import org.springframework.ai.tool.annotation.ToolParam;
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250611
|
||||
*/
|
||||
@Slf4j
|
||||
public class ChartTool {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChartTool.class);
|
||||
|
||||
@Tool(description = """
|
||||
根据需求生成mermaid图表代码
|
||||
""")
|
||||
@@ -45,8 +43,8 @@ public class ChartTool {
|
||||
其他:箭头类型(实线/虚线)、注释文本等
|
||||
""") String request
|
||||
) {
|
||||
logger.info("Enter method: mermaid[request]. request:{}", request);
|
||||
ChatClient.Builder builder = AiChatApplication.getBean(ChatClient.Builder.class);
|
||||
log.info("Enter method: mermaid[request]. request:{}", request);
|
||||
ChatClient.Builder builder = WebApplication.getBean(ChatClient.Builder.class);
|
||||
ChatClient client = builder.build();
|
||||
return client.prompt()
|
||||
// language=TEXT
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat.tools;
|
||||
package com.lanyuanxiaoyao.service.ai.web.tools;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.AiChatApplication;
|
||||
import com.lanyuanxiaoyao.service.ai.web.WebApplication;
|
||||
import com.lanyuanxiaoyao.service.forest.service.KnowledgeService;
|
||||
import org.springframework.ai.tool.annotation.Tool;
|
||||
import org.springframework.ai.tool.annotation.ToolParam;
|
||||
@@ -27,7 +27,7 @@ public class KnowledgeTool {
|
||||
""")
|
||||
String query
|
||||
) {
|
||||
KnowledgeService knowledgeService = AiChatApplication.getBean(KnowledgeService.class);
|
||||
KnowledgeService knowledgeService = WebApplication.getBean(KnowledgeService.class);
|
||||
var documents = knowledgeService.query(knowledgeId, query, 10, 0.5);
|
||||
if (ObjectUtil.isNotEmpty(documents)) {
|
||||
return StrUtil.format("""
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat.tools;
|
||||
package com.lanyuanxiaoyao.service.ai.web.tools;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.AiChatApplication;
|
||||
import com.lanyuanxiaoyao.service.ai.web.WebApplication;
|
||||
import com.lanyuanxiaoyao.service.forest.service.InfoService;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.tool.annotation.Tool;
|
||||
import org.springframework.ai.tool.annotation.ToolParam;
|
||||
|
||||
@@ -15,8 +14,8 @@ import org.springframework.ai.tool.annotation.ToolParam;
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250605
|
||||
*/
|
||||
@Slf4j
|
||||
public class TableTool {
|
||||
private static final Logger logger = LoggerFactory.getLogger(TableTool.class);
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
@Tool(description = """
|
||||
@@ -27,12 +26,12 @@ public class TableTool {
|
||||
完整的MySQL查询语句,禁止使用除select外的任何语句。
|
||||
""") String sql
|
||||
) {
|
||||
logger.info("Enter method: executeJdbc[sql]. sql:{}", sql);
|
||||
InfoService infoService = AiChatApplication.getBean(InfoService.class);
|
||||
log.info("Enter method: executeJdbc[sql]. sql:{}", sql);
|
||||
InfoService infoService = WebApplication.getBean(InfoService.class);
|
||||
String result = infoService.jdbc(sql)
|
||||
.collect(map -> map.valuesView().makeString(","))
|
||||
.makeString("\n");
|
||||
logger.info("SQL result: \n{}", result);
|
||||
log.info("SQL result: \n{}", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -48,8 +47,8 @@ public class TableTool {
|
||||
一次调用只能传一个类型,不支持多个类型同时查询
|
||||
""") String type
|
||||
) {
|
||||
logger.info("Enter method: tableCount[type]. type:{}", type);
|
||||
var infoService = AiChatApplication.getBean(InfoService.class);
|
||||
log.info("Enter method: tableCount[type]. type:{}", type);
|
||||
var infoService = WebApplication.getBean(InfoService.class);
|
||||
return switch (type) {
|
||||
case "logic" -> StrUtil.format("""
|
||||
逻辑表共{}张,其中重点表{}张
|
||||
@@ -83,8 +82,8 @@ public class TableTool {
|
||||
""")
|
||||
String type
|
||||
) {
|
||||
logger.info("Enter method: version[date, type]. date:{},type:{}", date, type);
|
||||
InfoService infoService = AiChatApplication.getBean(InfoService.class);
|
||||
log.info("Enter method: version[date, type]. date:{},type:{}", date, type);
|
||||
InfoService infoService = WebApplication.getBean(InfoService.class);
|
||||
String version = date;
|
||||
if (StrUtil.isBlank(version)) {
|
||||
version = LocalDateTime.now().minusDays(1).format(FORMATTER);
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.lanyuanxiaoyao.service.ai.chat.tools;
|
||||
package com.lanyuanxiaoyao.service.ai.web.tools;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lanyuanxiaoyao.service.ai.chat.AiChatApplication;
|
||||
import com.lanyuanxiaoyao.service.ai.web.WebApplication;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnApplication;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnQueue;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnRootQueue;
|
||||
import com.lanyuanxiaoyao.service.forest.service.YarnService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.tool.annotation.Tool;
|
||||
import org.springframework.ai.tool.annotation.ToolParam;
|
||||
|
||||
@@ -16,9 +15,8 @@ import org.springframework.ai.tool.annotation.ToolParam;
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250606
|
||||
*/
|
||||
@Slf4j
|
||||
public class YarnTool {
|
||||
private static final Logger logger = LoggerFactory.getLogger(YarnTool.class);
|
||||
|
||||
@Tool(description = """
|
||||
查询yarn集群整体资源情况,返回值为资源占用率(%)
|
||||
""")
|
||||
@@ -28,8 +26,8 @@ public class YarnTool {
|
||||
一次调用只能查询一个集群,不支持多个集群同时查询
|
||||
""") String cluster
|
||||
) {
|
||||
logger.info("Enter method: yarnStatus[cluster]. cluster:{}", cluster);
|
||||
YarnService yarnService = AiChatApplication.getBean(YarnService.class);
|
||||
log.info("Enter method: yarnStatus[cluster]. cluster:{}", cluster);
|
||||
YarnService yarnService = WebApplication.getBean(YarnService.class);
|
||||
YarnRootQueue status = yarnService.cluster(cluster);
|
||||
return (status.getUsedCapacity() * 100.0) / status.getCapacity();
|
||||
}
|
||||
@@ -46,8 +44,8 @@ public class YarnTool {
|
||||
yarn队列名称
|
||||
""") String queue
|
||||
) {
|
||||
logger.info("Enter method: yarnQueueStatus[cluster, queue]. cluster:{},queue:{}", cluster, queue);
|
||||
YarnService yarnService = AiChatApplication.getBean(YarnService.class);
|
||||
log.info("Enter method: yarnQueueStatus[cluster, queue]. cluster:{},queue:{}", cluster, queue);
|
||||
YarnService yarnService = WebApplication.getBean(YarnService.class);
|
||||
YarnQueue status = yarnService.queueDetail(cluster, queue);
|
||||
return (status.getAbsoluteCapacity() * 100.0) / status.getAbsoluteMaxCapacity();
|
||||
}
|
||||
@@ -67,8 +65,8 @@ public class YarnTool {
|
||||
一次调用只能传一个类型,不支持多个类型同时查询
|
||||
""") String type
|
||||
) {
|
||||
logger.info("Enter method: yarnTaskStatus[cluster, type]. cluster:{},type:{}", cluster, type);
|
||||
YarnService yarnService = AiChatApplication.getBean(YarnService.class);
|
||||
log.info("Enter method: yarnTaskStatus[cluster, type]. cluster:{},type:{}", cluster, type);
|
||||
YarnService yarnService = WebApplication.getBean(YarnService.class);
|
||||
ImmutableList<YarnApplication> applications = yarnService.jobList(cluster).select(app -> StrUtil.isNotBlank(type) && StrUtil.contains(app.getName(), type));
|
||||
return StrUtil.format(
|
||||
"""
|
||||
@@ -0,0 +1,20 @@
|
||||
spring:
|
||||
profiles:
|
||||
include: random-port,common,discovery,metrics,forest
|
||||
ai:
|
||||
vectorstore:
|
||||
qdrant:
|
||||
host: 132.121.206.65
|
||||
port: 29463
|
||||
api-key: ENC(0/0UkIKeAvyV17yNqSU3v04wmm8CdWKe4BYSSJa2FuBtK12TcZRJPdwk+ZpYnpISv+KmVTUrrmFBzAYrDR3ysA==)
|
||||
llm:
|
||||
base-url: http://132.121.206.65:10086
|
||||
api-key: ENC(K+Hff9QGC+fcyi510VIDd9CaeK/IN5WBJ9rlkUsHEdDgIidW+stHHJlsK0lLPUXXREha+ToQZqqDXJrqSE+GUKCXklFhelD8bRHFXBIeP/ZzT2cxhzgKUXgjw3S0Qw2R)
|
||||
chat:
|
||||
model: 'Qwen3/qwen3-1.7b'
|
||||
visual:
|
||||
model: 'Qwen2.5/qwen2.5-vl-7b'
|
||||
embedding:
|
||||
model: 'Qwen3/qwen3-embedding-4b'
|
||||
reranker:
|
||||
model: 'Bge-reranker-v2'
|
||||
@@ -0,0 +1,39 @@
|
||||
server:
|
||||
port: 8080
|
||||
spring:
|
||||
ai:
|
||||
vectorstore:
|
||||
qdrant:
|
||||
host: 192.168.100.140
|
||||
port: 6334
|
||||
llm:
|
||||
base-url: https://api.siliconflow.cn
|
||||
api-key: sk-xrguybusoqndpqvgzgvllddzgjamksuecyqdaygdwnrnqfwo
|
||||
chat:
|
||||
model: 'Qwen/Qwen3-8B'
|
||||
visual:
|
||||
base-url: https://open.bigmodel.cn/api/paas/v4
|
||||
endpoint: /chat/completions
|
||||
model: 'glm-4v-flash'
|
||||
embedding:
|
||||
model: 'BAAI/bge-m3'
|
||||
reranker:
|
||||
model: 'BAAI/bge-reranker-v2-m3'
|
||||
cloud:
|
||||
discovery:
|
||||
enabled: false
|
||||
zookeeper:
|
||||
enabled: false
|
||||
datasource:
|
||||
url: jdbc:mysql://192.168.100.140:3306/hudi_collect_build_b12?useSSL=false&allowPublicKeyRetrieval=true
|
||||
username: test
|
||||
password: test
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
security:
|
||||
meta:
|
||||
authority: ENC(GXKnbq1LS11U2HaONspvH+D/TkIx13aWTaokdkzaF7HSvq6Z0Rv1+JUWFnYopVXu)
|
||||
username: ENC(moIO5mO39V1Z+RDwROK9JXY4GfM8ZjDgM6Si7wRZ1MPVjbhTpmLz3lz28rAiw7c2LeCmizfJzHkEXIwGlB280g==)
|
||||
darkcode: ENC(0jzpQ7T6S+P7bZrENgYsUoLhlqGvw7DA2MN3BRqEOwq7plhtg72vuuiPQNnr3DaYz0CpyTvxInhpx11W3VZ1trD6NINh7O3LN70ZqO5pWXk=)
|
||||
jasypt:
|
||||
encryptor:
|
||||
password: 'r#(R,P"Dp^A47>WSn:Wn].gs/+"v:q_Q*An~zF*g-@j@jtSTv5H/,S-3:R?r9R}.'
|
||||
19
service-ai/service-ai-web/src/main/resources/application.yml
Normal file
19
service-ai/service-ai-web/src/main/resources/application.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
application:
|
||||
name: service-ai-web
|
||||
mvc:
|
||||
async:
|
||||
request-timeout: 3600000
|
||||
autoconfigure:
|
||||
exclude: |
|
||||
org.springframework.ai.model.openai.autoconfigure.OpenAiChatAutoConfiguration,
|
||||
org.springframework.ai.model.openai.autoconfigure.OpenAiAudioSpeechAutoConfiguration,
|
||||
org.springframework.ai.model.openai.autoconfigure.OpenAiAudioTranscriptionAutoConfiguration,
|
||||
org.springframework.ai.model.openai.autoconfigure.OpenAiImageAutoConfiguration,
|
||||
org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration,
|
||||
org.springframework.ai.model.openai.autoconfigure.OpenAiModerationAutoConfiguration,
|
||||
org.springframework.ai.model.deepseek.autoconfigure.DeepSeekChatAutoConfiguration
|
||||
liteflow:
|
||||
rule-source: liteflow.xml
|
||||
print-banner: false
|
||||
check-node-exists: false
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge;
|
||||
package com.lanyuanxiaoyao.service.ai.web;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge;
|
||||
package com.lanyuanxiaoyao.service.ai.web;
|
||||
|
||||
import java.net.http.HttpClient;
|
||||
import org.slf4j.Logger;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.lanyuanxiaoyao.service.ai.knowledge;
|
||||
package com.lanyuanxiaoyao.service.ai.web;
|
||||
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
@@ -176,8 +176,9 @@ deploy:
|
||||
jdk: "jdk17"
|
||||
replicas: 1
|
||||
arguments:
|
||||
"[knowledge.download-prefix]": 'http://132.126.207.130:35690/hudi_services/ai_knowledge'
|
||||
"[knowledge.upload-path]": ${deploy.runtime.data-path}/knowledge
|
||||
"[spring.profiles.active]": 'build'
|
||||
"[file-store.download-prefix]": 'http://132.126.207.130:35690/hudi_services/ai_knowledge'
|
||||
"[file-store.upload-path]": ${deploy.runtime.data-path}/knowledge
|
||||
"[spring.datasource.url]": ${deploy.runtime.database.config.url}
|
||||
"[spring.datasource.username]": ${deploy.runtime.database.config.username}
|
||||
"[spring.datasource.password]": ${deploy.runtime.database.config.password}
|
||||
|
||||
@@ -51,8 +51,7 @@ public class GatewayApplication {
|
||||
.route("web", createRoute("/hudi_services/service_web", "lb://service-web"))
|
||||
.route("services", createRoute("/hudi_services/service_cloud_query", "lb://service-cloud-query"))
|
||||
.route("exporter", createRoute("/hudi_services/service_exporter", "lb://service-exporter"))
|
||||
.route("ai-chat", createRoute("/hudi_services/ai_chat", "lb://service-ai-chat"))
|
||||
.route("ai-knowledge", createRoute("/hudi_services/ai_knowledge", "lb://service-ai-knowledge"))
|
||||
.route("ai-web", createRoute("/hudi_services/service_ai_web", "lb://service-ai-web"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import {ClearOutlined, FileOutlined, UserOutlined} from '@ant-design/icons'
|
||||
import {ClearOutlined, UserOutlined} from '@ant-design/icons'
|
||||
import {Bubble, Sender, useXAgent, useXChat, Welcome} from '@ant-design/x'
|
||||
import {fetchEventSource} from '@echofly/fetch-event-source'
|
||||
import {useMount} from 'ahooks'
|
||||
import {Button, Collapse, Flex, Popover, Radio, Typography} from 'antd'
|
||||
import {isEqual, isStrBlank, trim} from 'licia'
|
||||
import {Button, Collapse, Flex, Typography} from 'antd'
|
||||
import {isStrBlank, trim} from 'licia'
|
||||
import {useRef, useState} from 'react'
|
||||
import styled from 'styled-components'
|
||||
import {commonInfo} from '../../util/amis.tsx'
|
||||
@@ -40,24 +39,10 @@ type ChatMessage = { role: string, content?: string, reason?: string }
|
||||
function Conversation() {
|
||||
const abortController = useRef<AbortController | null>(null)
|
||||
const [input, setInput] = useState<string>('')
|
||||
const [knowledge, setKnowledge] = useState<string>('0')
|
||||
const [knowledgeList, setKnowledgeList] = useState<{ id: string, name: string }[]>([])
|
||||
|
||||
useMount(async () => {
|
||||
let response = await fetch(`${commonInfo.baseAiKnowledgeUrl}/knowledge/list`, {
|
||||
headers: commonInfo.authorizationHeaders,
|
||||
})
|
||||
let items = (await response.json()).data.items
|
||||
setKnowledgeList(items.map((item: { id: string, name: string }) => ({id: item.id, name: item.name})))
|
||||
})
|
||||
|
||||
const [agent] = useXAgent<ChatMessage>({
|
||||
request: async (info, callbacks) => {
|
||||
let requestUrl = `${commonInfo.baseAiChatUrl}/chat/async`
|
||||
if (!isEqual('0', info.knowledge)) {
|
||||
requestUrl = `${requestUrl}?knowledge_id=${info.knowledge}`
|
||||
}
|
||||
await fetchEventSource(requestUrl, {
|
||||
await fetchEventSource(`${commonInfo.baseAiUrl}/chat/async`, {
|
||||
method: 'POST',
|
||||
headers: commonInfo.authorizationHeaders,
|
||||
body: JSON.stringify(info.messages),
|
||||
@@ -180,7 +165,6 @@ function Conversation() {
|
||||
content: message,
|
||||
},
|
||||
stream: true,
|
||||
knowledge: knowledge,
|
||||
})
|
||||
setInput('')
|
||||
}}
|
||||
@@ -190,32 +174,6 @@ function Conversation() {
|
||||
return (
|
||||
<Flex justify="space-between" align="center">
|
||||
<Flex gap="small" align="center">
|
||||
<Popover
|
||||
title="选择知识库"
|
||||
trigger="hover"
|
||||
content={<Radio.Group
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 10,
|
||||
}}
|
||||
disabled={agent.isRequesting()}
|
||||
value={knowledge}
|
||||
onChange={event => setKnowledge(event.target.value)}
|
||||
options={[
|
||||
{value: '0', label: '无'},
|
||||
...knowledgeList.map(k => ({label: k.name, value: k.id})),
|
||||
]}
|
||||
/>}
|
||||
>
|
||||
<Button
|
||||
icon={<FileOutlined/>}
|
||||
type="text"
|
||||
size="small"
|
||||
>
|
||||
知识库
|
||||
</Button>
|
||||
</Popover>
|
||||
<Button
|
||||
icon={<ClearOutlined/>}
|
||||
type="text"
|
||||
|
||||
108
service-web/client/src/pages/ai/feedback/Feedback.tsx
Normal file
108
service-web/client/src/pages/ai/feedback/Feedback.tsx
Normal file
@@ -0,0 +1,108 @@
|
||||
import React from 'react'
|
||||
import {amisRender, commonInfo, crudCommonOptions} from '../../../util/amis.tsx'
|
||||
|
||||
const Feedback: React.FC = () => {
|
||||
return (
|
||||
<div className="feedback">
|
||||
{amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
title: '报障清单',
|
||||
body: [
|
||||
{
|
||||
type: 'crud',
|
||||
api: `${commonInfo.baseAiUrl}/feedback/list`,
|
||||
...crudCommonOptions(),
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
{
|
||||
type: 'action',
|
||||
label: '',
|
||||
icon: 'fa fa-plus',
|
||||
tooltip: '新增',
|
||||
tooltipPlacement: 'top',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '新增报账单',
|
||||
size: 'md',
|
||||
body: {
|
||||
debug: commonInfo.debug,
|
||||
type: 'form',
|
||||
api: {
|
||||
url: `${commonInfo.baseAiUrl}/feedback/add`,
|
||||
dataType: 'form',
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'editor',
|
||||
required: true,
|
||||
label: '故障描述',
|
||||
name: 'source',
|
||||
language: 'plaintext',
|
||||
options: {
|
||||
lineNumbers: 'off',
|
||||
wordWrap: 'bounded',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'input-image',
|
||||
name: 'pictures',
|
||||
label: '相关截图',
|
||||
autoUpload: false,
|
||||
multiple: true,
|
||||
// 5MB 5242880
|
||||
// 100MB 104857600
|
||||
// 500MB 524288000
|
||||
// 1GB 1073741824
|
||||
maxSize: 5242880,
|
||||
receiver: `${commonInfo.baseAiUrl}/upload`
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'id',
|
||||
label: '编号',
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
label: '状态',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
type: 'operation',
|
||||
label: '操作',
|
||||
width: 150,
|
||||
buttons: [
|
||||
{
|
||||
type: 'action',
|
||||
label: '删除',
|
||||
className: 'text-danger hover:text-red-600',
|
||||
level: 'link',
|
||||
size: 'sm',
|
||||
actionType: 'ajax',
|
||||
api: {
|
||||
method: 'get',
|
||||
url: `${commonInfo.baseAiUrl}/feedback/delete`,
|
||||
data: {
|
||||
id: '${id}',
|
||||
},
|
||||
},
|
||||
confirmText: '确认删除',
|
||||
confirmTitle: '删除',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Feedback
|
||||
@@ -24,7 +24,7 @@ const DataDetail: React.FC = () => {
|
||||
{
|
||||
type: 'service',
|
||||
className: 'inline',
|
||||
api: `${commonInfo.baseAiKnowledgeUrl}/knowledge/name?id=${knowledge_id}`,
|
||||
api: `${commonInfo.baseAiUrl}/knowledge/name?id=${knowledge_id}`,
|
||||
body: {
|
||||
type: 'tpl',
|
||||
tpl: '${name}',
|
||||
@@ -38,7 +38,7 @@ const DataDetail: React.FC = () => {
|
||||
body: [
|
||||
{
|
||||
type: 'crud',
|
||||
api: `${commonInfo.baseAiKnowledgeUrl}/group/list?knowledge_id=${knowledge_id}`,
|
||||
api: `${commonInfo.baseAiUrl}/knowledge/group/list?knowledge_id=${knowledge_id}`,
|
||||
...crudCommonOptions(),
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
@@ -146,7 +146,7 @@ const DataDetail: React.FC = () => {
|
||||
level: 'link',
|
||||
size: 'sm',
|
||||
actionType: 'ajax',
|
||||
api: `get:${commonInfo.baseAiKnowledgeUrl}/group/delete?id=\${id}`,
|
||||
api: `get:${commonInfo.baseAiUrl}/knowledge/group/delete?id=\${id}`,
|
||||
confirmText: '确认删除',
|
||||
confirmTitle: '删除',
|
||||
},
|
||||
|
||||
@@ -23,7 +23,7 @@ const DataImport: React.FC = () => {
|
||||
{
|
||||
type: 'service',
|
||||
className: 'inline',
|
||||
api: `${commonInfo.baseAiKnowledgeUrl}/knowledge/name?id=${knowledge_id}`,
|
||||
api: `${commonInfo.baseAiUrl}/knowledge/name?id=${knowledge_id}`,
|
||||
body: {
|
||||
type: 'tpl',
|
||||
tpl: '${name}',
|
||||
@@ -109,7 +109,7 @@ const DataImport: React.FC = () => {
|
||||
// 500MB 524288000
|
||||
// 1GB 1073741824
|
||||
maxSize: 104857600,
|
||||
receiver: `${commonInfo.baseAiKnowledgeUrl}/upload`
|
||||
receiver: `${commonInfo.baseAiUrl}/upload`
|
||||
// useChunk: true,
|
||||
// startChunkApi: `post:${commonInfo.baseAiKnowledgeUrl}/upload/start`,
|
||||
// chunkApi: `post:${commonInfo.baseAiKnowledgeUrl}/upload/slice`,
|
||||
@@ -130,7 +130,7 @@ const DataImport: React.FC = () => {
|
||||
level: 'secondary',
|
||||
api: {
|
||||
method: 'post',
|
||||
url: `${commonInfo.baseAiKnowledgeUrl}/knowledge/preview_text`,
|
||||
url: `${commonInfo.baseAiUrl}/knowledge/preview_text`,
|
||||
dataType: 'form',
|
||||
data: {
|
||||
mode: '${mode|default:undefined}',
|
||||
@@ -148,7 +148,7 @@ const DataImport: React.FC = () => {
|
||||
actionType: 'ajax',
|
||||
api: {
|
||||
method: 'post',
|
||||
url: `${commonInfo.baseAiKnowledgeUrl}/knowledge/submit_text`,
|
||||
url: `${commonInfo.baseAiUrl}/knowledge/submit_text`,
|
||||
dataType: 'form',
|
||||
data: {
|
||||
id: knowledge_id,
|
||||
|
||||
@@ -18,7 +18,7 @@ const DataDetail: React.FC = () => {
|
||||
{
|
||||
type: 'service',
|
||||
className: 'inline',
|
||||
api: `${commonInfo.baseAiKnowledgeUrl}/knowledge/name?id=${knowledge_id}`,
|
||||
api: `${commonInfo.baseAiUrl}/knowledge/name?id=${knowledge_id}`,
|
||||
body: {
|
||||
type: 'tpl',
|
||||
tpl: '${name}',
|
||||
@@ -32,7 +32,7 @@ const DataDetail: React.FC = () => {
|
||||
body: [
|
||||
{
|
||||
type: 'crud',
|
||||
api: `${commonInfo.baseAiKnowledgeUrl}/segment/list?knowledge_id=${knowledge_id}&group_id=${group_id}`,
|
||||
api: `${commonInfo.baseAiUrl}/knowledge/segment/list?knowledge_id=${knowledge_id}&group_id=${group_id}`,
|
||||
...crudCommonOptions(),
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
|
||||
@@ -25,7 +25,7 @@ const Knowledge: React.FC = () => {
|
||||
body: [
|
||||
{
|
||||
type: 'crud',
|
||||
api: `${commonInfo.baseAiKnowledgeUrl}/knowledge/list`,
|
||||
api: `${commonInfo.baseAiUrl}/knowledge/list`,
|
||||
...crudCommonOptions(),
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
@@ -42,7 +42,7 @@ const Knowledge: React.FC = () => {
|
||||
body: {
|
||||
type: 'form',
|
||||
api: {
|
||||
url: `${commonInfo.baseAiKnowledgeUrl}/knowledge/add`,
|
||||
url: `${commonInfo.baseAiUrl}/knowledge/add`,
|
||||
dataType: 'form',
|
||||
},
|
||||
body: [
|
||||
@@ -148,7 +148,7 @@ const Knowledge: React.FC = () => {
|
||||
actionType: 'ajax',
|
||||
api: {
|
||||
method: 'get',
|
||||
url: `${commonInfo.baseAiKnowledgeUrl}/knowledge/delete`,
|
||||
url: `${commonInfo.baseAiUrl}/knowledge/delete`,
|
||||
headers: {
|
||||
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
|
||||
},
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import {
|
||||
CheckSquareOutlined,
|
||||
CloudOutlined,
|
||||
ClusterOutlined,
|
||||
CompressOutlined,
|
||||
DatabaseOutlined,
|
||||
InfoCircleOutlined,
|
||||
OpenAIOutlined,
|
||||
QuestionOutlined,
|
||||
SunOutlined,
|
||||
SyncOutlined,
|
||||
TableOutlined,
|
||||
ToolOutlined,
|
||||
CheckSquareOutlined,
|
||||
CloudOutlined,
|
||||
ClusterOutlined,
|
||||
CompressOutlined,
|
||||
DatabaseOutlined,
|
||||
InfoCircleOutlined,
|
||||
OpenAIOutlined,
|
||||
QuestionOutlined,
|
||||
SunOutlined,
|
||||
SyncOutlined,
|
||||
TableOutlined,
|
||||
ToolOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import {Navigate, type RouteObject} from 'react-router'
|
||||
import Conversation from './pages/ai/Conversation.tsx'
|
||||
import Inspection from './pages/ai/Inspection.tsx'
|
||||
import DataDetail from './pages/ai/knowledge/DataDetail.tsx'
|
||||
import DataImport from './pages/ai/knowledge/DataImport.tsx'
|
||||
import DataSegment from './pages/ai/knowledge/DataSegment.tsx'
|
||||
@@ -31,6 +30,7 @@ import Yarn from './pages/overview/Yarn.tsx'
|
||||
import YarnCluster from './pages/overview/YarnCluster.tsx'
|
||||
import {commonInfo} from './util/amis.tsx'
|
||||
import Test from './pages/Test.tsx'
|
||||
import Feedback from './pages/ai/feedback/Feedback.tsx'
|
||||
|
||||
export const routes: RouteObject[] = [
|
||||
{
|
||||
@@ -84,14 +84,14 @@ export const routes: RouteObject[] = [
|
||||
index: true,
|
||||
element: <Navigate to="/ai/conversation" replace/>,
|
||||
},
|
||||
{
|
||||
path: 'inspection',
|
||||
Component: Inspection,
|
||||
},
|
||||
{
|
||||
path: 'conversation',
|
||||
Component: Conversation,
|
||||
},
|
||||
{
|
||||
path: 'feedback',
|
||||
Component: Feedback,
|
||||
},
|
||||
{
|
||||
path: 'knowledge',
|
||||
Component: Knowledge,
|
||||
@@ -201,8 +201,8 @@ export const menus = {
|
||||
icon: <QuestionOutlined/>,
|
||||
},
|
||||
{
|
||||
path: '/ai/inspection',
|
||||
name: '智能巡检',
|
||||
path: '/ai/feedback',
|
||||
name: '智慧报账',
|
||||
icon: <CheckSquareOutlined/>,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,9 +10,8 @@ import {isEqual} from 'licia'
|
||||
export const commonInfo = {
|
||||
debug: isEqual(import.meta.env.MODE, 'development'),
|
||||
baseUrl: 'http://132.126.207.130:35690/hudi_services/service_web',
|
||||
baseAiChatUrl: 'http://132.126.207.130:35690/hudi_services/ai_chat',
|
||||
baseAiKnowledgeUrl: 'http://132.126.207.130:35690/hudi_services/ai_knowledge',
|
||||
// baseUrl: '/hudi_services/service_web',
|
||||
// baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web',
|
||||
baseAiUrl: 'http://localhost:8080',
|
||||
authorizationHeaders: {
|
||||
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user