26 Commits

Author SHA1 Message Date
df6f1eb548 feat(web): 增加编辑侧边栏关闭时保存节点数据 2025-06-23 20:15:32 +08:00
73e6ff3c54 feat(web): 优化编辑界面 2025-06-21 10:31:11 +08:00
v-zhangjc9
ec37d04ae5 feat(web): 替换amis渲染,amis渲染太慢,导致卡顿 2025-06-21 00:08:38 +08:00
v-zhangjc9
172ef4c099 feat(web): 增加流程定义基本能力 2025-06-20 18:15:49 +08:00
v-zhangjc9
306c20aa7f fix(web): 修复删除按钮hover不是红色 2025-06-19 11:31:07 +08:00
v-zhangjc9
24d5d10ecb fix(web): 优化字号 2025-06-19 11:14:59 +08:00
v-zhangjc9
4a9a9ec238 fix(ai-web): 优化qa嵌入提示词 2025-06-19 11:10:14 +08:00
v-zhangjc9
08aa1d8382 fix(ai-web): 修复chartjs工具获取bean错误 2025-06-19 11:09:52 +08:00
v-zhangjc9
1b3045dfd4 feat(web): 统一字体展示 2025-06-19 11:09:05 +08:00
v-zhangjc9
0f5ae1c4d4 fix(ai-web): 修复超时时间设置过短导致反复重连 2025-06-18 16:09:37 +08:00
v-zhangjc9
48e42ee99a fix(ai-web): 升级部份依赖版本 2025-06-18 14:53:45 +08:00
v-zhangjc9
0914b458d3 fix(ai-web): 修复页面失去焦点的时候没有断开对话的连接 2025-06-18 10:34:56 +08:00
v-zhangjc9
368c30676e feat(ai-web): 尝试优化对话连接的稳定性 2025-06-18 10:33:44 +08:00
v-zhangjc9
60477f99f5 fix(ai-web): 修复错别字 2025-06-17 17:43:18 +08:00
v-zhangjc9
565c530dd5 feat(ai-web): 知识库增加描述 2025-06-17 17:19:04 +08:00
v-zhangjc9
5130885033 fix(ai-web): 改正包名 2025-06-17 16:18:38 +08:00
v-zhangjc9
8e6463845b feat(ai-web): 开启gzip 2025-06-17 16:16:01 +08:00
v-zhangjc9
e89bffe289 feat(ai-web): 增加Feedback详情展示和处理情况确认 2025-06-17 16:15:42 +08:00
v-zhangjc9
1dd00d329c refactor(ai-web): 优化流程编排 2025-06-17 10:35:39 +08:00
e470a87372 feat(web): 修复yarn页面查看资源队列错误 2025-06-16 23:51:36 +08:00
v-zhangjc9
45da452f18 fix(ai-web): 完成feedback AI流程 2025-06-16 20:37:14 +08:00
v-zhangjc9
e6a1bc5383 fix(ai-web): 修复取值错误 2025-06-16 17:13:16 +08:00
v-zhangjc9
c5916703cd fix(web): 修复base url错误 2025-06-16 16:12:39 +08:00
v-zhangjc9
807ddbe5cb feat(ai-web): 完成图片上传和显示 2025-06-16 13:38:42 +08:00
v-zhangjc9
13de694e37 fix(all): 修复配置错误 2025-06-16 12:13:42 +08:00
v-zhangjc9
1962dd586c feat(ai-web): 增加辅助插件 2025-06-16 11:07:56 +08:00
46 changed files with 1884 additions and 2065 deletions

View File

@@ -1,11 +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
`id` bigint NOT NULL,
`source` longtext NOT NULL,
`conclusion` 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;

View File

