20 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
37 changed files with 1448 additions and 1894 deletions

View File

@@ -1,11 +1,11 @@
CREATE TABLE `service_ai_feedback` CREATE TABLE `service_ai_feedback`
( (
`id` bigint NOT NULL, `id` bigint NOT NULL,
`source` longtext NOT NULL, `source` longtext NOT NULL,
`analysis_short` longtext, `conclusion` longtext,
`analysis` longtext, `analysis` longtext,
`pictures` longtext, `pictures` longtext,
`status` varchar(50) NOT NULL DEFAULT 'ANALYSIS_PROCESSING', `status` varchar(50) NOT NULL DEFAULT 'ANALYSIS_PROCESSING',
`created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP `modified_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) DEFAULT CHARSET = utf8mb4; ) DEFAULT CHARSET = utf8mb4;

View File

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

View File

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

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

View File

@@ -45,12 +45,28 @@ public class FeedbackController {
feedbackService.remove(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 @Data
public static final class CreateItem { public static final class CreateItem {
private String source; private String source;
private ImmutableList<Long> pictures; private ImmutableList<Long> pictures;
} }
@Data
public static final class ConcludeItem {
private Long id;
private String conclusion;
}
@Data @Data
public static final class ListItem { public static final class ListItem {
private Long id; private Long id;
@@ -58,7 +74,7 @@ public class FeedbackController {
private ImmutableList<String> pictures; private ImmutableList<String> pictures;
private Feedback.Status status; private Feedback.Status status;
private String analysis; private String analysis;
private String analysisShort; private String conclusion;
public ListItem(FileStoreProperties fileStoreProperties, Feedback feedback) { public ListItem(FileStoreProperties fileStoreProperties, Feedback feedback) {
this.id = feedback.getId(); this.id = feedback.getId();
@@ -67,7 +83,7 @@ public class FeedbackController {
.collect(id -> StrUtil.format("{}/upload/download/{}", fileStoreProperties.getDownloadPrefix(), id)); .collect(id -> StrUtil.format("{}/upload/download/{}", fileStoreProperties.getDownloadPrefix(), id));
this.status = feedback.getStatus(); this.status = feedback.getStatus();
this.analysis = feedback.getAnalysis(); this.analysis = feedback.getAnalysis();
this.analysisShort = feedback.getAnalysisShort(); this.conclusion = feedback.getConclusion();
} }
} }
} }

View File

@@ -37,9 +37,18 @@ public class KnowledgeBaseController {
@PostMapping("add") @PostMapping("add")
public void add( public void add(
@RequestParam("name") String name, @RequestParam("name") String name,
@RequestParam("description") String description,
@RequestParam("strategy") String strategy @RequestParam("strategy") String strategy
) throws ExecutionException, InterruptedException { ) 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") @GetMapping("name")

View File

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

View File

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

View File

@@ -12,5 +12,6 @@ import org.eclipse.collections.api.factory.Lists;
@Data @Data
public class FeedbackContext { public class FeedbackContext {
private Feedback feedback; private Feedback feedback;
private String optimizedSource;
private List<String> pictureDescriptions = Lists.mutable.empty(); private List<String> pictureDescriptions = Lists.mutable.empty();
} }

View File

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

View File

@@ -26,12 +26,12 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class FeedbackService { public class FeedbackService {
public static final String FEEDBACK_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_feedback"; public static final String FEEDBACK_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_feedback";
public static final String[] FEEDBACK_COLUMNS = new String[]{"id", "source", "analysis_short", "analysis", "pictures", "status", "created_time", "modified_time"}; 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) -> { private static final RowMapper<Feedback> feedbackMapper = (rs, row) -> {
Feedback feedback = new Feedback(); Feedback feedback = new Feedback();
feedback.setId(rs.getLong(1)); feedback.setId(rs.getLong(1));
feedback.setSource(rs.getString(2)); feedback.setSource(rs.getString(2));
feedback.setAnalysisShort(rs.getString(3)); feedback.setConclusion(rs.getString(3));
feedback.setAnalysis(rs.getString(4)); feedback.setAnalysis(rs.getString(4));
feedback.setPictureIds( feedback.setPictureIds(
StrUtil.isBlank(rs.getString(5)) StrUtil.isBlank(rs.getString(5))
@@ -92,20 +92,32 @@ public class FeedbackService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateAnalysis(Long id, String analysis, String analysisShort) { public void updateAnalysis(Long id, String analysis) {
Assert.notNull(id, "ID cannot be null"); Assert.notNull(id, "ID cannot be null");
template.update( template.update(
SqlBuilder.update(FEEDBACK_TABLE_NAME) SqlBuilder.update(FEEDBACK_TABLE_NAME)
.set("analysis", "?") .set("analysis", "?")
.addSet("analysis_short", "?")
.whereEq("id", "?") .whereEq("id", "?")
.precompileSql(), .precompileSql(),
analysis, analysis,
analysisShort,
id 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) @Transactional(rollbackFor = Exception.class)
public void updateStatus(Long id, Feedback.Status status) { public void updateStatus(Long id, Feedback.Status status) {
Assert.notNull(id, "ID cannot be null"); Assert.notNull(id, "ID cannot be null");
@@ -140,4 +152,9 @@ public class FeedbackService {
.build() .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 com.lanyuanxiaoyao.service.common.Constants;
import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantClient;
import io.qdrant.client.grpc.Collections; import io.qdrant.client.grpc.Collections;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -32,14 +31,16 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class KnowledgeBaseService { public class KnowledgeBaseService {
public static final String KNOWLEDGE_TABLE_NAME = Constants.DATABASE_NAME + ".service_ai_knowledge"; 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) -> { private static final RowMapper<Knowledge> knowledgeMapper = (rs, row) -> {
Knowledge knowledge = new Knowledge(); Knowledge knowledge = new Knowledge();
knowledge.setId(rs.getLong(1)); knowledge.setId(rs.getLong(1));
knowledge.setVectorSourceId(rs.getLong(2)); knowledge.setVectorSourceId(rs.getLong(2));
knowledge.setName(rs.getString(3)); knowledge.setName(rs.getString(3));
knowledge.setStrategy(rs.getString(4)); knowledge.setDescription(rs.getString(4));
knowledge.setCreatedTime(rs.getTimestamp(5).getTime()); knowledge.setStrategy(rs.getString(5));
knowledge.setModifiedTime(rs.getTimestamp(6).getTime()); knowledge.setCreatedTime(rs.getTimestamp(6).getTime());
knowledge.setModifiedTime(rs.getTimestamp(7).getTime());
return knowledge; return knowledge;
}; };
private final JdbcTemplate template; private final JdbcTemplate template;
@@ -56,7 +57,7 @@ public class KnowledgeBaseService {
public Knowledge get(Long id) { public Knowledge get(Long id) {
return template.queryForObject( return template.queryForObject(
SqlBuilder.select("id", "vector_source_id", "name", "strategy", "created_time", "modified_time") SqlBuilder.select(KNOWLEDGE_COLUMNS)
.from(KNOWLEDGE_TABLE_NAME) .from(KNOWLEDGE_TABLE_NAME)
.whereEq("id", "?") .whereEq("id", "?")
.precompileSql(), .precompileSql(),
@@ -66,7 +67,7 @@ public class KnowledgeBaseService {
} }
@Transactional(rollbackFor = Exception.class) @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( Integer count = template.queryForObject(
SqlBuilder.select("count(*)") SqlBuilder.select("count(*)")
.from(KNOWLEDGE_TABLE_NAME) .from(KNOWLEDGE_TABLE_NAME)
@@ -82,13 +83,14 @@ public class KnowledgeBaseService {
long id = SnowflakeId.next(); long id = SnowflakeId.next();
long vectorSourceId = SnowflakeId.next(); long vectorSourceId = SnowflakeId.next();
template.update( 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() .values()
.addValue("?", "?", "?", "?") .addValue("?", "?", "?", "?", "?")
.precompileSql(), .precompileSql(),
id, id,
vectorSourceId, vectorSourceId,
name, name,
description,
strategy strategy
); );
client.createCollectionAsync( client.createCollectionAsync(
@@ -100,6 +102,18 @@ public class KnowledgeBaseService {
).get(); ).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) { public String getName(Long id) {
return template.queryForObject( return template.queryForObject(
SqlBuilder.select("name") SqlBuilder.select("name")
@@ -113,7 +127,7 @@ public class KnowledgeBaseService {
public ImmutableList<KnowledgeVO> list() { public ImmutableList<KnowledgeVO> list() {
return template.query( return template.query(
SqlBuilder.select("id", "vector_source_id", "name", "strategy", "created_time", "modified_time") SqlBuilder.select(KNOWLEDGE_COLUMNS)
.from(KNOWLEDGE_TABLE_NAME) .from(KNOWLEDGE_TABLE_NAME)
.orderByDesc("created_time") .orderByDesc("created_time")
.build(), .build(),
@@ -127,6 +141,7 @@ public class KnowledgeBaseService {
vo.setId(knowledge.getId()); vo.setId(knowledge.getId());
vo.setVectorSourceId(knowledge.getVectorSourceId()); vo.setVectorSourceId(knowledge.getVectorSourceId());
vo.setName(knowledge.getName()); vo.setName(knowledge.getName());
vo.setDescription(knowledge.getDescription());
vo.setPoints(info.getPointsCount()); vo.setPoints(info.getPointsCount());
vo.setSegments(info.getSegmentsCount()); vo.setSegments(info.getSegmentsCount());
vo.setStatus(info.getStatus().name()); vo.setStatus(info.getStatus().name());
@@ -165,7 +180,7 @@ public class KnowledgeBaseService {
String text, String text,
Integer limit, Integer limit,
Double threshold Double threshold
) throws ExecutionException, InterruptedException, IOException { ) throws ExecutionException, InterruptedException {
Knowledge knowledge = get(id); Knowledge knowledge = get(id);
Boolean exists = client.collectionExistsAsync(String.valueOf(knowledge.getVectorSourceId())).get(); Boolean exists = client.collectionExistsAsync(String.valueOf(knowledge.getVectorSourceId())).get();
if (!exists) { if (!exists) {
@@ -182,13 +197,6 @@ public class KnowledgeBaseService {
.similarityThreshold(threshold) .similarityThreshold(threshold)
.build() .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) return Lists.immutable.ofAll(documents)
.collect(Document::getText); .collect(Document::getText);
} }

View File

@@ -19,8 +19,6 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.document.Document; import org.springframework.ai.document.Document;
import org.springframework.ai.document.DocumentReader; import org.springframework.ai.document.DocumentReader;
@@ -42,12 +40,12 @@ import org.springframework.core.io.PathResource;
@Slf4j @Slf4j
@LiteflowComponent @LiteflowComponent
public class EmbeddingNodes { public class EmbeddingNodes {
private final ChatClient chatClient; private final ChatClient.Builder chatClientBuilder;
private final QdrantClient qdrantClient; private final QdrantClient qdrantClient;
private final EmbeddingModel embeddingModel; private final EmbeddingModel embeddingModel;
public EmbeddingNodes(@Qualifier("chat") ChatClient.Builder builder, VectorStore vectorStore, 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.qdrantClient = (QdrantClient) vectorStore.getNativeClient().orElseThrow();
this.embeddingModel = embeddingModel; this.embeddingModel = embeddingModel;
} }
@@ -152,9 +150,11 @@ public class EmbeddingNodes {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "qa_split", nodeName = "使用Q/A格式分段", nodeType = NodeTypeEnum.COMMON) @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "qa_split", nodeName = "使用Q/A格式分段", nodeType = NodeTypeEnum.COMMON)
public void qaSplit(NodeComponent node) { public void qaSplit(NodeComponent node) {
EmbeddingContext context = node.getContextBean(EmbeddingContext.class); EmbeddingContext context = node.getContextBean(EmbeddingContext.class);
// language=TEXT
context.getDocuments().addAll(llmSplit( context.getDocuments().addAll(llmSplit(
""" """
对用户输入的文本,生成多组高质量的问答对。请遵循以下指南: 对用户输入的文本,生成多组高质量的问答对。请遵循以下指南:
1. 问题部分: 1. 问题部分:
为同一个主题创建尽可能多的不同表述的问题,确保问题的多样性。 为同一个主题创建尽可能多的不同表述的问题,确保问题的多样性。
每个问题应考虑用户可能的多种问法,例如: 每个问题应考虑用户可能的多种问法,例如:
@@ -169,7 +169,7 @@ public class EmbeddingNodes {
答案应直接基于给定文本,确保准确性和一致性。 答案应直接基于给定文本,确保准确性和一致性。
包含相关的细节,如日期、名称、职位等具体信息,必要时提供背景信息以增强理解。 包含相关的细节,如日期、名称、职位等具体信息,必要时提供背景信息以增强理解。
3. 格式: 3. 格式:
使用"问:"标记问题集合的开始,所有问题应在一个段落内,问题之间用空格分隔 使用"问:"标记问题的开始,问题文本应在一个段落内完成
使用"答:"标记答案的开始,答案应清晰分段,便于阅读。 使用"答:"标记答案的开始,答案应清晰分段,便于阅读。
问答对之间用“---”分隔,以提高可读性。 问答对之间用“---”分隔,以提高可读性。
4. 内容要求: 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) { 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) .system(prompt)
.user(content) .user(content)
.call() .call()

View File

@@ -100,12 +100,12 @@ public class FeedbackNodes {
} }
} }
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "feedback_suggest", nodeName = "大模型建议", nodeType = NodeTypeEnum.COMMON) @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "optimize_source", nodeName = "报障信息优化", nodeType = NodeTypeEnum.COMMON)
public void suggest(NodeComponent node) { public void optimizeSource(NodeComponent node) {
FeedbackContext context = node.getContextBean(FeedbackContext.class); FeedbackContext context = node.getContextBean(FeedbackContext.class);
Feedback feedback = context.getFeedback(); Feedback feedback = context.getFeedback();
ChatClient client = chatClientBuilder.build(); String optimizedSource = chatClientBuilder.build()
String description = client.prompt() .prompt()
// language=TEXT // language=TEXT
.system(""" .system("""
你是一名专业的IT系统运维工程师对于用户输入的关于系统的报障信息你会严格遵循以下步骤进行处理 你是一名专业的IT系统运维工程师对于用户输入的关于系统的报障信息你会严格遵循以下步骤进行处理
@@ -140,42 +140,64 @@ public class FeedbackNodes {
重写的故障描述,以结构化段落呈现,涵盖问题概述、详细症状、重现步骤和相关环境。 重写的故障描述,以结构化段落呈现,涵盖问题概述、详细症状、重现步骤和相关环境。
输出将使用中性、客观语言,避免任何个人意见或建议,以确保报告专注于事实描述。 输出将使用中性、客观语言,避免任何个人意见或建议,以确保报告专注于事实描述。
""") """)
.call() .user(StrUtil.format(
.content(); """
Assert.notBlank(description, "Description cannot be blank");
String analysis = client.prompt()
.system("""
你是一名专业的IT系统运维工程师对于用户输入的报障信息你会给出专业的意见
""")
.user(StrUtil.format("""
[故障描述] [故障描述]
{} {}
[相关截图] [相关截图]
{} {}
""", """,
description, feedback.getSource(),
ObjectUtil.isEmpty(context.getPictureDescriptions()) ? "" : StrUtil.join(",", context.getPictureDescriptions()) ObjectUtil.isEmpty(context.getPictureDescriptions()) ? "" : StrUtil.join(",", context.getPictureDescriptions())
)) ))
.call() .call()
.content(); .content();
feedback.setAnalysis(analysis); if (StrUtil.isBlank(optimizedSource)) {
Assert.notBlank(description, "Analysis cannot be blank"); log.warn("Optimized source is blank");
String analysisShort = client.prompt() }
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(""" .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) .user(analysis)
.call() .call()
.content(); .content();
feedback.setAnalysisShort(analysisShort); feedback.setConclusion(StrUtil.trim(conclusion));
} }
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "feedback_save", nodeName = "保存分析内容", nodeType = NodeTypeEnum.COMMON) @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "feedback_save", nodeName = "保存分析内容", nodeType = NodeTypeEnum.COMMON)
public void saveFeedback(NodeComponent node) { public void saveFeedback(NodeComponent node) {
FeedbackContext context = node.getContextBean(FeedbackContext.class); FeedbackContext context = node.getContextBean(FeedbackContext.class);
Feedback feedback = context.getFeedback(); Feedback feedback = context.getFeedback();
feedbackService.updateAnalysis(feedback.getId(), feedback.getAnalysis(), feedback.getAnalysisShort()); feedbackService.updateAnalysis(feedback.getId(), feedback.getAnalysis());
feedbackService.updateConclusion(feedback.getId(), feedback.getConclusion());
feedbackService.updateStatus(feedback.getId(), Feedback.Status.ANALYSIS_SUCCESS); feedbackService.updateStatus(feedback.getId(), Feedback.Status.ANALYSIS_SUCCESS);
} }
} }

View File

@@ -44,7 +44,7 @@ public class ChartTool {
""") String request """) String request
) { ) {
log.info("Enter method: mermaid[request]. request:{}", 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(); ChatClient client = builder.build();
return client.prompt() return client.prompt()
// language=TEXT // language=TEXT

View File

@@ -1,3 +1,6 @@
server:
compression:
enabled: true
spring: spring:
application: application:
name: service-ai-web name: service-ai-web
@@ -36,4 +39,4 @@ spring:
liteflow: liteflow:
rule-source: liteflow.xml rule-source: liteflow.xml
print-banner: false print-banner: false
check-node-exists: false check-node-exists: false

View File

@@ -29,6 +29,7 @@
feedback_check_if_picture_needed, feedback_check_if_picture_needed,
image_read image_read
), ),
optimize_source,
feedback_suggest, feedback_suggest,
feedback_save feedback_save
) )

View File

@@ -1,3 +1,4 @@
<!--suppress CssUnknownTarget, HtmlUnknownTarget -->
<!doctype html> <!doctype html>
<html lang="zh"> <html lang="zh">
<head> <head>
@@ -13,6 +14,15 @@
margin: 0; margin: 0;
padding: 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> </style>
</head> </head>
<body> <body>

View File

@@ -10,17 +10,18 @@
}, },
"dependencies": { "dependencies": {
"@ant-design/icons": "^6.0.0", "@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", "@ant-design/x": "^1.4.0",
"@echofly/fetch-event-source": "^3.0.2", "@echofly/fetch-event-source": "^3.0.2",
"@fortawesome/fontawesome-free": "^6.7.2", "@fortawesome/fontawesome-free": "^6.7.2",
"@lightenna/react-mermaid-diagram": "^1.0.20", "@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", "ahooks": "^3.8.5",
"amis": "^6.12.0", "amis": "^6.12.0",
"antd": "^5.25.3", "antd": "^5.26.1",
"axios": "^1.9.0", "axios": "^1.10.0",
"chart.js": "^4.4.9", "chart.js": "^4.5.0",
"echarts-for-react": "^3.0.2", "echarts-for-react": "^3.0.2",
"licia": "^1.48.0", "licia": "^1.48.0",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
@@ -29,18 +30,18 @@
"react-chartjs-2": "^5.3.0", "react-chartjs-2": "^5.3.0",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-markdown": "^10.1.0", "react-markdown": "^10.1.0",
"react-router": "^7.6.1", "react-router": "^7.6.2",
"styled-components": "^6.1.18" "styled-components": "^6.1.18",
"zustand": "^5.0.5"
}, },
"devDependencies": { "devDependencies": {
"@types/markdown-it": "^14.1.2", "@types/markdown-it": "^14.1.2",
"@types/react": "^18.3.23", "@types/react": "^18.3.23",
"@types/react-dom": "^18.3.7", "@types/react-dom": "^18.3.7",
"@vitejs/plugin-react-swc": "^3.10.0", "@vitejs/plugin-react-swc": "^3.10.2",
"globals": "^16.2.0", "globals": "^16.2.0",
"sass": "^1.89.0", "sass": "^1.89.2",
"typescript": "~5.8.3", "typescript": "~5.8.3",
"typescript-eslint": "^8.33.0",
"vite": "^6.3.5", "vite": "^6.3.5",
"vite-plugin-javascript-obfuscator": "^3.1.0" "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 {createRoot} from 'react-dom/client'
import {createHashRouter, RouterProvider} from 'react-router' import {createHashRouter, RouterProvider} from 'react-router'
import './index.scss'
import './components/Registry.ts' import './components/Registry.ts'
import {routes} from './route.tsx' import {routes} from './route.tsx'

View File

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

View File

@@ -1,128 +1,486 @@
import MarkdownRender from '../util/Markdown.tsx' import {DeleteFilled, EditFilled, PlusCircleFilled, SaveFilled} from '@ant-design/icons'
import {useState} from 'react' 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 FlowableDiv = styled.div`
const markdownText = `### Hello height: 93vh;
world .toolbar {
tony z-index: 999;
jenny position: absolute;
}
\`\`\`javascript .node-card {
console.log('hello') cursor: grab;
\`\`\`
\`\`\`mermaid .card-container {
graph TD cursor: default;
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: '水果店周销量数据'
}
} }
} }
} `
\`\`\`
\`\`\`chartjs type AmisNodeType = 'normal' | 'start' | 'end'
{
type: 'bar', const AmisNode = (
data: { props: NodeProps,
labels: ['苹果', '香蕉', '橙子', '葡萄', '菠萝'], type: AmisNodeType,
datasets: [{ name: String,
label: '水果销量', description?: String,
data: [43, 32, 56, 29, 38], columnSchema?: Schema[],
}] ) => {
}, const {id, data} = props
options: { const {getDataById, removeNode, editNode} = data
plugins: { return (
legend: { <div className="p-1 w-64">
position: 'top', <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 const StartAmisNode = (props: NodeProps) => AmisNode(
{ props,
grid: { top: 8, right: 8, bottom: 24, left: 36 }, 'start',
xAxis: { '开始节点',
type: 'category', '定义输入变量',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], [
}, {
yAxis: { type: 'input-kvs',
type: 'value', name: 'fields',
}, addButtonText: '新增入参',
series: [ draggable: false,
{ keyItem: {
data: [820, 932, 901, 934, 1290, 1330, 1320], label: '参数名称',
type: 'line',
smooth: true,
}, },
], valueItems: [
tooltip: { {
trigger: 'axis', 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 const initialNodes: Node[] = [
{ {
grid: { top: 8, right: 8, bottom: 24, left: 36 }, id: 'BMFP3Eov94',
xAxis: { type: 'start-amis-node',
type: 'category', position: {x: 10, y: 100},
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], data: {},
}, },
yAxis: { {
type: 'value', id: 'PYK8LjduQ1',
}, type: 'end-amis-node',
series: [ position: {x: 500, y: 100},
{ data: {},
data: [820, 932, 901, 934, 1290, 1330, 1320], },
type: 'line', ]
smooth: true, const initialEdges: Edge[] = []
},
], const useStore = create<{
tooltip: { data: Record<string, any>,
trigger: 'axis', 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() { 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 ( return (
<> <FlowableDiv>
<button onClick={() => setValue('hahaha\n' + markdownText)}>Button</button> {contextHolder}
<MarkdownRender content={value}/> <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 {ClearOutlined, UserOutlined} from '@ant-design/icons'
import {Bubble, Sender, useXAgent, useXChat, Welcome} from '@ant-design/x' import {Bubble, Sender, useXAgent, useXChat, Welcome} from '@ant-design/x'
import {fetchEventSource} from '@echofly/fetch-event-source' import {fetchEventSource} from '@echofly/fetch-event-source'
import {useUnmount} from 'ahooks'
import {Button, Collapse, Flex, Typography} from 'antd' import {Button, Collapse, Flex, Typography} from 'antd'
import {isStrBlank, trim} from 'licia' import {isStrBlank, trim} from 'licia'
import {useRef, useState} from 'react' import {useRef, useState} from 'react'
@@ -40,6 +41,11 @@ function Conversation() {
const abortController = useRef<AbortController | null>(null) const abortController = useRef<AbortController | null>(null)
const [input, setInput] = useState<string>('') const [input, setInput] = useState<string>('')
useUnmount(() => {
console.log('Page Unmount')
abortController.current?.abort()
})
const [agent] = useXAgent<ChatMessage>({ const [agent] = useXAgent<ChatMessage>({
request: async (info, callbacks) => { request: async (info, callbacks) => {
await fetchEventSource(`${commonInfo.baseAiUrl}/chat/async`, { await fetchEventSource(`${commonInfo.baseAiUrl}/chat/async`, {
@@ -55,6 +61,7 @@ function Conversation() {
}) })
}, },
onclose: () => callbacks.onSuccess([]), onclose: () => callbacks.onSuccess([]),
onerror: error => callbacks.onError(error),
}) })
}, },
}) })

View File

@@ -4,6 +4,8 @@ import {amisRender, commonInfo, crudCommonOptions, mappingField, mappingItem} fr
const FeedbackDiv = styled.div` const FeedbackDiv = styled.div`
.feedback-list-images { .feedback-list-images {
margin-top: 10px;
.antd-Img-container { .antd-Img-container {
width: 32px; width: 32px;
height: 32px; height: 32px;
@@ -84,17 +86,24 @@ const Feedback: React.FC = () => {
width: 150, width: 150,
}, },
{ {
name: 'source',
label: '故障描述', label: '故障描述',
}, type: 'flex',
{ direction: 'column',
name: 'pictures', items: [
label: '相关截图', {
width: 200, type: 'tpl',
className: 'feedback-list-images', className: 'white-space-pre',
type: 'images', tpl: '${source}',
enlargeAble: true, },
enlargeWithGallary: true, {
className: 'feedback-list-images',
type: 'images',
enlargeAble: true,
enlargeWithGallary: true,
source: '${pictures}',
showToolbar: true,
},
],
}, },
{ {
label: '状态', label: '状态',
@@ -105,12 +114,110 @@ const Feedback: React.FC = () => {
{ {
type: 'operation', type: 'operation',
label: '操作', label: '操作',
width: 150, width: 200,
buttons: [ 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', type: 'action',
label: '删除', label: '删除',
className: 'text-danger hover:text-red-600', className: 'text-danger btn-deleted',
level: 'link', level: 'link',
size: 'sm', size: 'sm',
actionType: 'ajax', actionType: 'ajax',
@@ -121,8 +228,8 @@ const Feedback: React.FC = () => {
id: '${id}', id: '${id}',
}, },
}, },
confirmText: '确认删除',
confirmTitle: '删除', confirmTitle: '删除',
confirmText: '删除后将无法恢复,确认删除?',
}, },
], ],
}, },

View File

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

View File

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

View File

@@ -50,12 +50,20 @@ const Knowledge: React.FC = () => {
type: 'input-text', type: 'input-text',
name: 'name', name: 'name',
label: '名称', label: '名称',
required: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
required: true,
}, },
{ {
type: 'select', type: 'select',
name: 'strategy', name: 'strategy',
label: '类型', label: '类型',
value: 'Cosine', value: 'Cosine',
required: true,
options: [ options: [
{ {
label: '文本', label: '文本',
@@ -77,6 +85,11 @@ const Knowledge: React.FC = () => {
{ {
name: 'name', name: 'name',
label: '名称', label: '名称',
width: 200,
},
{
name: 'description',
label: '描述',
}, },
{ {
label: '类型', label: '类型',
@@ -99,8 +112,41 @@ const Knowledge: React.FC = () => {
{ {
type: 'operation', type: 'operation',
label: '操作', label: '操作',
width: 150, width: 200,
buttons: [ 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', type: 'action',
label: '详情', label: '详情',
@@ -142,7 +188,7 @@ const Knowledge: React.FC = () => {
{ {
type: 'action', type: 'action',
label: '删除', label: '删除',
className: 'text-danger hover:text-red-600', className: 'text-danger btn-deleted',
level: 'link', level: 'link',
size: 'sm', size: 'sm',
actionType: 'ajax', 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) => { const overviewYarnJob = (cluster: string, search: string, queue: string | undefined, yarnQueue: string) => {
return { return {
className: 'text-base leading-none', className: 'text-sm leading-none',
type: 'table-view', type: 'table-view',
border: false, border: false,
padding: '0 10px 0 15px', padding: '0 10px 0 15px',

View File

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

View File

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

View File

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

View File

@@ -1,19 +1,21 @@
import { import {
CheckSquareOutlined, CheckSquareOutlined,
CloudOutlined, CloudOutlined,
ClusterOutlined, ClusterOutlined,
CompressOutlined, CompressOutlined,
DatabaseOutlined, DatabaseOutlined,
InfoCircleOutlined, InfoCircleOutlined,
OpenAIOutlined, OpenAIOutlined,
QuestionOutlined, QuestionOutlined,
SunOutlined, SunOutlined,
SyncOutlined, SyncOutlined,
TableOutlined, TableOutlined,
ToolOutlined, ToolOutlined,
} from '@ant-design/icons' } from '@ant-design/icons'
import {values} from 'licia'
import {Navigate, type RouteObject} from 'react-router' import {Navigate, type RouteObject} from 'react-router'
import Conversation from './pages/ai/Conversation.tsx' import Conversation from './pages/ai/Conversation.tsx'
import Feedback from './pages/ai/feedback/Feedback.tsx'
import DataDetail from './pages/ai/knowledge/DataDetail.tsx' import DataDetail from './pages/ai/knowledge/DataDetail.tsx'
import DataImport from './pages/ai/knowledge/DataImport.tsx' import DataImport from './pages/ai/knowledge/DataImport.tsx'
import DataSegment from './pages/ai/knowledge/DataSegment.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 Version from './pages/overview/Version.tsx'
import Yarn from './pages/overview/Yarn.tsx' import Yarn from './pages/overview/Yarn.tsx'
import YarnCluster from './pages/overview/YarnCluster.tsx' import YarnCluster from './pages/overview/YarnCluster.tsx'
import {commonInfo} from './util/amis.tsx'
import Test from './pages/Test.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[] = [ export const routes: RouteObject[] = [
{ {
@@ -58,7 +59,7 @@ export const routes: RouteObject[] = [
Component: Version, Component: Version,
}, },
{ {
path: 'yarn/:clusters/:queue/:search?', path: 'yarn/:clusters/:queues/:search?',
Component: Yarn, Component: Yarn,
}, },
{ {
@@ -146,12 +147,12 @@ export const menus = {
icon: <SunOutlined/>, icon: <SunOutlined/>,
}, },
{ {
path: `/yarn/${commonInfo.clusters.sync_names()}/root/Sync`, path: `/yarn/${commonInfo.clusters.sync_names()}/default/Sync`,
name: '同步集群', name: '同步集群',
icon: <SyncOutlined/>, icon: <SyncOutlined/>,
}, },
{ {
path: `/yarn/${commonInfo.clusters.compaction_names()}/default/Compaction`, path: `/yarn/${commonInfo.clusters.compaction_names()}/${values(commonInfo.clusters.compaction).join(",")}/Compaction`,
name: '压缩集群', name: '压缩集群',
icon: <SyncOutlined/>, icon: <SyncOutlined/>,
}, },
@@ -202,7 +203,7 @@ export const menus = {
}, },
{ {
path: '/ai/feedback', path: '/ai/feedback',
name: '智慧报', name: '智慧报',
icon: <CheckSquareOutlined/>, icon: <CheckSquareOutlined/>,
}, },
{ {

View File

@@ -281,6 +281,7 @@ export function crudCommonOptions() {
resizable: false, resizable: false,
syncLocation: false, syncLocation: false,
silentPolling: true, silentPolling: true,
columnsTogglable: false,
} }
} }

View File

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