@@ -3,6 +3,7 @@ CREATE TABLE `service_ai_knowledge`
`id` bigint NOT NULL,
`vector_source_id` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`description` longtext NOT NULL,
`strategy` varchar(10) NOT NULL,
`created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

View File

@@ -29,12 +29,18 @@
<eclipse-collections.version>11.1.0</eclipse-collections.version>
<curator.version>5.1.0</curator.version>
<hutool.version>5.8.27</hutool.version>
<mapstruct.version>1.6.3</mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
@@ -154,12 +160,22 @@
<artifactId>solon-ai-dialect-openai</artifactId>
<version>${solon-ai.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
@@ -168,7 +184,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>

View File

@@ -70,6 +70,32 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amapstruct.defaultComponentModel=spring</arg>
<arg>-Amapstruct.defaultInjectionStrategy=constructor</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>

View File

@@ -34,6 +34,10 @@ public class WebApplication implements ApplicationRunner, ApplicationContextAwar
return context.getBean(clazz);
}
public static <T> T getBean(String name, Class<T> clazz) {
return context.getBean(name, clazz);
}
@Override
public void run(ApplicationArguments args) {
}

View File

@@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "file-store")
public class FileStoreConfiguration {
public class FileStoreProperties {
private String downloadPrefix;
private String uploadPath;
}

View File

@@ -63,7 +63,7 @@ public class LlmConfiguration {
.openAiApi(apiBuilder.build())
.defaultOptions(
OpenAiChatOptions.builder()
.model(llmProperties.getChat().getModel())
.model(llmProperties.getVisual().getModel())
.build()
)
.build()

View File

@@ -7,7 +7,7 @@ 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.web.configuration.FileStoreConfiguration;
import com.lanyuanxiaoyao.service.ai.web.configuration.FileStoreProperties;
import com.lanyuanxiaoyao.service.ai.web.entity.vo.DataFileVO;
import com.lanyuanxiaoyao.service.ai.web.service.DataFileService;
import jakarta.servlet.http.HttpServletResponse;
@@ -41,17 +41,17 @@ import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/upload")
public class DataFileController {
private final FileStoreConfiguration fileStoreConfiguration;
private final FileStoreProperties fileStoreProperties;
private final DataFileService dataFileService;
private final String uploadFolderPath;
private final String cacheFolderPath;
private final String sliceFolderPath;
public DataFileController(FileStoreConfiguration fileStoreConfiguration, DataFileService dataFileService) {
this.fileStoreConfiguration = fileStoreConfiguration;
public DataFileController(FileStoreProperties fileStoreProperties, DataFileService dataFileService) {
this.fileStoreProperties = fileStoreProperties;
this.dataFileService = dataFileService;
this.uploadFolderPath = fileStoreConfiguration.getUploadPath();
this.uploadFolderPath = fileStoreProperties.getUploadPath();
this.cacheFolderPath = StrUtil.format("{}/cache", uploadFolderPath);
this.sliceFolderPath = StrUtil.format("{}/slice", uploadFolderPath);
}
@@ -60,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/{}", fileStoreConfiguration.getDownloadPrefix(), id);
String url = StrUtil.format("{}/upload/download/{}", fileStoreProperties.getDownloadPrefix(), id);
byte[] bytes = file.getBytes();
String originMd5 = SecureUtil.md5(new ByteArrayInputStream(bytes));
File targetFile = new File(StrUtil.format("{}/{}", uploadFolderPath, originMd5));
@@ -80,7 +80,7 @@ public class DataFileController {
}
@GetMapping("/download/{id}")
public void download(@PathVariable Long id, HttpServletResponse response) throws IOException {
public void download(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
DataFileVO dataFile = dataFileService.downloadFile(id);
File targetFile = new File(dataFile.getPath());
response.setHeader("Content-Type", dataFile.getType());
@@ -157,7 +157,7 @@ public class DataFileController {
request.uploadId,
request.filename,
request.uploadId.toString(),
StrUtil.format("{}/upload/download/{}", fileStoreConfiguration.getDownloadPrefix(), request.uploadId)
StrUtil.format("{}/upload/download/{}", fileStoreProperties.getDownloadPrefix(), request.uploadId)
));
} else {
throw new RuntimeException("合并文件失败");

View File

@@ -1,4 +1,4 @@
package com.lanyuanxiaoyao.service.ai.web.controller.caht;
package com.lanyuanxiaoyao.service.ai.web.controller.chat;
import cn.hutool.core.util.StrUtil;
import com.lanyuanxiaoyao.service.ai.web.configuration.Prompts;
@@ -6,10 +6,13 @@ 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 com.lanyuanxiaoyao.service.configuration.ExecutorProvider;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.concurrent.TimeoutException;
import org.eclipse.collections.api.list.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -98,24 +101,34 @@ public class ChatController {
@PostMapping("async")
public SseEmitter chatAsync(
@RequestBody ImmutableList<MessageVO> messages
@RequestBody ImmutableList<MessageVO> messages,
HttpServletResponse httpResponse
) {
SseEmitter emitter = new SseEmitter();
buildRequest(messages)
.stream()
.chatResponse()
.subscribe(
response -> {
try {
emitter.send(toMessage(response));
} catch (IOException e) {
emitter.completeWithError(e);
throw new RuntimeException(e);
}
},
emitter::completeWithError,
emitter::complete
);
httpResponse.setHeader("X-Accel-Buffering", "no");
SseEmitter emitter = new SseEmitter(20 * 60 * 1000L);
ExecutorProvider.EXECUTORS.submit(() -> {
buildRequest(messages)
.stream()
.chatResponse()
.subscribe(
response -> {
try {
emitter.send(
SseEmitter.event()
.data(toMessage(response))
.reconnectTime(5 * 1000L)
.build()
);
} catch (IOException e) {
emitter.completeWithError(e);
}
},
emitter::completeWithError,
emitter::complete
);
});
emitter.onTimeout(() -> emitter.completeWithError(new TimeoutException("SseEmitter Timeout")));
return emitter;
}

View File

@@ -1,13 +1,19 @@
package com.lanyuanxiaoyao.service.ai.web.controller.feedback;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisCrudResponse;
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
import com.lanyuanxiaoyao.service.ai.web.configuration.FileStoreProperties;
import com.lanyuanxiaoyao.service.ai.web.entity.Feedback;
import com.lanyuanxiaoyao.service.ai.web.service.feedback.FeedbackService;
import lombok.Data;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -16,27 +22,68 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("feedback")
public class FeedbackController {
private final FileStoreProperties fileStoreProperties;
private final FeedbackService feedbackService;
public FeedbackController(FeedbackService feedbackService) {
public FeedbackController(FileStoreProperties fileStoreProperties, FeedbackService feedbackService) {
this.fileStoreProperties = fileStoreProperties;
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()));
public void add(@RequestBody CreateItem item) {
feedbackService.add(item.source, ObjectUtil.defaultIfNull(item.pictures, Lists.immutable.empty()));
}
@GetMapping("list")
public AmisResponse<?> list() {
return AmisResponse.responseCrudData(feedbackService.list());
public AmisCrudResponse list() {
return AmisResponse.responseCrudData(feedbackService.list().collect(feedback -> new ListItem(fileStoreProperties, feedback)));
}
@GetMapping("delete")
public void delete(@RequestParam("id") Long id) {
feedbackService.remove(id);
}
@GetMapping("reanalysis")
public void reanalysis(@RequestParam("id") Long id) {
feedbackService.reanalysis(id);
}
@PostMapping("conclude")
public void conclude(@RequestBody ConcludeItem item) {
feedbackService.updateConclusion(item.getId(), item.getConclusion());
}
@Data
public static final class CreateItem {
private String source;
private ImmutableList<Long> pictures;
}
@Data
public static final class ConcludeItem {
private Long id;
private String conclusion;
}
@Data
public static final class ListItem {
private Long id;
private String source;
private ImmutableList<String> pictures;
private Feedback.Status status;
private String analysis;
private String conclusion;
public ListItem(FileStoreProperties fileStoreProperties, Feedback feedback) {
this.id = feedback.getId();
this.source = feedback.getSource();
this.pictures = feedback.getPictureIds()
.collect(id -> StrUtil.format("{}/upload/download/{}", fileStoreProperties.getDownloadPrefix(), id));
this.status = feedback.getStatus();
this.analysis = feedback.getAnalysis();
this.conclusion = feedback.getConclusion();
}
}
}

View File

@@ -37,9 +37,18 @@ public class KnowledgeBaseController {
@PostMapping("add")
public void add(
@RequestParam("name") String name,
@RequestParam("description") String description,
@RequestParam("strategy") String strategy
) throws ExecutionException, InterruptedException {
knowledgeBaseService.add(name, strategy);
knowledgeBaseService.add(name, description, strategy);
}
@PostMapping("update_description")
public void updateDescription(
@RequestParam("id") Long id,
@RequestParam("description") String description
) {
knowledgeBaseService.updateDescription(id, description);
}
@GetMapping("name")

View File

@@ -7,9 +7,9 @@ import org.eclipse.collections.api.list.ImmutableList;
public class Feedback {
private Long id;
private String source;
private String analysisShort;
private ImmutableList<Long> pictureIds;
private String analysis;
private ImmutableList<String> pictureIds;
private String conclusion;
private Status status;
private Long createdTime;
private Long modifiedTime;

View File

@@ -11,6 +11,7 @@ public class Knowledge {
private Long id;
private Long vectorSourceId;
private String name;
private String description;
private String strategy;
private Long createdTime;
private Long modifiedTime;

View File

@@ -0,0 +1,17 @@
package com.lanyuanxiaoyao.service.ai.web.entity.context;
import com.lanyuanxiaoyao.service.ai.web.entity.Feedback;
import java.util.List;
import lombok.Data;
import org.eclipse.collections.api.factory.Lists;
/**
* @author lanyuanxiaoyao
* @version 20250616
*/
@Data
public class FeedbackContext {
private Feedback feedback;
private String optimizedSource;
private List<String> pictureDescriptions = Lists.mutable.empty();
}

View File

@@ -11,6 +11,7 @@ public class KnowledgeVO {
private Long id;
private Long vectorSourceId;
private String name;
private String description;
private String strategy;
private Long size;
private Long points;

View File

@@ -1,18 +1,24 @@
package com.lanyuanxiaoyao.service.ai.web.service.feedback;
import club.kingon.sql.builder.SqlBuilder;
import cn.hutool.core.lang.Assert;
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.ai.web.entity.context.FeedbackContext;
import com.lanyuanxiaoyao.service.common.Constants;
import com.yomahub.liteflow.core.FlowExecutor;
import java.util.List;
import java.util.concurrent.TimeUnit;
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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -20,16 +26,17 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class FeedbackService {
public static final String FEEDBACK_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_feedback";
public static final String[] FEEDBACK_COLUMNS = new String[]{"id", "source", "conclusion", "analysis", "pictures", "status", "created_time", "modified_time"};
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.setConclusion(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), ","))
: Lists.immutable.ofAll(StrUtil.split(rs.getString(5), ",")).collect(Long::parseLong)
);
feedback.setStatus(EnumUtil.fromString(Feedback.Status.class, rs.getString(6)));
feedback.setCreatedTime(rs.getTimestamp(7).getTime());
@@ -37,9 +44,38 @@ public class FeedbackService {
return feedback;
};
private final JdbcTemplate template;
private final FlowExecutor executor;
public FeedbackService(JdbcTemplate template) {
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public FeedbackService(JdbcTemplate template, FlowExecutor executor) {
this.template = template;
this.executor = executor;
}
@Scheduled(initialDelay = 1, fixedDelay = 1, timeUnit = TimeUnit.MINUTES)
public void analysis() {
List<Feedback> feedbacks = template.query(
SqlBuilder.select(FEEDBACK_COLUMNS)
.from(FEEDBACK_TABLE_NAME)
.whereEq("status", Feedback.Status.ANALYSIS_PROCESSING.name())
.build(),
feedbackMapper
);
for (Feedback feedback : feedbacks) {
FeedbackContext context = new FeedbackContext();
context.setFeedback(feedback);
executor.execute2Resp("feedback_analysis", null, context);
}
}
public Feedback get(Long id) {
return template.queryForObject(
SqlBuilder.select(FEEDBACK_COLUMNS)
.from(FEEDBACK_TABLE_NAME)
.whereEq("id", id)
.build(),
feedbackMapper
);
}
@Transactional(rollbackFor = Exception.class)
@@ -51,15 +87,53 @@ public class FeedbackService {
.precompileSql(),
SnowflakeId.next(),
source,
ObjectUtil.isEmpty(pictureIds)
? null
: pictureIds.makeString(",")
ObjectUtil.isEmpty(pictureIds) ? null : pictureIds.makeString(",")
);
}
@Transactional(rollbackFor = Exception.class)
public void updateAnalysis(Long id, String analysis) {
Assert.notNull(id, "ID cannot be null");
template.update(
SqlBuilder.update(FEEDBACK_TABLE_NAME)
.set("analysis", "?")
.whereEq("id", "?")
.precompileSql(),
analysis,
id
);
}
@Transactional(rollbackFor = Exception.class)
public void updateConclusion(Long id, String conclusion) {
Assert.notNull(id, "ID cannot be null");
template.update(
SqlBuilder.update(FEEDBACK_TABLE_NAME)
.set("conclusion", "?")
.whereEq("id", "?")
.precompileSql(),
conclusion,
id
);
updateStatus(id, Feedback.Status.FINISHED);
}
@Transactional(rollbackFor = Exception.class)
public void updateStatus(Long id, Feedback.Status status) {
Assert.notNull(id, "ID cannot be null");
template.update(
SqlBuilder.update(FEEDBACK_TABLE_NAME)
.set("status", "?")
.whereEq("id", "?")
.precompileSql(),
status.name(),
id
);
}
public ImmutableList<Feedback> list() {
return template.query(
SqlBuilder.select("id", "source", "analysis_short", "analysis", "pictures", "status", "created_time", "modified_time")
SqlBuilder.select(FEEDBACK_COLUMNS)
.from(FEEDBACK_TABLE_NAME)
.orderByDesc("created_time")
.build(),
@@ -78,4 +152,9 @@ public class FeedbackService {
.build()
);
}
@Transactional(rollbackFor = Exception.class)
public void reanalysis(Long id) {
updateStatus(id, Feedback.Status.ANALYSIS_PROCESSING);
}
}

View File

@@ -9,7 +9,6 @@ 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;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
@@ -32,14 +31,16 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class KnowledgeBaseService {
public static final String KNOWLEDGE_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_knowledge";
public static final String[] KNOWLEDGE_COLUMNS = new String[]{"id", "vector_source_id", "name", "description", "strategy", "created_time", "modified_time"};
private static final RowMapper<Knowledge> knowledgeMapper = (rs, row) -> {
Knowledge knowledge = new Knowledge();
knowledge.setId(rs.getLong(1));
knowledge.setVectorSourceId(rs.getLong(2));
knowledge.setName(rs.getString(3));
knowledge.setStrategy(rs.getString(4));
knowledge.setCreatedTime(rs.getTimestamp(5).getTime());
knowledge.setModifiedTime(rs.getTimestamp(6).getTime());
knowledge.setDescription(rs.getString(4));
knowledge.setStrategy(rs.getString(5));
knowledge.setCreatedTime(rs.getTimestamp(6).getTime());
knowledge.setModifiedTime(rs.getTimestamp(7).getTime());
return knowledge;
};
private final JdbcTemplate template;
@@ -56,7 +57,7 @@ public class KnowledgeBaseService {
public Knowledge get(Long id) {
return template.queryForObject(
SqlBuilder.select("id", "vector_source_id", "name", "strategy", "created_time", "modified_time")
SqlBuilder.select(KNOWLEDGE_COLUMNS)
.from(KNOWLEDGE_TABLE_NAME)
.whereEq("id", "?")
.precompileSql(),
@@ -66,7 +67,7 @@ public class KnowledgeBaseService {
}
@Transactional(rollbackFor = Exception.class)
public void add(String name, String strategy) throws ExecutionException, InterruptedException {
public void add(String name, String description, String strategy) throws ExecutionException, InterruptedException {
Integer count = template.queryForObject(
SqlBuilder.select("count(*)")
.from(KNOWLEDGE_TABLE_NAME)
@@ -82,13 +83,14 @@ public class KnowledgeBaseService {
long id = SnowflakeId.next();
long vectorSourceId = SnowflakeId.next();
template.update(
SqlBuilder.insertInto(KNOWLEDGE_TABLE_NAME, "id", "vector_source_id", "name", "strategy")
SqlBuilder.insertInto(KNOWLEDGE_TABLE_NAME, "id", "vector_source_id", "name", "description", "strategy")
.values()
.addValue("?", "?", "?", "?")
.addValue("?", "?", "?", "?", "?")
.precompileSql(),
id,
vectorSourceId,
name,
description,
strategy
);
client.createCollectionAsync(
@@ -100,6 +102,18 @@ public class KnowledgeBaseService {
).get();
}
@Transactional(rollbackFor = Exception.class)
public void updateDescription(Long id, String description) {
template.update(
SqlBuilder.update(KNOWLEDGE_TABLE_NAME)
.set("description", "?")
.whereEq("id", "?")
.precompileSql(),
description,
id
);
}
public String getName(Long id) {
return template.queryForObject(
SqlBuilder.select("name")
@@ -113,7 +127,7 @@ public class KnowledgeBaseService {
public ImmutableList<KnowledgeVO> list() {
return template.query(
SqlBuilder.select("id", "vector_source_id", "name", "strategy", "created_time", "modified_time")
SqlBuilder.select(KNOWLEDGE_COLUMNS)
.from(KNOWLEDGE_TABLE_NAME)
.orderByDesc("created_time")
.build(),
@@ -127,6 +141,7 @@ public class KnowledgeBaseService {
vo.setId(knowledge.getId());
vo.setVectorSourceId(knowledge.getVectorSourceId());
vo.setName(knowledge.getName());
vo.setDescription(knowledge.getDescription());
vo.setPoints(info.getPointsCount());
vo.setSegments(info.getSegmentsCount());
vo.setStatus(info.getStatus().name());
@@ -165,7 +180,7 @@ public class KnowledgeBaseService {
String text,
Integer limit,
Double threshold
) throws ExecutionException, InterruptedException, IOException {
) throws ExecutionException, InterruptedException {
Knowledge knowledge = get(id);
Boolean exists = client.collectionExistsAsync(String.valueOf(knowledge.getVectorSourceId())).get();
if (!exists) {
@@ -182,13 +197,6 @@ public class KnowledgeBaseService {
.similarityThreshold(threshold)
.build()
);
// 如果只是一个知识库的话似乎没有什么rerank的必要...
/* List<org.noear.solon.ai.rag.Document> rerankDocuments = rerankingModel.rerank(
text,
documents.stream()
.map(doc -> new org.noear.solon.ai.rag.Document(doc.getId(), doc.getText(), doc.getMetadata(), doc.getScore()))
.toList()
); */
return Lists.immutable.ofAll(documents)
.collect(Document::getText);
}

View File

@@ -19,8 +19,6 @@ 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;
import org.springframework.ai.document.Document;
import org.springframework.ai.document.DocumentReader;
@@ -42,12 +40,12 @@ import org.springframework.core.io.PathResource;
@Slf4j
@LiteflowComponent
public class EmbeddingNodes {
private final ChatClient chatClient;
private final ChatClient.Builder chatClientBuilder;
private final QdrantClient qdrantClient;
private final EmbeddingModel embeddingModel;
public EmbeddingNodes(@Qualifier("chat") ChatClient.Builder builder, VectorStore vectorStore, EmbeddingModel embeddingModel) {
this.chatClient = builder.build();
this.chatClientBuilder = builder;
this.qdrantClient = (QdrantClient) vectorStore.getNativeClient().orElseThrow();
this.embeddingModel = embeddingModel;
}
@@ -152,9 +150,11 @@ public class EmbeddingNodes {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "qa_split", nodeName = "使用Q/A格式分段", nodeType = NodeTypeEnum.COMMON)
public void qaSplit(NodeComponent node) {
EmbeddingContext context = node.getContextBean(EmbeddingContext.class);
// language=TEXT
context.getDocuments().addAll(llmSplit(
"""
对用户输入的文本,生成多组高质量的问答对。请遵循以下指南:
1. 问题部分:
为同一个主题创建尽可能多的不同表述的问题,确保问题的多样性。
每个问题应考虑用户可能的多种问法,例如:
@@ -169,7 +169,7 @@ public class EmbeddingNodes {
答案应直接基于给定文本,确保准确性和一致性。
包含相关的细节,如日期、名称、职位等具体信息,必要时提供背景信息以增强理解。
3. 格式:
使用"问:"标记问题集合的开始,所有问题应在一个段落内,问题之间用空格分隔
使用"问:"标记问题的开始,问题文本应在一个段落内完成
使用"答:"标记答案的开始,答案应清晰分段,便于阅读。
问答对之间用“---”分隔,以提高可读性。
4. 内容要求:
@@ -177,6 +177,8 @@ public class EmbeddingNodes {
避免添加文本中未提及的信息,确保信息的真实性。
一个问题搭配一个答案,避免一组问答对中同时涉及多个问题。
如果文本信息不足以回答某个方面,可以在答案中说明 "根据给定信息无法确定",并尽量提供相关的上下文。
除了问答对本身,避免输出任何与问答对无关的提示性、引导性、解释性的文本。
格式样例:
问:苹果通常是什么颜色的?
答:红色。
@@ -190,7 +192,8 @@ public class EmbeddingNodes {
}
private List<Document> llmSplit(String prompt, String content, Map<String, Object> metadata) {
String response = chatClient.prompt()
ChatClient client = chatClientBuilder.build();
String response = client.prompt()
.system(prompt)
.user(content)
.call()

View File

@@ -1,14 +1,203 @@
package com.lanyuanxiaoyao.service.ai.web.service.node;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.lanyuanxiaoyao.service.ai.web.entity.Feedback;
import com.lanyuanxiaoyao.service.ai.web.entity.context.FeedbackContext;
import com.lanyuanxiaoyao.service.ai.web.entity.vo.DataFileVO;
import com.lanyuanxiaoyao.service.ai.web.service.DataFileService;
import com.lanyuanxiaoyao.service.ai.web.service.feedback.FeedbackService;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.FileSystemResource;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
@Slf4j
@LiteflowComponent
public class FeedbackNodes {
private final ChatClient.Builder chatClientBuilder;
private final ChatClient.Builder visualChatClientBuilder;
private final DataFileService dataFileService;
private final FeedbackService feedbackService;
public FeedbackNodes(@Qualifier("chat") ChatClient.Builder chatClientBuilder) {
public FeedbackNodes(
@Qualifier("chat") ChatClient.Builder chatClientBuilder,
@Qualifier("visual") ChatClient.Builder visualClientBuilder, DataFileService dataFileService, FeedbackService feedbackService
) {
this.chatClientBuilder = chatClientBuilder;
this.visualChatClientBuilder = visualClientBuilder;
this.dataFileService = dataFileService;
this.feedbackService = feedbackService;
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "feedback_check_if_picture_needed", nodeName = "判断有图片进行识别", nodeType = NodeTypeEnum.BOOLEAN)
public boolean checkIfPictureReadNeeded(NodeComponent node) {
FeedbackContext context = node.getContextBean(FeedbackContext.class);
Feedback feedback = context.getFeedback();
return ObjectUtil.isNotEmpty(feedback.getPictureIds());
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "image_read", nodeName = "读取图片", nodeType = NodeTypeEnum.COMMON)
public void imageRead(NodeComponent node) {
FeedbackContext context = node.getContextBean(FeedbackContext.class);
Feedback feedback = context.getFeedback();
ChatClient client = visualChatClientBuilder
// language=TEXT
.defaultSystem("""
你是一个专业的OCR解析助手。请严格按以下步骤处理用户上传的图片
1. 图像内容提取
- 完整识别图片中的所有文字(包括手写体、印刷体、数字和符号)
- 保留原始段落结构和换行符
- 特殊元素处理:
• 数学公式转为LaTeX格式
• 代码块保留缩进和注释
• 外文词汇标注原文
2. 表格解析优化
- 识别所有表格区域
- 转换为Markdown表格格式对齐表头与单元格
- 补充缺失的表格线
- 用▲标注合并单元格▲跨3列▲
3. 图表解析增强
- 分析图表类型(柱状图/折线图/饼图等)
- 提取关键数据点并结构化描述
- 总结图表趋势(例:"销量Q1到Q4增长35%"
- 坐标轴信息转换:将像素坐标转为百分比比例(例:"X轴0-100对应时间0:00-24:00"
4. 输出规范
- 按[文本][表格][图表]分区块输出
- 表格/图表区域标注原始位置(例:"[左上区域表格]"
- 模糊内容用[?]标注并给出备选(例:"年收[?]入(可能为'入'或'人'"
- 保持原始数据精度(不四舍五入)
立即开始处理用户图片,无需确认步骤。
""")
.build();
for (Long pictureId : feedback.getPictureIds()) {
DataFileVO file = dataFileService.downloadFile(pictureId);
log.info("Parse picture: {} {}", file.getFilename(), file.getPath());
MimeType type = switch (StrUtil.blankToDefault(file.getType(), "").toLowerCase()) {
case "jpg", "jpeg" -> MimeTypeUtils.IMAGE_JPEG;
default -> MimeTypeUtils.IMAGE_PNG;
};
String content = client.prompt()
.user(spec -> spec
.text("输出图片内容")
.media(type, new FileSystemResource(file.getPath())))
.call()
.content();
log.info("Picture: {}", content);
context.getPictureDescriptions().add(content);
}
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "optimize_source", nodeName = "报障信息优化", nodeType = NodeTypeEnum.COMMON)
public void optimizeSource(NodeComponent node) {
FeedbackContext context = node.getContextBean(FeedbackContext.class);
Feedback feedback = context.getFeedback();
String optimizedSource = chatClientBuilder.build()
.prompt()
// language=TEXT
.system("""
你是一名专业的IT系统运维工程师对于用户输入的关于系统的报障信息你会严格遵循以下步骤进行处理
1.输入
[故障描述]
(这里是用户遇到的系统故障的详细描述)
[相关截图]
(这里是用户遇到的系统故障相关的截图的文字描述,如果没有相关截图,这里会写“无”;如果有多张图片,图片和图片之间会使用“---”分隔)
2.处理逻辑
解析输入
读取并解析用户提供的故障描述和相关截图描述。
识别关键元素:包括故障类型(如硬件故障、软件错误)、受影响系统组件(如服务器、网络设备)、错误消息、发生时间、重现步骤、影响范围等。
如果截图描述存在,提取关键细节(如错误弹窗文本、系统状态截图),并将其作为辅助证据;如果无截图,则忽略此部分。
分析与重写故障描述
专业化改写使用标准IT术语替换非专业用语例如“电脑死机”改为“系统无响应”“连不上网”改为“网络连接中断”并确保描述符合行业规范。
排除歧义澄清模糊描述如添加具体时间戳、系统版本、IP地址或错误代码移除主观语言如“我觉得”或“可能”并添加必要上下文如操作系统环境、相关服务运行状态
结构化组织:将故障描述重写为逻辑段落,格式包括:
问题概述:简明总结故障本质(例如,“数据库服务异常导致应用无法访问”)。
详细症状描述具体现象包括错误消息、发生频率和影响范围如“影响用户登录功能错误代码500”
重现步骤列出可复现故障的操作序列如“1. 访问URL X2. 触发操作 Y”
相关环境添加系统细节如“运行在Linux Ubuntu 20.04, Java 11环境”
整合截图信息如果截图描述存在将其嵌入重写中作为证据例如“根据截图错误弹窗显示Connection timeout
质量校验
检查重写后的内容是否完整、一致且无歧义:确保所有用户输入细节都被涵盖,添加缺失信息(如建议的故障分类),并验证专业术语的准确性。
如果输入信息不足(如缺少时间戳或系统版本),在输出中添加注释提示用户补充。
3.输出
输出一个专业、结构化的故障报告,格式清晰,可直接用于运维团队诊断。
重写的故障描述,以结构化段落呈现,涵盖问题概述、详细症状、重现步骤和相关环境。
输出将使用中性、客观语言,避免任何个人意见或建议,以确保报告专注于事实描述。
""")
.user(StrUtil.format(
"""
[故障描述]
{}
[相关截图]
{}
""",
feedback.getSource(),
ObjectUtil.isEmpty(context.getPictureDescriptions()) ? "" : StrUtil.join(",", context.getPictureDescriptions())
))
.call()
.content();
if (StrUtil.isBlank(optimizedSource)) {
log.warn("Optimized source is blank");
}
context.setOptimizedSource(StrUtil.trim(optimizedSource));
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "feedback_suggest", nodeName = "大模型建议", nodeType = NodeTypeEnum.COMMON)
public void suggestFeedback(NodeComponent node) {
FeedbackContext context = node.getContextBean(FeedbackContext.class);
Feedback feedback = context.getFeedback();
ChatClient client = chatClientBuilder.build();
String analysis = client.prompt()
// language=TEXT
.system("""
你是一名专业的IT系统运维工程师。针对用户输入的报障信息严格遵循以下步骤
1. 提取关键要素: 精准识别报障信息中的关键要素(如系统/设备名称、故障现象、错误信息、时间地点、影响范围、用户操作步骤等)。
2. 分析诊断: 基于提取的要素,运用运维专业知识,分析潜在原因,并提出优先级高、可操作性强的排障建议或初步诊断方向。
3. 输出专业意见:
内容要求: 意见必须包含明确的行动步骤如检查XX日志、验证XX配置、重启XX服务、联系XX团队、潜在风险提示及预期效果。
表达要求: 使用清晰、简洁、专业的技术术语,避免使用推测性语言或不确定词汇(如“可能”、“大概”、“也许”)。
格式要求: 直接输出意见内容,避免添加引导语(如“我的建议是”、“根据报障信息”等)。
""")
.user(context.getOptimizedSource())
.call()
.content();
feedback.setAnalysis(StrUtil.trim(analysis));
Assert.notBlank(analysis, "Analysis cannot be blank");
String conclusion = client.prompt()
// language=TEXT
.system("""
你是一名专业的文字编辑。严格按以下要求处理用户输入:
核心逻辑: 用一段话精准总结输入内容的核心信息,确保涵盖所有关键点。禁止虚构、扩展或添加原文不存在的信息。
输出规范: 仅输出一段总结文本。禁止分点、分段、使用Markdown格式如着重、- 或 1. 等列表符号)或添加任何无关引导语(如“总结如下”、“该总结指出”、“本文总结”等)。直接给出总结文本。""")
.user(analysis)
.call()
.content();
feedback.setConclusion(StrUtil.trim(conclusion));
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "feedback_save", nodeName = "保存分析内容", nodeType = NodeTypeEnum.COMMON)
public void saveFeedback(NodeComponent node) {
FeedbackContext context = node.getContextBean(FeedbackContext.class);
Feedback feedback = context.getFeedback();
feedbackService.updateAnalysis(feedback.getId(), feedback.getAnalysis());
feedbackService.updateConclusion(feedback.getId(), feedback.getConclusion());
feedbackService.updateStatus(feedback.getId(), Feedback.Status.ANALYSIS_SUCCESS);
}
}

View File

@@ -44,7 +44,7 @@ public class ChartTool {
""") String request
) {
log.info("Enter method: mermaid[request]. request:{}", request);
ChatClient.Builder builder = WebApplication.getBean(ChatClient.Builder.class);
ChatClient.Builder builder = WebApplication.getBean("chat", ChatClient.Builder.class);
ChatClient client = builder.build();
return client.prompt()
// language=TEXT

View File

@@ -1,20 +0,0 @@
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'

View File

@@ -1,39 +0,0 @@
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}.'

View File

@@ -1,6 +1,11 @@
server:
compression:
enabled: true
spring:
application:
name: service-ai-web
profiles:
include: random-port,common,discovery,metrics,forest
mvc:
async:
request-timeout: 3600000
@@ -13,7 +18,25 @@ spring:
org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration,
org.springframework.ai.model.openai.autoconfigure.OpenAiModerationAutoConfiguration,
org.springframework.ai.model.deepseek.autoconfigure.DeepSeekChatAutoConfiguration
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:
base-url: ${spring.llm.base-url}/v1
model: 'Qwen3/qwen3-1.7b'
visual:
model: 'Qwen2.5/qwen2.5-vl-7b-q4km'
embedding:
model: 'Qwen3/qwen3-embedding-4b'
reranker:
model: 'BGE/beg-reranker-v2'
liteflow:
rule-source: liteflow.xml
print-banner: false
check-node-exists: false
check-node-exists: false

View File

@@ -23,4 +23,15 @@
<chain id="embedding_submit_directly">
SER(import_vector_source)
</chain>
<chain id="feedback_analysis">
SER(
IF(
feedback_check_if_picture_needed,
image_read
),
optimize_source,
feedback_suggest,
feedback_save
)
</chain>
</flow>

View File

@@ -1,114 +1,68 @@
package com.lanyuanxiaoyao.service.ai.web;
import java.net.http.HttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lanyuanxiaoyao.service.ai.core.configuration.WebClientConfiguration;
import com.lanyuanxiaoyao.service.ai.web.configuration.LlmConfiguration;
import com.lanyuanxiaoyao.service.ai.web.configuration.LlmProperties;
import lombok.extern.slf4j.Slf4j;
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.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 org.springframework.core.io.FileSystemResource;
import org.springframework.util.MimeTypeUtils;
/**
* @author lanyuanxiaoyao
* @version 20250526
*/
@Slf4j
public class TestLlm {
private static final Logger log = LoggerFactory.getLogger(TestLlm.class);
public static void main(String[] args) {
HttpClient httpClient = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.build();
ChatClient client = ChatClient.builder(
OpenAiChatModel.builder()
.openAiApi(
OpenAiApi.builder()
.baseUrl("http://132.121.206.65:10086")
.apiKey("*XMySqV%>hR&v>>g*NwCs3tpQ5FVMFEF2VHVTj<MYQd$&@$sY7CgqNyea4giJi4")
.webClientBuilder(WebClient.builder().clientConnector(new JdkClientHttpConnector(httpClient)))
.restClientBuilder(RestClient.builder().requestFactory(new JdkClientHttpRequestFactory(httpClient)))
.build()
)
.defaultOptions(
OpenAiChatOptions.builder()
.model("Qwen3-1.7-vllm")
.build()
)
.build()
)
.build();
LlmConfiguration configuration = new LlmConfiguration();
LlmProperties properties = new LlmProperties();
LlmProperties.ChatProperties chatProperties = new LlmProperties.ChatProperties();
chatProperties.setBaseUrl("http://132.121.206.65:10086");
chatProperties.setApiKey("*XMySqV%>hR&v>>g*NwCs3tpQ5FVMFEF2VHVTj<MYQd$&@$sY7CgqNyea4giJi4");
chatProperties.setModel("Qwen2.5/qwen2.5-vl-7b");
properties.setVisual(chatProperties);
ChatClient client = configuration.visualClientBuilder(
properties,
WebClientConfiguration.generateWebClientBuilder(),
WebClientConfiguration.generateRestClientBuilder()
).build();
String content = client.prompt()
// language=TEXT
.system("""
对用户输入的文本,生成多组高质量的问答对。请遵循以下指南
1. 问题部分:
为同一个主题创建尽可能多的不同表述的问题,确保问题的多样性。
每个问题应考虑用户可能的多种问法,例如:
直接询问(如“什么是...?”)
请求确认(如“是否可以说...?”)
寻求解释(如“请解释一下...的含义。”)
假设性问题(如“如果...会怎样?”)
例子请求(如“能否举个例子说明...?”)
问题应涵盖文本中的关键信息、主要概念和细节,确保不遗漏重要内容。
2. 答案部分:
提供一个全面、信息丰富的答案,涵盖问题的所有可能角度,确保逻辑连贯。
答案应直接基于给定文本,确保准确性和一致性。
包含相关的细节,如日期、名称、职位等具体信息,必要时提供背景信息以增强理解。
3. 格式:
使用"问:"标记问题集合的开始,所有问题应在一个段落内,问题之间用空格分隔。
使用"答:"标记答案的开始,答案应清晰分段,便于阅读。
问答对之间用“---”分隔,以提高可读性。
4. 内容要求:
确保问答对紧密围绕文本主题,避免偏离主题。
避免添加文本中未提及的信息,确保信息的真实性。
一个问题搭配一个答案,避免一组问答对中同时涉及多个问题。
如果文本信息不足以回答某个方面,可以在答案中说明 "根据给定信息无法确定",并尽量提供相关的上下文。
""")
.user("""
Apache Hudi 是一款开源的数据湖管理框架,专注于高效处理大规模数据集的增量更新和实时操作。以下是其核心要点介绍:
核心功能与特性
增量数据处理支持插入Insert、更新Update、删除Delete操作并通过“Upsert”插入或更新机制高效处理变更数据避免重写整个数据集。
事务支持:提供 ACID 事务保证,确保数据一致性和可靠性,支持原子提交和回滚。
存储优化:自动合并小文件并维护文件最佳大小,减少存储碎片化问题,提升查询性能。
多查询类型:
快照查询:获取最新数据状态(对 MoR 表合并基础文件和增量文件)。
增量查询:捕获自某次提交后的变更数据流,适用于增量管道。
读取优化查询:针对 MoR 表展示最新压缩后的数据。
存储模型
写入时复制Copy-on-Write, CoW数据以列式格式如 Parquet存储每次更新生成新版本文件适合读多写少的场景。
读取时合并Merge-on-Read, MoR结合列式Parquet和行式Avro存储更新写入增量文件后异步合并适合写频繁的场景。
适用场景
合规性需求:支持 GDPR、CCPA 等法规要求的数据删除和更新。
实时数据流处理:如 IoT 设备数据、CDC变更数据捕获系统实现近实时分析。
数据湖管理:优化大规模数据集的存储和查询效率,支持时间旅行查询和历史版本回溯。
技术生态与兼容性
多引擎支持:与 Spark、Flink、Hive、Presto、Trino 等计算和查询引擎集成。
存储格式:基于 Parquet 和 Avro兼容 Hadoop 生态及云存储(如 Amazon S3
优势对比
相较于同类产品(如 Apache Iceberg、Delta LakeHudi 在实时更新和增量处理方面表现突出,尤其适合需要频繁数据变更的场景。其独特的 MoR 模型在写入性能上优于传统批处理方案。
总结
Apache Hudi 通过灵活的存储模型、高效的事务管理和广泛的生态系统集成,成为构建现代化数据湖的核心工具,适用于金融、物联网、实时分析等对数据新鲜度和操作效率要求高的领域。
你是一个专业的OCR解析助手。请严格按以下步骤处理用户上传的图片
1. 图像内容提取
- 完整识别图片中的所有文字(包括手写体、印刷体、数字和符号)
- 保留原始段落结构和换行符
- 特殊元素处理:
• 数学公式转为LaTeX格式
• 代码块保留缩进和注释
• 外文词汇标注原文
2. 表格解析优化
- 识别所有表格区域
- 转换为Markdown表格格式对齐表头与单元格
- 补充缺失的表格线
- 用▲标注合并单元格▲跨3列▲
3. 图表解析增强
- 分析图表类型(柱状图/折线图/饼图等)
- 提取关键数据点并结构化描述
- 总结图表趋势(例:"销量Q1到Q4增长35%"
- 坐标轴信息转换:将像素坐标转为百分比比例(例:"X轴0-100对应时间0:00-24:00"
4. 输出规范
- 按[文本][表格][图表]分区块输出
- 表格/图表区域标注原始位置(例:"[左上区域表格]"
- 模糊内容用[?]标注并给出备选(例:"年收[?]入(可能为'入'或'人'"
- 保持原始数据精度(不四舍五入)
立即开始处理用户图片,无需确认步骤。
""")
.user(spec -> spec
// language=TEXT
.text("输出图片内容")
.media(MimeTypeUtils.IMAGE_PNG, new FileSystemResource("/Users/lanyuanxiaoyao/Downloads/图片_002_07.png")))
.call()
.content();
log.info(content);

View File

@@ -161,23 +161,15 @@ deploy:
- "service"
source-jar: service-monitor-1.0.0-SNAPSHOT.jar
replicas: 1
service-ai-chat:
service-ai-web:
order: 6
groups:
- "ai"
source-jar: service-ai-chat-1.0.0-SNAPSHOT.jar
jdk: "jdk17"
replicas: 1
service-ai-knowledge:
order: 6
groups:
- "ai"
source-jar: service-ai-knowledge-1.0.0-SNAPSHOT.jar
source-jar: service-ai-web-1.0.0-SNAPSHOT.jar
jdk: "jdk17"
replicas: 1
arguments:
"[spring.profiles.active]": 'build'
"[file-store.download-prefix]": 'http://132.126.207.130:35690/hudi_services/ai_knowledge'
"[file-store.download-prefix]": 'http://132.126.207.130:35690/hudi_services/service_ai_web'
"[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}

View File

@@ -1,3 +1,4 @@
<!--suppress CssUnknownTarget, HtmlUnknownTarget -->
<!doctype html>
<html lang="zh">
<head>
@@ -13,6 +14,15 @@
margin: 0;
padding: 0;
}
@font-face {
font-family: 'LXGWWenKai';
src: url('fonts/LXGWNeoXiHei.ttf') format('truetype');
}
*:not(.fa,.fas) {
font-family: LXGWWenKai, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', serif !important;
}
</style>
</head>
<body>

View File

@@ -10,17 +10,18 @@
},
"dependencies": {
"@ant-design/icons": "^6.0.0",
"@ant-design/pro-components": "^2.8.7",
"@ant-design/pro-components": "^2.8.9",
"@ant-design/x": "^1.4.0",
"@echofly/fetch-event-source": "^3.0.2",
"@fortawesome/fontawesome-free": "^6.7.2",
"@lightenna/react-mermaid-diagram": "^1.0.20",
"@tinyflow-ai/react": "^0.1.10",
"@tinyflow-ai/react": "^0.2.1",
"@xyflow/react": "^12.7.0",
"ahooks": "^3.8.5",
"amis": "^6.12.0",
"antd": "^5.25.3",
"axios": "^1.9.0",
"chart.js": "^4.4.9",
"antd": "^5.26.1",
"axios": "^1.10.0",
"chart.js": "^4.5.0",
"echarts-for-react": "^3.0.2",
"licia": "^1.48.0",
"markdown-it": "^14.1.0",
@@ -29,18 +30,18 @@
"react-chartjs-2": "^5.3.0",
"react-dom": "^18.3.1",
"react-markdown": "^10.1.0",
"react-router": "^7.6.1",
"styled-components": "^6.1.18"
"react-router": "^7.6.2",
"styled-components": "^6.1.18",
"zustand": "^5.0.5"
},
"devDependencies": {
"@types/markdown-it": "^14.1.2",
"@types/react": "^18.3.23",
"@types/react-dom": "^18.3.7",
"@vitejs/plugin-react-swc": "^3.10.0",
"@vitejs/plugin-react-swc": "^3.10.2",
"globals": "^16.2.0",
"sass": "^1.89.0",
"sass": "^1.89.2",
"typescript": "~5.8.3",
"typescript-eslint": "^8.33.0",
"vite": "^6.3.5",
"vite-plugin-javascript-obfuscator": "^3.1.0"
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,4 @@
// 改写一些amis中控制不到的全局CSS
button.btn-deleted:hover {
color: #dc2626 !important;
}

View File

@@ -1,6 +1,6 @@
import {createRoot} from 'react-dom/client'
import {createHashRouter, RouterProvider} from 'react-router'
import './index.scss'
import './components/Registry.ts'
import {routes} from './route.tsx'

View File

@@ -2,6 +2,7 @@ import {ProLayout} from '@ant-design/pro-components'
import React from 'react'
import {Outlet, useLocation, useNavigate} from 'react-router'
import {menus} from '../route.tsx'
import {ConfigProvider} from 'antd'
const App: React.FC = () => {
const navigate = useNavigate()
@@ -34,7 +35,18 @@ const App: React.FC = () => {
style={{minHeight: '100vh'}}
contentStyle={{backgroundColor: 'white', padding: '10px 10px 10px 20px'}}
>
<Outlet/>
<ConfigProvider
theme={{
components: {
Card: {
bodyPadding: 0,
bodyPaddingSM: 0,
}
}
}}
>
<Outlet/>
</ConfigProvider>
</ProLayout>
)
}

View File

@@ -1,128 +1,486 @@
import MarkdownRender from '../util/Markdown.tsx'
import {useState} from 'react'
import {DeleteFilled, EditFilled, PlusCircleFilled, SaveFilled} from '@ant-design/icons'
import {
addEdge,
applyEdgeChanges,
applyNodeChanges,
Background,
BackgroundVariant,
Controls,
type Edge,
Handle,
MiniMap,
type Node,
type NodeProps,
type OnConnect,
type OnEdgesChange,
type OnNodesChange,
Position,
ReactFlow,
} from '@xyflow/react'
import {useMount} from 'ahooks'
import type {Schema} from 'amis'
import {Button, Card, Drawer, Dropdown, message, Space} from 'antd'
import {arrToMap, filter, find, findIdx, isEqual, isNil, randomId} from 'licia'
import {type JSX, useState} from 'react'
import styled from 'styled-components'
import '@xyflow/react/dist/style.css'
import {create} from 'zustand/react'
import {amisRender, commonInfo} from '../util/amis.tsx'
// language=Markdown
const markdownText = `### Hello
const FlowableDiv = styled.div`
height: 93vh;
world
tony
jenny
.toolbar {
z-index: 999;
position: absolute;
}
\`\`\`javascript
console.log('hello')
\`\`\`
.node-card {
cursor: grab;
\`\`\`mermaid
graph TD
a-->b;
\`\`\`
\`\`\`mermaid
graph TD
c-->d;
\`\`\`
\`\`\`chartjs
{
type: 'bar',
data: {
labels: ['苹果', '香蕉', '橙子', '葡萄', '菠萝'],
datasets: [{
label: '水果销量',
data: [43, 32, 56, 29, 38],
}]
},
options: {
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: '水果店周销量数据'
}
.card-container {
cursor: default;
}
}
}
\`\`\`
`
\`\`\`chartjs
{
type: 'bar',
data: {
labels: ['苹果', '香蕉', '橙子', '葡萄', '菠萝'],
datasets: [{
label: '水果销量',
data: [43, 32, 56, 29, 38],
}]
},
options: {
plugins: {
legend: {
position: 'top',
type AmisNodeType = 'normal' | 'start' | 'end'
const AmisNode = (
props: NodeProps,
type: AmisNodeType,
name: String,
description?: String,
columnSchema?: Schema[],
) => {
const {id, data} = props
const {getDataById, removeNode, editNode} = data
return (
<div className="p-1 w-64">
<Card
className="node-card"
title={name}
size="small"
hoverable
>
<Dropdown
className="card-container"
trigger={['contextMenu']}
menu={{
items: [
{
key: 'edit',
label: '编辑',
icon: <EditFilled className="text-gray-600 hover:text-blue-500"/>,
},
{
key: 'remove',
label: '删除',
icon: <DeleteFilled className="text-red-500 hover:text-red-500"/>,
},
],
onClick: menu => {
switch (menu.key) {
case 'edit':
// @ts-ignore
editNode(id, name, description, columnSchema)
break
case 'remove':
// @ts-ignore
removeNode(id)
break
}
},
title: {
display: true,
text: '水果店周销量数据'
}
}
}
}}
>
<div className="card-description p-2 text-secondary text-sm">
{description}
</div>
</Dropdown>
</Card>
{isEqual(type, 'start') || isEqual(type, 'normal')
? <Handle type="source" position={Position.Right}/> : undefined}
{isEqual(type, 'end') || isEqual(type, 'normal')
? <Handle type="target" position={Position.Left}/> : undefined}
</div>
)
}
\`\`\`
\`\`\`echart
{
grid: { top: 8, right: 8, bottom: 24, left: 36 },
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true,
const StartAmisNode = (props: NodeProps) => AmisNode(
props,
'start',
'开始节点',
'定义输入变量',
[
{
type: 'input-kvs',
name: 'fields',
addButtonText: '新增入参',
draggable: false,
keyItem: {
label: '参数名称',
},
],
tooltip: {
trigger: 'axis',
valueItems: [
{
type: 'input-text',
name: 'description',
label: '参数描述',
},
{
type: 'select',
name: 'type',
label: '参数类型',
required: true,
selectFirst: true,
options: [
{
label: '文本',
value: 'text',
},
{
label: '数字',
value: 'number',
},
{
label: '文件',
value: 'files',
},
],
},
],
},
}
\`\`\`
],
)
const EndAmisNode = (props: NodeProps) => AmisNode(
props,
'end',
'结束节点',
'定义输出变量',
[
{
type: 'input-kvs',
name: 'fields',
addButtonText: '新增输出',
draggable: false,
keyItem: {
label: '参数名称',
},
valueItems: [
{
type: 'select',
name: 'type',
label: '参数',
required: true,
selectFirst: true,
options: [],
},
],
},
],
)
const LlmAmisNode = (props: NodeProps) => AmisNode(
props,
'normal',
'大模型节点',
'使用大模型对话',
[
{
type: 'select',
name: 'model',
label: '大模型',
required: true,
selectFirst: true,
options: [
{
label: 'Qwen3',
value: 'qwen3',
},
{
label: 'Deepseek',
value: 'deepseek',
},
],
},
{
type: 'textarea',
name: 'systemPrompt',
label: '系统提示词',
required: true,
},
],
)
\`\`\`echart
{
grid: { top: 8, right: 8, bottom: 24, left: 36 },
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true,
},
],
tooltip: {
trigger: 'axis',
},
}
\`\`\``
const initialNodes: Node[] = [
{
id: 'BMFP3Eov94',
type: 'start-amis-node',
position: {x: 10, y: 100},
data: {},
},
{
id: 'PYK8LjduQ1',
type: 'end-amis-node',
position: {x: 500, y: 100},
data: {},
},
]
const initialEdges: Edge[] = []
const useStore = create<{
data: Record<string, any>,
getData: () => Record<string, any>,
setData: (data: Record<string, any>) => void,
getDataById: (id: string) => any,
setDataById: (id: string, data: any) => void,
}>((set, get) => ({
data: {},
getData: () => get().data,
setData: (data) => set(data),
getDataById: id => get().data[id],
setDataById: (id, data) => {
let updateData = get().data
updateData[id] = data
set({
data: updateData,
})
},
}))
const useFlowStore = create<{
nodes: Node[],
onNodesChange: OnNodesChange,
addNode: (node: Node) => void,
removeNode: (id: string) => void,
setNodes: (nodes: Node[]) => void,
edges: Edge[],
onEdgesChange: OnEdgesChange,
setEdges: (edges: Edge[]) => void,
onConnect: OnConnect,
}>((set, get) => ({
nodes: [],
onNodesChange: changes => {
set({
nodes: applyNodeChanges(changes, get().nodes),
})
},
addNode: node => set({nodes: get().nodes.concat(node)}),
removeNode: id => {
set({
nodes: filter(get().nodes, node => !isEqual(node.id, id)),
})
},
setNodes: nodes => set({nodes}),
edges: [],
onEdgesChange: changes => {
set({
edges: applyEdgeChanges(changes, get().edges),
})
},
setEdges: edges => set({edges}),
onConnect: connection => {
set({
edges: addEdge(connection, get().edges),
})
},
}))
function Test() {
const [value, setValue] = useState<string>(markdownText)
const [messageApi, contextHolder] = message.useMessage()
const [nodeDef] = useState<{
key: string,
name: string,
component: (props: NodeProps) => JSX.Element
}[]>([
{
key: 'start-amis-node',
name: '开始',
component: StartAmisNode,
},
{
key: 'end-amis-node',
name: '结束',
component: EndAmisNode,
},
{
key: 'llm-amis-node',
name: '大模型',
component: LlmAmisNode,
},
])
const [open, setOpen] = useState(false)
const {getData, getDataById, setDataById} = useStore()
const {
nodes,
addNode,
removeNode,
setNodes,
onNodesChange,
edges,
setEdges,
onEdgesChange,
onConnect,
} = useFlowStore()
const [currentNodeForm, setCurrentNodeForm] = useState<JSX.Element>()
const editNode = (id: string, name: string, description: string, columnSchema?: Schema[]) => {
if (!isNil(columnSchema)) {
setCurrentNodeForm(
amisRender(
{
type: 'wrapper',
size: 'none',
body: [
{
type: 'tpl',
className: 'text-secondary',
tpl: description,
},
{
debug: commonInfo.debug,
title: name,
type: 'form',
wrapWithPanel: false,
onEvent: {
submitSucc: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, action, event) => {
setDataById(id, context.props.data)
setOpen(false)
},
},
],
},
},
body: [
...(columnSchema ?? []),
{
type: 'wrapper',
size: 'none',
className: 'space-x-1 float-right',
body: [
{
type: 'action',
label: '取消',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, action, event) => {
setOpen(false)
},
},
],
},
},
},
{
type: 'submit',
label: '保存',
level: 'primary',
},
],
},
],
},
]
},
getDataById(id),
),
)
setOpen(true)
}
}
useMount(() => {
for (let node of initialNodes) {
node.data = {
getDataById,
setDataById,
removeNode,
editNode,
}
}
setNodes(initialNodes)
setEdges(initialEdges)
})
return (
<>
<button onClick={() => setValue('hahaha\n' + markdownText)}>Button</button>
<MarkdownRender content={value}/>
</>
<FlowableDiv>
{contextHolder}
<Space className="toolbar">
<Button type="primary" onClick={() => console.log(JSON.stringify(getData()))}>
<SaveFilled/>
</Button>
<Dropdown
menu={{
items: nodeDef.map(def => ({key: def.key, label: def.name})),
onClick: ({key}) => {
if (isEqual(key, 'start-amis-node') && findIdx(nodes, (node: Node) => isEqual(key, node.type)) > -1) {
messageApi.error('只能存在1个开始节点')
return
}
if (isEqual(key, 'end-amis-node') && findIdx(nodes, (node: Node) => isEqual(key, node.type)) > -1) {
messageApi.error('只能存在1个结束节点')
return
}
addNode({
id: randomId(10),
type: key,
position: {x: 100, y: 100},
data: {
getDataById,
setDataById,
removeNode,
editNode,
},
})
},
}}
>
<Button type="dashed">
<PlusCircleFilled/>
</Button>
</Dropdown>
</Space>
<Drawer
title="节点编辑"
open={open}
closeIcon={false}
maskClosable={false}
destroyOnHidden
>
{currentNodeForm}
</Drawer>
<ReactFlow
nodes={nodes}
edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
// @ts-ignore
nodeTypes={arrToMap(
nodeDef.map(def => def.key),
key => find(nodeDef, def => isEqual(key, def.key))!.component)
}
>
<Controls/>
<MiniMap/>
<Background variant={BackgroundVariant.Cross} gap={20} size={3}/>
</ReactFlow>
</FlowableDiv>
)
}

View File

@@ -1,6 +1,7 @@
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 {useUnmount} from 'ahooks'
import {Button, Collapse, Flex, Typography} from 'antd'
import {isStrBlank, trim} from 'licia'
import {useRef, useState} from 'react'
@@ -40,6 +41,11 @@ function Conversation() {
const abortController = useRef<AbortController | null>(null)
const [input, setInput] = useState<string>('')
useUnmount(() => {
console.log('Page Unmount')
abortController.current?.abort()
})
const [agent] = useXAgent<ChatMessage>({
request: async (info, callbacks) => {
await fetchEventSource(`${commonInfo.baseAiUrl}/chat/async`, {
@@ -55,6 +61,7 @@ function Conversation() {
})
},
onclose: () => callbacks.onSuccess([]),
onerror: error => callbacks.onError(error),
})
},
})

View File

@@ -1,9 +1,27 @@
import React from 'react'
import {amisRender, commonInfo, crudCommonOptions} from '../../../util/amis.tsx'
import styled from 'styled-components'
import {amisRender, commonInfo, crudCommonOptions, mappingField, mappingItem} from '../../../util/amis.tsx'
const FeedbackDiv = styled.div`
.feedback-list-images {
margin-top: 10px;
.antd-Img-container {
width: 32px;
height: 32px;
}
}
`
const statusMapping = [
mappingItem('分析中', 'ANALYSIS_PROCESSING', 'label-warning'),
mappingItem('分析完成', 'ANALYSIS_SUCCESS', 'label-primary'),
mappingItem('处理完成', 'FINISHED', 'label-success'),
]
const Feedback: React.FC = () => {
return (
<div className="feedback">
<FeedbackDiv className="feedback">
{amisRender(
{
type: 'page',
@@ -28,10 +46,7 @@ const Feedback: React.FC = () => {
body: {
debug: commonInfo.debug,
type: 'form',
api: {
url: `${commonInfo.baseAiUrl}/feedback/add`,
dataType: 'form',
},
api: `${commonInfo.baseAiUrl}/feedback/add`,
body: [
{
type: 'editor',
@@ -50,12 +65,14 @@ const Feedback: React.FC = () => {
label: '相关截图',
autoUpload: false,
multiple: true,
joinValues: false,
extractValue: true,
// 5MB 5242880
// 100MB 104857600
// 500MB 524288000
// 1GB 1073741824
maxSize: 5242880,
receiver: `${commonInfo.baseAiUrl}/upload`
receiver: `${commonInfo.baseAiUrl}/upload`,
},
],
},
@@ -66,21 +83,141 @@ const Feedback: React.FC = () => {
{
name: 'id',
label: '编号',
width: 150,
},
{
label: '故障描述',
type: 'flex',
direction: 'column',
items: [
{
type: 'tpl',
className: 'white-space-pre',
tpl: '${source}',
},
{
className: 'feedback-list-images',
type: 'images',
enlargeAble: true,
enlargeWithGallary: true,
source: '${pictures}',
showToolbar: true,
},
],
},
{
name: 'status',
label: '状态',
width: 80,
align: 'center',
...mappingField('status', statusMapping),
},
{
type: 'operation',
label: '操作',
width: 150,
width: 200,
buttons: [
{
visibleOn: '${status === \'ANALYSIS_SUCCESS\'}',
type: 'action',
label: '重新分析',
level: 'link',
size: 'sm',
actionType: 'ajax',
api: {
method: 'get',
url: `${commonInfo.baseAiUrl}/feedback/reanalysis`,
data: {
id: '${id}',
},
},
confirmText: '确认执行重新分析?',
confirmTitle: '重新分析',
},
{
disabledOn: '${status === \'ANALYSIS_PROCESSING\'}',
type: 'action',
label: '详情',
level: 'link',
size: 'sm',
actionType: 'dialog',
dialog: {
title: '报障详情',
size: 'lg',
closeOnOutside: true,
actions: [
{
visibleOn: '${status !== \'FINISHED\'}',
type: 'action',
actionType: 'close',
label: '取消',
},
{
visibleOn: '${status !== \'FINISHED\'}',
type: 'submit',
label: '确认',
level: 'primary',
},
],
body: {
debug: commonInfo.debug,
type: 'form',
mode: 'normal',
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/feedback/conclude`,
data: {
id: '${id}',
conclusion: '${conclusion|default:undefined}',
},
},
body: [
{
type: 'textarea',
name: 'source',
label: '报障描述',
static: true,
},
{
type: 'control',
name: 'pictures',
label: '相关截图',
body: {
type: 'images',
enlargeAble: true,
enlargeWithGallary: true,
showToolbar: true,
},
},
{
type: 'control',
name: 'analysis',
label: 'AI辅助分析',
body: {
type: 'markdown',
},
},
{
visibleOn: '${status !== \'FINISHED\'}',
type: 'textarea',
name: 'conclusion',
label: '结论',
},
{
visibleOn: '${status === \'FINISHED\'}',
type: 'textarea',
name: 'conclusion',
label: '结论',
static: true,
},
],
},
},
},
{
disabledOn: '${status === \'ANALYSIS_PROCESSING\'}',
type: 'action',
label: '删除',
className: 'text-danger hover:text-red-600',
className: 'text-danger btn-deleted',
level: 'link',
size: 'sm',
actionType: 'ajax',
@@ -91,8 +228,8 @@ const Feedback: React.FC = () => {
id: '${id}',
},
},
confirmText: '确认删除',
confirmTitle: '删除',
confirmText: '删除后将无法恢复,确认删除?',
},
],
},
@@ -101,7 +238,7 @@ const Feedback: React.FC = () => {
],
},
)}
</div>
</FeedbackDiv>
)
}

View File

@@ -142,7 +142,7 @@ const DataDetail: React.FC = () => {
{
type: 'action',
label: '删除',
className: 'text-danger hover:text-red-600',
className: 'text-danger btn-deleted',
level: 'link',
size: 'sm',
actionType: 'ajax',

View File

@@ -87,7 +87,7 @@ const DataDetail: React.FC = () => {
{
type: 'action',
label: '删除',
className: 'text-danger hover:text-red-600',
className: 'text-danger btn-deleted',
level: 'link',
size: 'sm',
actionType: 'ajax',

View File

@@ -50,12 +50,20 @@ const Knowledge: React.FC = () => {
type: 'input-text',
name: 'name',
label: '名称',
required: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
required: true,
},
{
type: 'select',
name: 'strategy',
label: '类型',
value: 'Cosine',
required: true,
options: [
{
label: '文本',
@@ -77,6 +85,11 @@ const Knowledge: React.FC = () => {
{
name: 'name',
label: '名称',
width: 200,
},
{
name: 'description',
label: '描述',
},
{
label: '类型',
@@ -99,8 +112,41 @@ const Knowledge: React.FC = () => {
{
type: 'operation',
label: '操作',
width: 150,
width: 200,
buttons: [
{
type: 'action',
label: '更新',
level: 'link',
size: 'sm',
actionType: 'dialog',
dialog: {
title: '更新描述',
body: {
debug: commonInfo.debug,
type: 'form',
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/update_description`,
dataType: 'form',
},
mode: 'normal',
body: [
{
type: 'hidden',
name: "id",
// value: '${id}',
},
{
type: 'textarea',
name: 'description',
label: '描述',
required: true,
}
]
}
}
},
{
type: 'action',
label: '详情',
@@ -142,7 +188,7 @@ const Knowledge: React.FC = () => {
{
type: 'action',
label: '删除',
className: 'text-danger hover:text-red-600',
className: 'text-danger btn-deleted',
level: 'link',
size: 'sm',
actionType: 'ajax',

View File

@@ -169,7 +169,7 @@ const tableDetailDialog = (variable: string, targetList: any) => {
const overviewYarnJob = (cluster: string, search: string, queue: string | undefined, yarnQueue: string) => {
return {
className: 'text-base leading-none',
className: 'text-sm leading-none',
type: 'table-view',
border: false,
padding: '0 10px 0 15px',

View File

@@ -91,7 +91,7 @@ function Table() {
columns: [
{
label: 'Flink job id',
width: 195,
width: 200,
fixed: 'left',
type: 'wrapper',
size: 'none',

View File

@@ -99,7 +99,7 @@ function Version() {
columns: [
{
label: 'Flink job id',
width: 195,
width: 200,
fixed: 'left',
type: 'wrapper',
size: 'none',

View File

@@ -1,16 +1,16 @@
import React from 'react'
import {useLocation, useParams} from 'react-router'
import {
amisRender,
commonInfo,
crudCommonOptions,
paginationCommonOptions,
yarnCrudColumns,
yarnQueueCrud,
amisRender,
commonInfo,
crudCommonOptions,
paginationCommonOptions,
yarnCrudColumns,
yarnQueueCrud,
} from '../../util/amis.tsx'
const Yarn: React.FC = () => {
const {clusters, queue, search} = useParams()
const {clusters, queues, search} = useParams()
const location = useLocation()
return (
<div key={location.key} className="hudi-yarn">
@@ -27,7 +27,7 @@ const Yarn: React.FC = () => {
type: 'tpl',
tpl: '<span class="font-bold text-xl">集群资源</span>',
},
yarnQueueCrud(clusters, queue),
yarnQueueCrud(clusters, queues),
{
type: 'tpl',
tpl: '<span class="font-bold text-xl">集群任务</span>',

View File

@@ -1,19 +1,21 @@
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 {values} from 'licia'
import {Navigate, type RouteObject} from 'react-router'
import Conversation from './pages/ai/Conversation.tsx'
import Feedback from './pages/ai/feedback/Feedback.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'
@@ -28,9 +30,8 @@ import Tool from './pages/overview/Tool.tsx'
import Version from './pages/overview/Version.tsx'
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'
import {commonInfo} from './util/amis.tsx'
export const routes: RouteObject[] = [
{
@@ -58,7 +59,7 @@ export const routes: RouteObject[] = [
Component: Version,
},
{
path: 'yarn/:clusters/:queue/:search?',
path: 'yarn/:clusters/:queues/:search?',
Component: Yarn,
},
{
@@ -146,12 +147,12 @@ export const menus = {
icon: <SunOutlined/>,
},
{
path: `/yarn/${commonInfo.clusters.sync_names()}/root/Sync`,
path: `/yarn/${commonInfo.clusters.sync_names()}/default/Sync`,
name: '同步集群',
icon: <SyncOutlined/>,
},
{
path: `/yarn/${commonInfo.clusters.compaction_names()}/default/Compaction`,
path: `/yarn/${commonInfo.clusters.compaction_names()}/${values(commonInfo.clusters.compaction).join(",")}/Compaction`,
name: '压缩集群',
icon: <SyncOutlined/>,
},
@@ -202,7 +203,7 @@ export const menus = {
},
{
path: '/ai/feedback',
name: '智慧报',
name: '智慧报',
icon: <CheckSquareOutlined/>,
},
{

View File

@@ -10,8 +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',
// baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web',
baseAiUrl: 'http://localhost:8080',
baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web',
// baseAiUrl: 'http://localhost:8080',
authorizationHeaders: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
'Content-Type': 'application/json',
@@ -281,6 +281,7 @@ export function crudCommonOptions() {
resizable: false,
syncLocation: false,
silentPolling: true,
columnsTogglable: false,
}
}
@@ -903,7 +904,7 @@ export function simpleYarnDialog(cluster: string, title: string, filterField: st
type: 'crud',
api: {
method: 'get',
url: `\${base}/yarn/job_list`,
url: `${commonInfo.baseUrl}/yarn/job_list`,
data: {
clusters: `${cluster}`,
page: '${page|default:undefined}',

View File

@@ -1,5 +1,7 @@
server:
port: 0
compression:
enabled: true
spring:
application:
name: service-web