初始化

This commit is contained in:
2026-02-22 18:56:10 +08:00
commit 26677972a6
3112 changed files with 255972 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package tech.easyflow.ai.config;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;
import tech.easyflow.ai.mapper.*;
import tech.easyflow.common.util.SpringContextUtil;
import tech.easyflow.common.dict.DictManager;
import tech.easyflow.common.dict.loader.DbDataLoader;
import javax.annotation.Resource;
@Configuration
public class AiDictAutoConfig {
@Resource
private WorkflowMapper workflowMapper;
@Resource
private WorkflowCategoryMapper workflowCategoryMapper;
@Resource
private BotCategoryMapper botCategoryMapper;
@Resource
private ResourceCategoryMapper resourceCategoryMapper;
@Resource
private DocumentCollectionCategoryMapper documentCollectionCategoryMapper;
@EventListener(ApplicationReadyEvent.class)
public void onApplicationStartup() {
DictManager dictManager = SpringContextUtil.getBean(DictManager.class);
dictManager.putLoader(new DbDataLoader<>("aiWorkFlow", workflowMapper, "id", "title", null, null, false));
dictManager.putLoader(new DbDataLoader<>("aiWorkFlowCategory", workflowCategoryMapper, "id", "category_name", null, null, false));
dictManager.putLoader(new DbDataLoader<>("aiBotCategory", botCategoryMapper, "id", "category_name", null, null, false));
dictManager.putLoader(new DbDataLoader<>("aiResourceCategory", resourceCategoryMapper, "id", "category_name", null, null, false));
dictManager.putLoader(new DbDataLoader<>("aiDocumentCollectionCategory", documentCollectionCategoryMapper, "id", "category_name", null, null, false));
}
}

View File

@@ -0,0 +1,35 @@
package tech.easyflow.ai.config;
import com.easyagents.engine.es.ESConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class AiEsConfig extends ESConfig {
@Value("${rag.searcher.elastic.host}")
@Override
public void setHost(String host) {
super.setHost(host);
}
@Value("${rag.searcher.elastic.userName}")
@Override
public void setUserName(String userName) {
super.setUserName(userName);
}
@Value("${rag.searcher.elastic.password}")
@Override
public void setPassword(String password) {
super.setPassword(password);
}
@Value("${rag.searcher.elastic.indexName}")
@Override
public void setIndexName(String indexName) {
super.setIndexName(indexName);
}
}

View File

@@ -0,0 +1,17 @@
package tech.easyflow.ai.config;
import com.easyagents.search.engine.lucene.LuceneConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class AiLuceneConfig extends LuceneConfig {
@Value("${rag.searcher.lucene.indexDirPath}")
@Override
public void setIndexDirPath(String indexDirPath) {
super.setIndexDirPath(indexDirPath);
}
}

View File

@@ -0,0 +1,13 @@
package tech.easyflow.ai.config;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@MapperScan("tech.easyflow.ai.mapper")
@AutoConfiguration
public class AiModuleConfig {
public AiModuleConfig() {
System.out.println("启用模块 >>>>>>>>>> module-ai");
}
}

View File

@@ -0,0 +1,19 @@
package tech.easyflow.ai.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "node.bochaai")
public class BochaaiProps {
private String apiKey;
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
}

View File

@@ -0,0 +1,54 @@
package tech.easyflow.ai.config;
import com.easyagents.mcp.client.McpClientManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import tech.easyflow.ai.entity.Mcp;
import tech.easyflow.ai.service.impl.McpServiceImpl;
import tech.easyflow.common.util.StringUtil;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
import static tech.easyflow.ai.service.impl.McpServiceImpl.getFirstMcpServerName;
@Configuration
@DependsOn("mcpServiceImpl") // 确保 mcpService 先初始化
public class McpClientAutoConfig {
private final McpClientManager mcpClientManager = McpClientManager.getInstance();
private static final Logger log = LoggerFactory.getLogger(McpClientAutoConfig.class);
@Resource
private McpServiceImpl mcpService;
@PostConstruct
public void initMcpClient() {
log.info("开始初始化 MCP 客户端...");
List<Mcp> mcpList = mcpService.list();
log.info("获取到 MCP 配置列表,数量:{}", mcpList.size());
mcpList.forEach(mcp -> {
if (!mcp.getStatus()) {
return;
}
String configJson = mcp.getConfigJson();
String serverName = getFirstMcpServerName(configJson);
if (StringUtil.hasText(serverName)) {
try {
mcpClientManager.registerFromJson(configJson);
} catch (Exception e) {
log.error("MCP服务名称{} 注册失败", serverName, e);
}
log.info("MCP服务名称{} 注册成功", serverName);
} else {
log.error("MCP服务名称为{} 启动失败,配置 JSON 中未找到服务名称", mcp.getTitle());
}
});
}
}

View File

@@ -0,0 +1,40 @@
package tech.easyflow.ai.config;
import com.easyagents.engine.es.ElasticSearcher;
import com.easyagents.search.engine.lucene.LuceneSearcher;
import com.easyagents.search.engine.service.DocumentSearcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SearcherFactory {
@Autowired
private AiLuceneConfig luceneConfig;
@Autowired
private AiEsConfig aiEsConfig;
@Bean
public LuceneSearcher luceneSearcher() {
return new LuceneSearcher(luceneConfig);
}
@Bean
public ElasticSearcher elasticSearcher() {
return new ElasticSearcher(aiEsConfig);
}
public DocumentSearcher getSearcher(String defaultSearcherType) {
switch (defaultSearcherType) {
case "elasticSearch":
return new ElasticSearcher(aiEsConfig);
case "lucene":
default:
return new LuceneSearcher(luceneConfig);
}
}
}

View File

@@ -0,0 +1,40 @@
package tech.easyflow.ai.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import tech.easyflow.common.web.exceptions.BusinessException;
@Configuration
public class ThreadPoolConfig {
private static final Logger log = LoggerFactory.getLogger(ThreadPoolConfig.class);
/**
* SSE消息发送专用线程池
* 核心原则IO密集型任务网络推送线程数 = CPU核心数 * 2 + 1
*/
@Bean(name = "sseThreadPool")
public ThreadPoolTaskExecutor sseThreadPool() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
int cpuCoreNum = Runtime.getRuntime().availableProcessors(); // 获取CPU核心数4核返回4
executor.setCorePoolSize(cpuCoreNum * 2); // 核心线程数
executor.setMaxPoolSize(cpuCoreNum * 10); // 最大线程数(峰值时扩容,避免线程过多导致上下文切换)
executor.setQueueCapacity(8000); // 任务队列容量
executor.setKeepAliveSeconds(30); // 空闲线程存活时间30秒非核心线程空闲后销毁节省资源
executor.setThreadNamePrefix("sse-sender-");
// 拒绝策略
executor.setRejectedExecutionHandler((runnable, executorService) -> {
log.error("SSE线程池过载核心线程数{},最大线程数:{},队列任务数:{}",
executorService.getCorePoolSize(),
executorService.getMaximumPoolSize(),
executorService.getQueue().size());
// 抛出自定义异常,全局捕获后返回“服务繁忙”
throw new BusinessException("服务器忙,请稍后重试");
});
executor.initialize();
return executor;
}
}

View File

@@ -0,0 +1,77 @@
package tech.easyflow.ai.easyagents;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class CustomMultipartFile implements MultipartFile {
private final byte[] content;
private final String name;
private final String originalFilename;
private final String contentType;
public CustomMultipartFile(byte[] content, String name, String originalFilename, String contentType) {
this.content = content;
this.name = name;
this.originalFilename = originalFilename;
this.contentType = contentType;
}
// 从 InputStream 构建 CustomMultipartFile
public static CustomMultipartFile fromInputStream(InputStream inputStream, String name, String originalFilename, String contentType) throws IOException {
// 将 InputStream 转为字节数组
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
return new CustomMultipartFile(outputStream.toByteArray(), name, originalFilename, contentType);
}
// 实现 MultipartFile 接口的抽象方法
@Override
public String getName() {
return name;
}
@Override
public String getOriginalFilename() {
return originalFilename;
}
@Override
public String getContentType() {
return contentType;
}
@Override
public boolean isEmpty() {
return content == null || content.length == 0;
}
@Override
public long getSize() {
return content.length;
}
@Override
public byte[] getBytes() throws IOException {
return content;
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(content);
}
@Override
public void transferTo(java.io.File dest) throws IOException, IllegalStateException {
// 如需保存到文件,可实现此方法
throw new UnsupportedOperationException("transferTo is not implemented");
}
}

View File

@@ -0,0 +1,144 @@
package tech.easyflow.ai.easyagents.listener;
import com.easyagents.core.message.AiMessage;
import com.easyagents.core.message.ToolMessage;
import com.easyagents.core.model.chat.ChatModel;
import com.easyagents.core.model.chat.ChatOptions;
import com.easyagents.core.model.chat.StreamResponseListener;
import com.easyagents.core.model.chat.response.AiMessageResponse;
import com.easyagents.core.model.client.StreamContext;
import com.easyagents.core.prompt.MemoryPrompt;
import org.apache.catalina.connector.ClientAbortException;
import tech.easyflow.core.chat.protocol.ChatDomain;
import tech.easyflow.core.chat.protocol.ChatEnvelope;
import tech.easyflow.core.chat.protocol.ChatType;
import tech.easyflow.core.chat.protocol.MessageRole;
import tech.easyflow.core.chat.protocol.payload.ErrorPayload;
import tech.easyflow.core.chat.protocol.sse.ChatSseEmitter;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class ChatStreamListener implements StreamResponseListener {
private final String conversationId;
private final ChatModel chatModel;
private final MemoryPrompt memoryPrompt;
private final ChatSseEmitter sseEmitter;
private final ChatOptions chatOptions;
// 核心标记是否允许执行onStop业务逻辑仅最后一次无后续工具调用时为true
private boolean canStop = true;
// 辅助标记:是否进入过工具调用(避免重复递归判断)
private boolean hasToolCall = false;
public ChatStreamListener(String conversationId, ChatModel chatModel, MemoryPrompt memoryPrompt, ChatSseEmitter sseEmitter, ChatOptions chatOptions) {
this.conversationId = conversationId;
this.chatModel = chatModel;
this.memoryPrompt = memoryPrompt;
this.sseEmitter = sseEmitter;
this.chatOptions = chatOptions;
}
@Override
public void onStart(StreamContext context) {
StreamResponseListener.super.onStart(context);
}
@Override
public void onMessage(StreamContext context, AiMessageResponse aiMessageResponse) {
try {
AiMessage aiMessage = aiMessageResponse.getMessage();
if (aiMessage == null) {
return;
}
if (aiMessage.isFinalDelta() && aiMessageResponse.hasToolCalls()) {
this.canStop = false; // 工具调用期间禁止执行onStop
this.hasToolCall = true; // 标记已进入过工具调用
aiMessage.setContent(null);
memoryPrompt.addMessage(aiMessage);
List<ToolMessage> toolMessages = aiMessageResponse.executeToolCallsAndGetToolMessages();
for (ToolMessage toolMessage : toolMessages) {
memoryPrompt.addMessage(toolMessage);
}
chatModel.chatStream(memoryPrompt, this, chatOptions);
} else {
if (this.hasToolCall) {
this.canStop = true;
}
String reasoningContent = aiMessage.getReasoningContent();
if (reasoningContent != null && !reasoningContent.isEmpty()) {
sendChatEnvelope(sseEmitter, reasoningContent, ChatType.THINKING);
} else {
String delta = aiMessage.getContent();
if (delta != null && !delta.isEmpty()) {
sendChatEnvelope(sseEmitter, delta, ChatType.MESSAGE);
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void onStop(StreamContext context) {
// 仅当canStop为true最后一次无后续工具调用的响应执行业务逻辑
if (this.canStop) {
System.out.println("onStop");
if (context.getThrowable() != null) {
sendSystemError(sseEmitter, context.getThrowable().getMessage());
return;
}
memoryPrompt.addMessage(context.getFullMessage());
ChatEnvelope<Map<String, String>> chatEnvelope = new ChatEnvelope<>();
chatEnvelope.setDomain(ChatDomain.SYSTEM);
sseEmitter.sendDone(chatEnvelope);
StreamResponseListener.super.onStop(context);
}
}
@Override
public void onFailure(StreamContext context, Throwable throwable) {
if (throwable != null) {
throwable.printStackTrace();
sendSystemError(sseEmitter, throwable.getMessage());
}
}
private void sendChatEnvelope(ChatSseEmitter sseEmitter, String deltaContent, ChatType chatType) throws IOException {
if (deltaContent == null || deltaContent.isEmpty()) {
return;
}
ChatEnvelope<Map<String, String>> chatEnvelope = new ChatEnvelope<>();
chatEnvelope.setDomain(ChatDomain.LLM);
chatEnvelope.setType(chatType);
Map<String, String> deltaMap = new LinkedHashMap<>();
deltaMap.put("conversation_id", this.conversationId);
deltaMap.put("role", MessageRole.ASSISTANT.getValue());
deltaMap.put("delta", deltaContent);
chatEnvelope.setPayload(deltaMap);
sseEmitter.send(chatEnvelope);
}
public void sendSystemError(ChatSseEmitter sseEmitter,
String message) {
ChatEnvelope<ErrorPayload> envelope = new ChatEnvelope<>();
ErrorPayload payload = new ErrorPayload();
payload.setMessage(message);
payload.setCode("SYSTEM_ERROR");
payload.setRetryable(false);
envelope.setPayload(payload);
envelope.setDomain(ChatDomain.SYSTEM);
envelope.setType(ChatType.ERROR);
sseEmitter.sendError(envelope);
sseEmitter.complete();
}
}

View File

@@ -0,0 +1,63 @@
package tech.easyflow.ai.easyagents.listener;
import com.easyagents.core.model.chat.StreamResponseListener;
import com.easyagents.core.model.chat.response.AiMessageResponse;
import com.easyagents.core.model.client.StreamContext;
import com.alibaba.fastjson.JSON;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import tech.easyflow.common.util.StringUtil;
import tech.easyflow.core.chat.protocol.ChatDomain;
import tech.easyflow.core.chat.protocol.ChatEnvelope;
import tech.easyflow.core.chat.protocol.ChatType;
import tech.easyflow.core.chat.protocol.MessageRole;
import tech.easyflow.core.chat.protocol.sse.ChatSseEmitter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* 系统提示词优化监听器
*/
public class PromptChoreChatStreamListener implements StreamResponseListener {
private final ChatSseEmitter sseEmitter;
public PromptChoreChatStreamListener(ChatSseEmitter sseEmitter) {
this.sseEmitter = sseEmitter;
}
@Override
public void onStart(StreamContext context) {
StreamResponseListener.super.onStart(context);
}
@Override
public void onMessage(StreamContext context, AiMessageResponse response) {
String content = response.getMessage().getContent();
if (content != null) {
String delta = response.getMessage().getContent();
if (StringUtil.hasText(delta)) {
ChatEnvelope<Map<String, String>> chatEnvelope = new ChatEnvelope<>();
chatEnvelope.setDomain(ChatDomain.LLM);
chatEnvelope.setType(ChatType.MESSAGE);
Map<String, String> deletaMap = new HashMap<>();
deletaMap.put("delta", delta);
deletaMap.put("role", MessageRole.ASSISTANT.getValue());
chatEnvelope.setPayload(deletaMap);
sseEmitter.send(chatEnvelope);
}
}
}
@Override
public void onStop(StreamContext context) {
System.out.println("onStop");
sseEmitter.sendDone(new ChatEnvelope<>());
StreamResponseListener.super.onStop(context);
}
@Override
public void onFailure(StreamContext context, Throwable throwable) {
StreamResponseListener.super.onFailure(context, throwable);
}
}

View File

@@ -0,0 +1,74 @@
package tech.easyflow.ai.easyagents.memory;
import com.easyagents.core.memory.ChatMemory;
import com.easyagents.core.message.Message;
import com.mybatisflex.core.query.QueryWrapper;
import tech.easyflow.ai.entity.BotMessage;
import tech.easyflow.ai.service.BotMessageService;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class BotMessageMemory implements ChatMemory {
private final BigInteger botId;
private final BigInteger accountId;
private final BigInteger conversationId;
private final BotMessageService messageService;
public BotMessageMemory(BigInteger botId, BigInteger accountId, BigInteger conversationId,
BotMessageService messageService) {
this.botId = botId;
this.accountId = accountId;
this.conversationId = conversationId;
this.messageService = messageService;
}
@Override
public List<Message> getMessages(int count) {
List<BotMessage> sysAiMessages = messageService.list(QueryWrapper.create()
.eq(BotMessage::getBotId, botId, true)
.eq(BotMessage::getAccountId, accountId, true)
.eq(BotMessage::getConversationId, conversationId, true)
.orderBy(BotMessage::getCreated, true)
.limit(count)
);
if (sysAiMessages == null || sysAiMessages.isEmpty()) {
return null;
}
List<Message> messages = new ArrayList<>(sysAiMessages.size());
for (BotMessage botMessage : sysAiMessages) {
Message message = botMessage.getContentAsMessage();
if (message != null) messages.add(message);
}
return messages;
}
@Override
public void addMessage(Message message) {
BotMessage dbMessage = new BotMessage();
dbMessage.setCreated(new Date());
dbMessage.setBotId(botId);
dbMessage.setAccountId(accountId);
dbMessage.setConversationId(conversationId);
dbMessage.setContentAndRole(message);
dbMessage.setModified(new Date());
messageService.save(dbMessage);
}
@Override
public void clear() {
}
@Override
public Object id() {
return botId;
}
}

View File

@@ -0,0 +1,79 @@
package tech.easyflow.ai.easyagents.memory;
import com.easyagents.core.memory.DefaultChatMemory;
import com.easyagents.core.message.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import tech.easyflow.ai.entity.BotMessage;
import tech.easyflow.core.chat.protocol.ChatDomain;
import tech.easyflow.core.chat.protocol.ChatEnvelope;
import tech.easyflow.core.chat.protocol.ChatType;
import tech.easyflow.core.chat.protocol.MessageRole;
import tech.easyflow.core.chat.protocol.sse.ChatSseEmitter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class DefaultBotMessageMemory extends DefaultChatMemory {
private final ChatSseEmitter sseEmitter;
private final List<Map<String, String>> messages;
public DefaultBotMessageMemory(BigInteger conversationId, ChatSseEmitter sseEmitter, List<Map<String, String>> messages) {
super(conversationId);
this.sseEmitter = sseEmitter;
this.messages = messages;
}
@Override
public List<Message> getMessages(int count) {
List<Message> list = new ArrayList<>(messages.size());
for (Map<String, String> msg : messages) {
BotMessage botMessage = new BotMessage();
botMessage.setRole(msg.get("role"));
botMessage.setContent(msg.get("content"));
Message message = botMessage.getContentAsMessage();
list.add(message);
}
List<Message> collect = list.stream()
.limit(count)
.collect(Collectors.toList());
return collect;
}
@Override
public void addMessage(Message message) {
BotMessage dbMessage = new BotMessage();
ChatEnvelope<Map<String, String>> chatEnvelope = new ChatEnvelope<>();
String jsonMessage = JSON.toJSONString(message, SerializerFeature.WriteClassName);
if (message instanceof AiMessage) {
dbMessage.setRole(MessageRole.ASSISTANT.getValue());
} else if (message instanceof UserMessage) {
dbMessage.setRole(MessageRole.USER.getValue());
} else if (message instanceof SystemMessage) {
dbMessage.setRole(MessageRole.SYSTEM.getValue());
} else if (message instanceof ToolMessage) {
dbMessage.setRole(MessageRole.TOOL.getValue());
}
Map<String, String> res = new HashMap<>();
res.put("role", dbMessage.getRole());
res.put("content", jsonMessage);
chatEnvelope.setType(ChatType.MESSAGE);
chatEnvelope.setPayload(res);
chatEnvelope.setDomain(ChatDomain.SYSTEM);
if (dbMessage.getRole().equals(MessageRole.USER.getValue())) {
messages.remove(messages.size() - 1);
}
sseEmitter.sendMessageNeedSave(chatEnvelope);
messages.add(res);
}
}

View File

@@ -0,0 +1,31 @@
package tech.easyflow.ai.easyagents.memory;
import com.easyagents.core.memory.DefaultChatMemory;
import com.easyagents.core.message.Message;
import tech.easyflow.core.chat.protocol.sse.ChatSseEmitter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class PublicBotMessageMemory extends DefaultChatMemory {
private final ChatSseEmitter sseEmitter;
private List<Message> messages = new ArrayList<>();
public PublicBotMessageMemory(ChatSseEmitter sseEmitter, List<Message> messages ) {
this.messages = messages;
this.sseEmitter = sseEmitter;
}
@Override
public List<Message> getMessages(int count) {
return messages.stream()
.limit(count)
.collect(Collectors.toList());
}
@Override
public void addMessage(Message message) {
this.messages.add(message);
}
}

View File

@@ -0,0 +1,66 @@
package tech.easyflow.ai.easyagents.tool;
import com.easyagents.core.document.Document;
import com.easyagents.core.model.chat.tool.BaseTool;
import com.easyagents.core.model.chat.tool.Parameter;
import tech.easyflow.ai.entity.DocumentCollection;
import tech.easyflow.ai.service.DocumentCollectionService;
import tech.easyflow.common.util.SpringContextUtil;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
public class DocumentCollectionTool extends BaseTool {
private BigInteger knowledgeId;
public DocumentCollectionTool() {
}
public DocumentCollectionTool(DocumentCollection documentCollection, boolean needEnglishName) {
this.knowledgeId = documentCollection.getId();
if (needEnglishName) {
this.name = documentCollection.getEnglishName();
} else {
this.name = documentCollection.getTitle();
}
this.description = documentCollection.getDescription();
this.parameters = getDefaultParameters();
}
public Parameter[] getDefaultParameters() {
Parameter parameter = new Parameter();
parameter.setName("input");
parameter.setDescription("要查询的相关知识");
parameter.setType("string");
parameter.setRequired(true);
return new Parameter[]{parameter};
}
public BigInteger getKnowledgeId() {
return knowledgeId;
}
public void setKnowledgeId(BigInteger knowledgeId) {
this.knowledgeId = knowledgeId;
}
@Override
public Object invoke(Map<String, Object> argsMap) {
DocumentCollectionService knowledgeService = SpringContextUtil.getBean(DocumentCollectionService.class);
List<Document> documents = knowledgeService.search(this.knowledgeId, (String) argsMap.get("input"));
StringBuilder sb = new StringBuilder();
if (documents != null) {
for (Document document : documents) {
sb.append(document.getContent());
}
}
return sb.toString();
}
}

View File

@@ -0,0 +1,46 @@
package tech.easyflow.ai.easyagents.tool;
import com.easyagents.core.model.chat.tool.BaseTool;
import com.easyagents.core.model.chat.tool.Tool;
import com.easyagents.mcp.client.McpClientManager;
import tech.easyflow.ai.entity.Mcp;
import tech.easyflow.ai.service.McpService;
import tech.easyflow.ai.service.impl.McpServiceImpl;
import tech.easyflow.common.util.SpringContextUtil;
import tech.easyflow.common.util.StringUtil;
import java.math.BigInteger;
import java.util.Map;
import java.util.Optional;
public class McpTool extends BaseTool {
private BigInteger mcpId;
@Override
public Object invoke(Map<String, Object> argsMap) {
return runMcp(this.mcpId, argsMap);
}
public Object runMcp(BigInteger mcpId, Map<String, Object> argsMap) {
McpService mcpService = SpringContextUtil.getBean(McpService.class);
Mcp mcp = mcpService.getMapper().selectOneById(mcpId);
String serverName = McpServiceImpl.getFirstMcpServerName(mcp.getConfigJson());
if (StringUtil.hasText(serverName)) {
McpClientManager mcpClientManager = McpClientManager.getInstance();
Tool mcpTool = mcpClientManager.getMcpTool(serverName, this.name);
Object result = mcpTool.invoke(argsMap);
return result;
}
return null;
}
public void setMcpId(BigInteger mcpId) {
this.mcpId = mcpId;
}
public BigInteger getMcpId() {
return mcpId;
}
}

View File

@@ -0,0 +1,368 @@
package tech.easyflow.ai.easyagents.tool;
import cn.hutool.core.io.FileTypeUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.easyagents.core.model.chat.tool.BaseTool;
import com.easyagents.core.model.chat.tool.Parameter;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mybatisflex.core.query.QueryWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tech.easyflow.ai.easyagents.CustomMultipartFile;
import tech.easyflow.ai.entity.Plugin;
import tech.easyflow.ai.entity.PluginItem;
import tech.easyflow.ai.mapper.PluginMapper;
import tech.easyflow.ai.service.PluginItemService;
import tech.easyflow.common.ai.plugin.NestedParamConverter;
import tech.easyflow.common.ai.plugin.PluginHttpClient;
import tech.easyflow.common.ai.plugin.PluginParam;
import tech.easyflow.common.ai.plugin.PluginParamConverter;
import tech.easyflow.common.filestorage.FileStorageManager;
import tech.easyflow.common.filestorage.FileStorageService;
import tech.easyflow.common.util.SpringContextUtil;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class PluginTool extends BaseTool {
// 插件工具id
private BigInteger pluginToolId;
private String name;
private String description;
private Parameter[] parameters;
private static final Logger logger = LoggerFactory.getLogger(PluginTool.class);
public PluginTool() {
}
public PluginTool(PluginItem pluginItem) {
this.name = pluginItem.getEnglishName();
this.description = pluginItem.getDescription();
this.pluginToolId = pluginItem.getId();
this.parameters = getDefaultParameters(pluginItem.getInputData());
}
public BigInteger getPluginToolId() {
return pluginToolId;
}
public void setPluginToolId(BigInteger pluginToolId) {
this.pluginToolId = pluginToolId;
}
public void setName(String name) {
this.name = name;
}
public void setDescription(String description) {
this.description = description;
}
public void setParameters(Parameter[] parameters) {
this.parameters = parameters;
}
private Plugin getAiPlugin(BigInteger pluginId) {
QueryWrapper queryWrapper = QueryWrapper.create()
.select("*")
.from("tb_plugin")
.where("id = ?", pluginId);
PluginMapper pluginMapper = SpringContextUtil.getBean(PluginMapper.class);
Plugin plugin1 = pluginMapper.selectOneByQuery(queryWrapper);
return plugin1;
}
private Parameter[] getDefaultParameters(String inputData) {
PluginItemService pluginToolService = SpringContextUtil.getBean(PluginItemService.class);
QueryWrapper queryAiPluginToolWrapper = QueryWrapper.create()
.select("*")
.from("tb_plugin_item")
.where("id = ? ", this.pluginToolId);
PluginItem pluginItem = pluginToolService.getMapper().selectOneByQuery(queryAiPluginToolWrapper);
List<Map<String, Object>> dataList = null;
if (pluginItem == null || pluginItem.getInputData() == null){
dataList = getDataList(inputData);
} else {
dataList = getDataList(pluginItem.getInputData());
}
Parameter[] params = new Parameter[dataList.size()];
for (int i = 0; i < dataList.size(); i++) {
Map<String, Object> item = dataList.get(i);
Parameter parameter = new Parameter();
parameter.setName((String) item.get("name"));
parameter.setDescription((String) item.get("description"));
parameter.setRequired((boolean) item.get("required"));
String type = (String) item.get("type");
if (type != null) {
parameter.setType(type.toLowerCase());
}
params[i] = parameter;
}
return params;
}
// 转换输入参数
private List<Map<String, Object>> getDataList(String jsonArray){
List<Map<String, Object>> dataList;
if (jsonArray == null) {
return new ArrayList<>();
}
try {
dataList = new ObjectMapper().readValue(
jsonArray,
new TypeReference<List<Map<String, Object>>>(){}
);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return dataList;
}
@Override
public String getName() {
return name;
}
@Override
public String getDescription() {
return description;
}
@Override
public Parameter[] getParameters() {
return parameters;
}
@Override
public Object invoke(Map<String, Object> argsMap) {
return runPluginTool(argsMap, null, this.pluginToolId);
}
public Object runPluginTool(Map<String, Object> argsMap, String inputData, BigInteger pluginId){
PluginItemService pluginToolService = SpringContextUtil.getBean(PluginItemService.class);
QueryWrapper queryAiPluginToolWrapper = QueryWrapper.create()
.select("*")
.from("tb_plugin_item")
.where("id = ? ", pluginId);
PluginItem pluginItem = pluginToolService.getMapper().selectOneByQuery(queryAiPluginToolWrapper);
String method = pluginItem.getRequestMethod().toUpperCase();
Plugin plugin = getAiPlugin(pluginItem.getPluginId());
String url;
if (!StrUtil.isEmpty(pluginItem.getBasePath())) {
url = plugin.getBaseUrl()+ pluginItem.getBasePath();
} else {
url = plugin.getBaseUrl()+"/"+ pluginItem.getName();
}
List<Map<String, Object>> headers = getDataList(plugin.getHeaders());
Map<String, Object> headersMap = new HashMap<>();
for (Map<String, Object> header : headers) {
headersMap.put((String) header.get("label"), header.get("value"));
}
List<PluginParam> params = new ArrayList<>();
String authType = plugin.getAuthType();
if (!StrUtil.isEmpty(authType) && "apiKey".equals(plugin.getAuthType())){
if ("headers".equals(plugin.getPosition())){
headersMap.put(plugin.getTokenKey(), plugin.getTokenValue());
} else {
PluginParam pluginParam = new PluginParam();
pluginParam.setName(plugin.getTokenKey());
pluginParam.setDefaultValue(plugin.getTokenValue());
pluginParam.setEnabled(true);
pluginParam.setRequired(true);
pluginParam.setMethod("query");
params.add(pluginParam);
}
}
List<PluginParam> pluginParams = null;
// 前端点击试运行传过来的参数
if (inputData != null && !inputData.isEmpty()){
pluginParams = PluginParamConverter.convertFromJson(inputData);
// 大模型命中funcation_call 调用参数
} else {
pluginParams = PluginParamConverter.convertFromJson(pluginItem.getInputData());
}
// 准备存放不同位置的参数
List<PluginParam> queryParams = new ArrayList<>();
List<PluginParam> bodyParams = new ArrayList<>();
List<PluginParam> headerParams = new ArrayList<>();
List<PluginParam> pathParams = new ArrayList<>();
Map<String, Object> nestedParams = NestedParamConverter.convertToNestedParamMap(pluginParams);
// 遍历嵌套参数
for (Map.Entry<String, Object> entry : nestedParams.entrySet()) {
String paramName = entry.getKey();
// 获取原始参数定义
PluginParam originalParam = findOriginalParam(pluginParams, paramName);
if (originalParam == null || !originalParam.isEnabled()) {
continue;
}
// 创建参数副本以避免修改原始定义
PluginParam requestParam = new PluginParam();
requestParam.setName(originalParam.getName());
requestParam.setDescription(originalParam.getDescription());
requestParam.setRequired(originalParam.isRequired());
requestParam.setEnabled(originalParam.isEnabled());
requestParam.setMethod(originalParam.getMethod());
requestParam.setChildren(originalParam.getChildren());
// 优先级: argsMap值 < 参数默认值
if (argsMap != null && argsMap.containsKey(paramName)) {
// 1. 优先检查是否有有效的默认值
if (hasValidDefaultValue(originalParam.getDefaultValue())) {
// 使用默认值
requestParam.setDefaultValue(originalParam.getDefaultValue());
} else {
// 使用大模型返回的值
requestParam.setDefaultValue(argsMap.get(paramName));
}
} else if (hasValidDefaultValue(originalParam.getDefaultValue())) {
// 2. 没有传参但默认值有效时使用默认值
// 如果是文件类型
if (originalParam.getType().equals("File")){
try {
FileStorageService fileStorageService = SpringContextUtil.getBean(FileStorageManager.class);
InputStream inputStream = fileStorageService.readStream((String)originalParam.getDefaultValue());
requestParam.setType("MultipartFile");
byte[] bytes = inputStreamToBytes(inputStream);
String contentType = FileTypeUtil.getType(new ByteArrayInputStream(bytes));
String fileUrl = (String) originalParam.getDefaultValue();
int lastSlashIndex = fileUrl.lastIndexOf("/");
String fileName = fileUrl.substring(lastSlashIndex + 1);
requestParam.setDefaultValue(new CustomMultipartFile(bytes, originalParam.getName(), fileName, contentType));
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
requestParam.setType(originalParam.getType());
requestParam.setDefaultValue(originalParam.getDefaultValue());
}
}
// 根据method分类参数
switch (originalParam.getMethod().toLowerCase()) {
case "query":
queryParams.add(requestParam);
break;
case "body":
bodyParams.add(requestParam);
break;
case "header":
headerParams.add(requestParam);
break;
case "path":
pathParams.add(requestParam);
break;
}
}
// 合并所有参数
List<PluginParam> allParams = new ArrayList<>();
allParams.addAll(pathParams);
allParams.addAll(queryParams);
allParams.addAll(bodyParams);
allParams.addAll(headerParams);
allParams.addAll(params);
// 发送请求
JSONObject result = PluginHttpClient.sendRequest(url, method, headersMap, allParams);
if (result.get("error") != null){
logger.error("插件调用失败");
logger.error(result.get("error").toString());
}
return result;
}
// 辅助方法:根据参数名查找原始参数定义
private PluginParam findOriginalParam(List<PluginParam> params, String name) {
for (PluginParam param : params) {
if (name.equals(param.getName())) {
return param;
}
}
return null;
}
// 添加辅助方法判断默认值是否有效
private boolean hasValidDefaultValue(Object defaultValue) {
if (defaultValue == null) {
return false;
}
// 字符串类型检查
if (defaultValue instanceof CharSequence) {
return !((CharSequence) defaultValue).toString().trim().isEmpty();
}
// 集合/数组类型检查
if (defaultValue instanceof Collection) {
return !((Collection<?>) defaultValue).isEmpty();
}
if (defaultValue instanceof Map) {
return !((Map<?, ?>) defaultValue).isEmpty();
}
if (defaultValue.getClass().isArray()) {
return Array.getLength(defaultValue) > 0;
}
// 其他类型直接认为有效
return true;
}
private void processParamWithChildren(Map<String, Object> paramDef, Map<String, Object> argsMap, List<PluginParam> params) {
boolean enabled = (boolean) paramDef.get("enabled");
if (!enabled){
return;
}
String paramName = (String) paramDef.get("name");
PluginParam pluginParam = new PluginParam();
pluginParam.setName(paramName);
pluginParam.setDescription((String) paramDef.get("description"));
pluginParam.setRequired((boolean) paramDef.get("required"));
pluginParam.setType((String) paramDef.get("type"));
pluginParam.setEnabled((boolean) paramDef.get("enabled"));
pluginParam.setMethod((String) paramDef.get("method"));
// 如果用户传了值,就用用户的值;否则用默认值
if (paramDef.get("defaultValue") != null && !"".equals(paramDef.get("defaultValue"))) {
pluginParam.setDefaultValue(paramDef.get("defaultValue"));
} else if (argsMap != null && paramDef.get("name").equals(paramName) && paramDef.get("defaultValue") != null) {
pluginParam.setDefaultValue(argsMap.get(paramName));
}
params.add(pluginParam);
// 处理 children
List<Map<String, Object>> children = (List<Map<String, Object>>) paramDef.get("children");
if (children != null) {
for (Map<String, Object> child : children) {
processParamWithChildren(child, argsMap, params);
}
}
}
public static byte[] inputStreamToBytes(InputStream inputStream) throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[1024]; // 1KB缓冲区
while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
return buffer.toByteArray();
}
}

View File

@@ -0,0 +1,81 @@
package tech.easyflow.ai.easyagents.tool;
import com.easyagents.core.model.chat.tool.BaseTool;
import com.easyagents.core.model.chat.tool.Parameter;
import com.easyagents.flow.core.chain.ChainDefinition;
import com.easyagents.flow.core.chain.DataType;
import com.easyagents.flow.core.chain.runtime.ChainExecutor;
import tech.easyflow.ai.entity.Workflow;
import tech.easyflow.common.util.SpringContextUtil;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class WorkflowTool extends BaseTool {
private BigInteger workflowId;
public WorkflowTool() {
}
public WorkflowTool(Workflow workflow, boolean needEnglishName) {
this.workflowId = workflow.getId();
if (needEnglishName) {
this.name = workflow.getEnglishName();
} else {
this.name = workflow.getTitle();
}
this.description = workflow.getDescription();
this.parameters = toParameters(workflow);
}
static Parameter[] toParameters(Workflow workflow) {
ChainExecutor executor = SpringContextUtil.getBean(ChainExecutor.class);
ChainDefinition definition = executor.getDefinitionRepository().getChainDefinitionById(workflow.getId().toString());
List<com.easyagents.flow.core.chain.Parameter> parameterDefs = definition.getStartParameters();
if (parameterDefs == null || parameterDefs.isEmpty()) {
return new Parameter[0];
}
Parameter[] parameters = new Parameter[parameterDefs.size()];
for (int i = 0; i < parameterDefs.size(); i++) {
com.easyagents.flow.core.chain.Parameter parameterDef = parameterDefs.get(i);
Parameter parameter = new Parameter();
parameter.setName(parameterDef.getName());
parameter.setDescription(parameterDef.getDescription());
DataType dataType = parameterDef.getDataType();
if (dataType == null) dataType = DataType.String;
parameter.setType(dataType.toString());
parameter.setRequired(parameterDef.isRequired());
parameters[i] = parameter;
}
return parameters;
}
public BigInteger getWorkflowId() {
return workflowId;
}
public void setWorkflowId(BigInteger workflowId) {
this.workflowId = workflowId;
}
@Override
public Object invoke(Map<String, Object> argsMap) {
ChainExecutor executor = SpringContextUtil.getBean(ChainExecutor.class);
return executor.execute(workflowId.toString(), argsMap);
}
@Override
public String toString() {
return "AiWorkflowFunction{" +
"workflowId=" + workflowId +
", name='" + name + '\'' +
", description='" + description + '\'' +
", parameters=" + Arrays.toString(parameters) +
'}';
}
}

View File

@@ -0,0 +1,47 @@
package tech.easyflow.ai.easyagentsflow.config;
import com.easyagents.flow.core.chain.repository.ChainDefinitionRepository;
import com.easyagents.flow.core.chain.repository.ChainStateRepository;
import com.easyagents.flow.core.chain.repository.NodeStateRepository;
import com.easyagents.flow.core.chain.runtime.ChainExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tech.easyflow.ai.easyagentsflow.listener.ChainErrorListenerForSave;
import tech.easyflow.ai.easyagentsflow.listener.ChainEventListenerForSave;
import tech.easyflow.ai.easyagentsflow.listener.NodeErrorListenerForSave;
import javax.annotation.Resource;
@Configuration
public class ChainExecutorConfig {
@Resource
private ChainDefinitionRepository chainDefinitionRepository;
@Resource
private ChainStateRepository chainStateRepository;
@Resource
private NodeStateRepository nodeStateRepository;
@Resource
private ChainEventListenerForSave chainEventListenerForSave;
@Bean(name = "chainExecutor")
public ChainExecutor chainExecutor() {
ChainExecutor chainExecutor = new ChainExecutor(chainDefinitionRepository,
chainStateRepository,
nodeStateRepository);
saveStepsListeners(chainExecutor);
return chainExecutor;
}
/**
* 步骤保存监听器 - 自行实现
*/
private void saveStepsListeners(ChainExecutor chainExecutor) {
chainExecutor.addEventListener(chainEventListenerForSave);
chainExecutor.addErrorListener(new ChainErrorListenerForSave());
chainExecutor.addNodeErrorListener(new NodeErrorListenerForSave());
}
}

View File

@@ -0,0 +1,24 @@
package tech.easyflow.ai.easyagentsflow.config;
import com.easyagents.flow.core.parser.ChainParser;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tech.easyflow.ai.easyagentsflow.service.TinyFlowConfigService;
import javax.annotation.Resource;
@Configuration
public class ChainParserConfig {
@Resource
private TinyFlowConfigService tinyFlowConfigService;
@Bean
public ChainParser chainParser() {
ChainParser chainParser = ChainParser.builder()
.withDefaultParsers(true)
.build();
tinyFlowConfigService.initProvidersAndNodeParsers(chainParser);
return chainParser;
}
}

View File

@@ -0,0 +1,85 @@
package tech.easyflow.ai.easyagentsflow.entity;
import com.easyagents.flow.core.chain.ChainStatus;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
public class ChainInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 执行ID
*/
private String executeId;
/**
* 执行状态
* @see ChainStatus
*/
private Integer status;
/**
* 消息,错误时显示
*/
private String message;
/**
* 执行结果
*/
private Map<String, Object> result;
/**
* 节点信息
*/
private Map<String, NodeInfo> nodes = new HashMap<>();
public String getExecuteId() {
return executeId;
}
public void setExecuteId(String executeId) {
this.executeId = executeId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Map<String, Object> getResult() {
return result;
}
public void setResult(Map<String, Object> result) {
this.result = result;
}
public Map<String, NodeInfo> getNodes() {
return nodes;
}
public void setNodes(Map<String, NodeInfo> nodes) {
this.nodes = nodes;
}
@Override
public String toString() {
return "ChainInfo{" +
"executeId='" + executeId + '\'' +
", status=" + status +
", message='" + message + '\'' +
", result=" + result +
", nodes=" + nodes +
'}';
}
}

View File

@@ -0,0 +1,99 @@
package tech.easyflow.ai.easyagentsflow.entity;
import com.easyagents.flow.core.chain.NodeStatus;
import com.easyagents.flow.core.chain.Parameter;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class NodeInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 节点ID
*/
private String nodeId;
/**
* 节点名称
*/
private String nodeName;
/**
* 执行状态
* @see NodeStatus
*/
private Integer status;
/**
* 消息,错误时显示
*/
private String message;
/**
* 执行结果
*/
private Map<String, Object> result;
/**
* 挂起时需要填写的参数
*/
private List<Parameter> suspendForParameters;
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getNodeName() {
return nodeName;
}
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Map<String, Object> getResult() {
return result;
}
public void setResult(Map<String, Object> result) {
this.result = result;
}
public List<Parameter> getSuspendForParameters() {
return suspendForParameters;
}
public void setSuspendForParameters(List<Parameter> suspendForParameters) {
this.suspendForParameters = suspendForParameters;
}
@Override
public String toString() {
return "NodeInfo{" +
"nodeId='" + nodeId + '\'' +
", nodeName='" + nodeName + '\'' +
", status=" + status +
", message='" + message + '\'' +
", result=" + result +
", suspendForParameters=" + suspendForParameters +
'}';
}
}

View File

@@ -0,0 +1,19 @@
package tech.easyflow.ai.easyagentsflow.filestorage;
import com.easyagents.flow.core.filestoreage.FileStorage;
import com.easyagents.flow.core.filestoreage.FileStorageProvider;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class FileStorageProviderImpl implements FileStorageProvider {
@Resource(name = "tinyFlowFileStorage")
private FileStorage tinyFlowFileStorage;
@Override
public FileStorage getFileStorage() {
return tinyFlowFileStorage;
}
}

View File

@@ -0,0 +1,24 @@
package tech.easyflow.ai.easyagentsflow.filestorage;
import com.easyagents.flow.core.chain.Chain;
import com.easyagents.flow.core.filestoreage.FileStorage;
import com.easyagents.flow.core.node.BaseNode;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.node.InputStreamFile;
import tech.easyflow.common.filestorage.FileStorageService;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.Map;
@Component(value = "tinyFlowFileStorage")
public class StorageImpl implements FileStorage {
@Resource(name = "default")
private FileStorageService fileStorageService;
@Override
public String saveFile(InputStream stream, Map<String, String> headers, BaseNode node, Chain chain) {
return fileStorageService.save(new InputStreamFile(stream, headers));
}
}

View File

@@ -0,0 +1,42 @@
package tech.easyflow.ai.easyagentsflow.knowledge;
import com.easyagents.core.document.Document;
import com.alibaba.fastjson2.JSONObject;
import com.easyagents.flow.core.chain.Chain;
import com.easyagents.flow.core.knowledge.Knowledge;
import com.easyagents.flow.core.knowledge.KnowledgeProvider;
import com.easyagents.flow.core.node.KnowledgeNode;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.service.DocumentCollectionService;
import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class KnowledgeProviderImpl implements KnowledgeProvider {
@Resource
private DocumentCollectionService documentCollectionService;
/**
* 获取知识库
* @param id 知识库id
*/
@Override
public Knowledge getKnowledge(Object id) {
return new Knowledge() {
@Override
public List<Map<String, Object>> search(String keyword, int limit, KnowledgeNode knowledgeNode, Chain chain) {
List<Document> documents = documentCollectionService.search(new BigInteger(id.toString()), keyword);
List<Map<String, Object>> res = new ArrayList<>();
for (Document document : documents) {
res.add(JSONObject.from(document));
}
return res;
}
};
}
}

View File

@@ -0,0 +1,16 @@
package tech.easyflow.ai.easyagentsflow.listener;
import com.easyagents.flow.core.chain.Chain;
import com.easyagents.flow.core.chain.listener.ChainErrorListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ChainErrorListenerForSave implements ChainErrorListener {
private static final Logger log = LoggerFactory.getLogger(ChainErrorListenerForSave.class);
@Override
public void onError(Throwable error, Chain chain) {
log.error("ChainErrorListenerForFront: {}", chain, error);
}
}

View File

@@ -0,0 +1,169 @@
package tech.easyflow.ai.easyagentsflow.listener;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.easyagents.flow.core.chain.*;
import com.easyagents.flow.core.chain.event.*;
import com.easyagents.flow.core.chain.listener.ChainEventListener;
import com.easyagents.flow.core.chain.repository.NodeStateField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.entity.Workflow;
import tech.easyflow.ai.entity.WorkflowExecResult;
import tech.easyflow.ai.entity.WorkflowExecStep;
import tech.easyflow.ai.service.WorkflowExecResultService;
import tech.easyflow.ai.service.WorkflowExecStepService;
import tech.easyflow.ai.service.WorkflowService;
import tech.easyflow.ai.utils.WorkFlowUtil;
import javax.annotation.Resource;
import java.util.Date;
import java.util.EnumSet;
@Component
public class ChainEventListenerForSave implements ChainEventListener {
private static final Logger log = LoggerFactory.getLogger(ChainEventListenerForSave.class);
@Resource
private WorkflowService workflowService;
@Resource
private WorkflowExecResultService workflowExecResultService;
@Resource
private WorkflowExecStepService workflowExecStepService;
@Override
public void onEvent(Event event, Chain chain) {
if (event instanceof ChainStartEvent) {
handleChainStartEvent((ChainStartEvent) event, chain);
}
if (event instanceof ChainEndEvent) {
handleChainEndEvent((ChainEndEvent) event, chain);
}
if (event instanceof NodeStartEvent) {
handleNodeStartEvent((NodeStartEvent) event, chain);
}
if (event instanceof NodeEndEvent) {
handleNodeEndEvent((NodeEndEvent) event, chain);
}
if (event instanceof ChainStatusChangeEvent) {
handleChainStatusChangeEvent((ChainStatusChangeEvent) event, chain);
}
if (event instanceof ChainResumeEvent) {
handleChainResumeEvent((ChainResumeEvent) event, chain);
}
}
private void handleChainStartEvent(ChainStartEvent event, Chain chain) {
log.info("ChainStartEvent: {}", event);
ChainDefinition definition = chain.getDefinition();
ChainState state = chain.getState();
Workflow workflow = workflowService.getById(definition.getId());
String instanceId = state.getInstanceId();
WorkflowExecResult record = new WorkflowExecResult();
record.setExecKey(instanceId);
record.setWorkflowId(workflow.getId());
record.setTitle(workflow.getTitle());
record.setDescription(workflow.getDescription());
record.setInput(JSON.toJSONString(event.getVariables()));
record.setWorkflowJson(workflow.getContent());
record.setStartTime(new Date());
record.setStatus(state.getStatus().getValue());
record.setCreatedKey(WorkFlowUtil.USER_KEY);
record.setCreatedBy(WorkFlowUtil.getOperator(chain).getId().toString());
workflowExecResultService.save(record);
}
private void handleChainEndEvent(ChainEndEvent event, Chain chain) {
log.info("ChainEndEvent: {}", event);
ChainState state = chain.getState();
String instanceId = state.getInstanceId();
WorkflowExecResult record = workflowExecResultService.getByExecKey(instanceId);
if (record == null) {
log.error("ChainEndEvent: record not found: {}", instanceId);
} else {
record.setEndTime(new Date());
record.setStatus(state.getStatus().getValue());
record.setOutput(JSON.toJSONString(state.getExecuteResult()));
ExceptionSummary error = state.getError();
if (error != null) {
record.setErrorInfo(error.getRootCauseClass() + " --> " + error.getRootCauseMessage());
}
workflowExecResultService.updateById(record);
}
}
private void handleNodeStartEvent(NodeStartEvent event, Chain chain) {
log.info("NodeStartEvent: {}", event);
Node node = event.getNode();
ChainState ancestorState = findAncestorState(chain.getState(), chain);
String instanceId = ancestorState.getInstanceId();
NodeState nodeState = chain.getNodeState(node.getId());
String execKey = IdUtil.fastSimpleUUID();
chain.updateNodeStateSafely(node.getId(), state -> {
state.getMemory().put("executeId", execKey);
return EnumSet.of(NodeStateField.MEMORY);
});
WorkflowExecResult record = workflowExecResultService.getByExecKey(instanceId);
if (record == null) {
log.error("NodeStartEvent: record not found: {}", instanceId);
} else {
WorkflowExecStep step = new WorkflowExecStep();
step.setRecordId(record.getId());
step.setExecKey(execKey);
step.setNodeId(node.getId());
step.setNodeName(node.getName());
step.setInput(JSON.toJSONString(ancestorState.resolveParameters(node)));
step.setNodeData(JSON.toJSONString(node));
step.setStartTime(new Date());
step.setStatus(nodeState.getStatus().getValue());
workflowExecStepService.save(step);
}
}
private void handleNodeEndEvent(NodeEndEvent event, Chain chain) {
log.info("NodeEndEvent: {}", event);
Node node = event.getNode();
NodeState nodeState = chain.getNodeState(node.getId());
String execKey = nodeState.getMemory().get("executeId").toString();
WorkflowExecStep step = workflowExecStepService.getByExecKey(execKey);
if (step == null) {
log.error("NodeEndEvent: step not found: {}", execKey);
} else {
step.setOutput(JSON.toJSONString(event.getResult()));
step.setEndTime(new Date());
step.setStatus(nodeState.getStatus().getValue());
ExceptionSummary error = nodeState.getError();
if (error != null) {
step.setErrorInfo(error.getRootCauseClass() + " --> " + error.getRootCauseMessage());
}
workflowExecStepService.updateById(step);
}
}
private void handleChainStatusChangeEvent(ChainStatusChangeEvent event, Chain chain) {
log.info("ChainStatusChangeEvent: {}", event);
}
private void handleChainResumeEvent(ChainResumeEvent event, Chain chain) {
log.info("ChainResumeEvent: {}", event);
}
/**
* 递归查找顶级状态
*/
private ChainState findAncestorState(ChainState state, Chain chain) {
String parentInstanceId = state.getParentInstanceId();
if (StrUtil.isEmpty(parentInstanceId)) {
return state;
}
ChainState chainState = chain.getChainStateRepository().load(parentInstanceId);
return findAncestorState(chainState, chain);
}
}

View File

@@ -0,0 +1,19 @@
package tech.easyflow.ai.easyagentsflow.listener;
import com.easyagents.flow.core.chain.Chain;
import com.easyagents.flow.core.chain.Node;
import com.easyagents.flow.core.chain.listener.NodeErrorListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
public class NodeErrorListenerForSave implements NodeErrorListener {
private static final Logger log = LoggerFactory.getLogger(NodeErrorListenerForSave.class);
@Override
public void onError(Throwable error, Node node, Map<String, Object> nodeResult, Chain chain) {
log.error("NodeErrorListenerForFront: {}", node, error);
}
}

View File

@@ -0,0 +1,33 @@
package tech.easyflow.ai.easyagentsflow.llm;
import com.easyagents.flow.support.provider.EasyAgentsLlm;
import com.easyagents.flow.core.llm.Llm;
import com.easyagents.flow.core.llm.LlmProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.entity.Model;
import tech.easyflow.ai.service.ModelService;
import javax.annotation.Resource;
import java.math.BigInteger;
@Component
public class LlmProviderImpl implements LlmProvider {
private static final Logger log = LoggerFactory.getLogger(LlmProviderImpl.class);
@Resource
private ModelService modelService;
@Override
public Llm getChatModel(Object modelId) {
Model model = modelService.getModelInstance(new BigInteger(modelId.toString()));
if (model == null) {
log.error("LlmProviderImpl.getChatModel: modelId not found: {}", modelId);
return null;
}
EasyAgentsLlm llm = new EasyAgentsLlm();
llm.setChatModel(model.toChatModel());
return llm;
}
}

View File

@@ -0,0 +1,27 @@
package tech.easyflow.ai.easyagentsflow.repository;
import com.alicp.jetcache.Cache;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
public class BaseRepository {
@Resource(name = "defaultCache")
private Cache<String, Object> cache;
/**
* chain 的相关状态缓存三天
*/
protected void putCache(String key, Object value) {
cache.put(key, value, 3, TimeUnit.DAYS);
}
protected <T> T getCache(String key, Class<T> clazz) {
Object value = cache.get(key);
if (value == null) {
return null;
}
return clazz.cast(value);
}
}

View File

@@ -0,0 +1,30 @@
package tech.easyflow.ai.easyagentsflow.repository;
import com.easyagents.flow.core.chain.ChainDefinition;
import com.easyagents.flow.core.chain.repository.ChainDefinitionRepository;
import com.easyagents.flow.core.parser.ChainParser;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.entity.Workflow;
import tech.easyflow.ai.service.WorkflowService;
import javax.annotation.Resource;
@Component
public class ChainDefinitionRepositoryImpl implements ChainDefinitionRepository {
@Resource
private WorkflowService workflowService;
@Resource
private ChainParser chainParser;
@Override
public ChainDefinition getChainDefinitionById(String id) {
Workflow workflow = workflowService.getById(id);
String json = workflow.getContent();
ChainDefinition chainDefinition = chainParser.parse(json);
chainDefinition.setId(workflow.getId().toString());
chainDefinition.setName(workflow.getEnglishName());
chainDefinition.setDescription(workflow.getDescription());
return chainDefinition;
}
}

View File

@@ -0,0 +1,32 @@
package tech.easyflow.ai.easyagentsflow.repository;
import com.easyagents.flow.core.chain.ChainState;
import com.easyagents.flow.core.chain.repository.ChainStateField;
import com.easyagents.flow.core.chain.repository.ChainStateRepository;
import org.springframework.stereotype.Component;
import tech.easyflow.common.constant.CacheKey;
import java.util.EnumSet;
@Component
public class ChainStateRepositoryImpl extends BaseRepository implements ChainStateRepository {
@Override
public ChainState load(String instanceId) {
String key = CacheKey.CHAIN_CACHE_KEY + instanceId;
ChainState chainState = getCache(key, ChainState.class);
if (chainState == null) {
chainState = new ChainState();
chainState.setInstanceId(instanceId);
putCache(key, chainState);
}
return chainState;
}
@Override
public boolean tryUpdate(ChainState newState, EnumSet<ChainStateField> fields) {
String key = CacheKey.CHAIN_CACHE_KEY + newState.getInstanceId();
putCache(key, newState);
return true;
}
}

View File

@@ -0,0 +1,33 @@
package tech.easyflow.ai.easyagentsflow.repository;
import com.easyagents.flow.core.chain.NodeState;
import com.easyagents.flow.core.chain.repository.NodeStateField;
import com.easyagents.flow.core.chain.repository.NodeStateRepository;
import org.springframework.stereotype.Component;
import tech.easyflow.common.constant.CacheKey;
import java.util.EnumSet;
@Component
public class NodeStateRepositoryImpl extends BaseRepository implements NodeStateRepository {
@Override
public NodeState load(String instanceId, String nodeId) {
String key = CacheKey.NODE_CACHE_KEY + instanceId + ":" + nodeId;
NodeState nodeState = getCache(key, NodeState.class);
if (nodeState == null) {
nodeState = new NodeState();
nodeState.setChainInstanceId(instanceId);
nodeState.setNodeId(nodeId);
putCache(key, nodeState);
}
return nodeState;
}
@Override
public boolean tryUpdate(NodeState newState, EnumSet<NodeStateField> fields, long chainStateVersion) {
String key = CacheKey.NODE_CACHE_KEY + newState.getChainInstanceId() + ":" + newState.getNodeId();
putCache(key, newState);
return true;
}
}

View File

@@ -0,0 +1,91 @@
package tech.easyflow.ai.easyagentsflow.service;
import com.easyagents.flow.core.filestoreage.FileStorageManager;
import com.easyagents.flow.core.filestoreage.FileStorageProvider;
import com.easyagents.flow.core.knowledge.KnowledgeManager;
import com.easyagents.flow.core.knowledge.KnowledgeProvider;
import com.easyagents.flow.core.llm.LlmManager;
import com.easyagents.flow.core.llm.LlmProvider;
import com.easyagents.flow.core.parser.ChainParser;
import com.easyagents.flow.core.searchengine.SearchEngine;
import com.easyagents.flow.core.searchengine.SearchEngineManager;
import com.easyagents.flow.core.searchengine.SearchEngineProvider;
import com.easyagents.flow.core.searchengine.impl.BochaaiSearchEngineImpl;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.config.BochaaiProps;
import tech.easyflow.ai.node.*;
import javax.annotation.Resource;
@Component
public class TinyFlowConfigService {
@Resource
private LlmProvider llmProvider;
@Resource
private FileStorageProvider fileStorageProvider;
@Resource
private BochaaiProps bochaaiProps;
@Resource
private KnowledgeProvider knowledgeProvider;
public void initProvidersAndNodeParsers(ChainParser chainParser) {
setExtraNodeParser(chainParser);
setLlmProvider();
setFileStorage();
setKnowledgeProvider();
setSearchEngineProvider();
}
private void setFileStorage() {
FileStorageManager.getInstance().registerProvider(fileStorageProvider);
}
public void setExtraNodeParser(ChainParser chainParser) {
// 文档解析
DocNodeParser docNodeParser = new DocNodeParser();
// 文件生成
MakeFileNodeParser makeFileNodeParser = new MakeFileNodeParser();
// 插件
PluginToolNodeParser pluginToolNodeParser = new PluginToolNodeParser();
// SQL查询
SqlNodeParser sqlNodeParser = new SqlNodeParser();
// 下载文件节点
DownloadNodeParser downloadNodeParser = new DownloadNodeParser();
// 保存数据节点
SaveToDatacenterNodeParser saveDaveParser = new SaveToDatacenterNodeParser();
// 查询数据节点
SearchDatacenterNodeParser searchDatacenterNodeParser = new SearchDatacenterNodeParser();
// 工作流节点
WorkflowNodeParser workflowNodeParser = new WorkflowNodeParser();
chainParser.addNodeParser(docNodeParser.getNodeName(), docNodeParser);
chainParser.addNodeParser(makeFileNodeParser.getNodeName(), makeFileNodeParser);
chainParser.addNodeParser(pluginToolNodeParser.getNodeName(), pluginToolNodeParser);
chainParser.addNodeParser(sqlNodeParser.getNodeName(), sqlNodeParser);
chainParser.addNodeParser(downloadNodeParser.getNodeName(), downloadNodeParser);
chainParser.addNodeParser(saveDaveParser.getNodeName(), saveDaveParser);
chainParser.addNodeParser(searchDatacenterNodeParser.getNodeName(), searchDatacenterNodeParser);
chainParser.addNodeParser(workflowNodeParser.getNodeName(), workflowNodeParser);
}
public void setSearchEngineProvider() {
BochaaiSearchEngineImpl engine = new BochaaiSearchEngineImpl();
engine.setApiKey(bochaaiProps.getApiKey());
SearchEngineManager.getInstance().registerProvider(new SearchEngineProvider() {
@Override
public SearchEngine getSearchEngine(Object id) {
return id.equals("bocha-search") ? engine : null;
}
});
}
public void setLlmProvider() {
LlmManager.getInstance().registerProvider(llmProvider);
}
public void setKnowledgeProvider() {
KnowledgeManager.getInstance().registerProvider(knowledgeProvider);
}
}

View File

@@ -0,0 +1,91 @@
package tech.easyflow.ai.easyagentsflow.service;
import com.easyagents.flow.core.chain.ChainState;
import com.easyagents.flow.core.chain.ExceptionSummary;
import com.easyagents.flow.core.chain.NodeState;
import com.easyagents.flow.core.chain.repository.ChainStateRepository;
import com.easyagents.flow.core.chain.repository.NodeStateRepository;
import com.easyagents.flow.core.chain.runtime.ChainExecutor;
import org.springframework.stereotype.Component;
import tech.easyflow.ai.easyagentsflow.entity.ChainInfo;
import tech.easyflow.ai.easyagentsflow.entity.NodeInfo;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Component
public class TinyFlowService {
@Resource
private ChainExecutor chainExecutor;
/**
* 获取执行状态
*/
public ChainInfo getChainStatus(String executeId, List<NodeInfo> nodes) {
ChainStateRepository chainStateRepository = chainExecutor.getChainStateRepository();
NodeStateRepository nodeStateRepository = chainExecutor.getNodeStateRepository();
ChainState chainState = chainStateRepository.load(executeId);
ChainInfo res = getChainInfo(executeId, chainState);
for (NodeInfo node : nodes) {
processNodeState(executeId, node, chainStateRepository, nodeStateRepository);
res.getNodes().put(node.getNodeId(), node);
}
return res;
}
/**
* 处理节点状态
*/
private void processNodeState(String currentExecuteId,
NodeInfo node,
ChainStateRepository chainStateRepository,
NodeStateRepository nodeStateRepository) {
// 加载当前层的状态
ChainState currentChainState = chainStateRepository.load(currentExecuteId);
NodeState currentNodeState = nodeStateRepository.load(currentExecuteId, node.getNodeId());
setNodeStatus(node, currentNodeState, currentChainState);
}
private static ChainInfo getChainInfo(String executeId, ChainState chainState) {
ChainInfo res = new ChainInfo();
res.setExecuteId(executeId);
res.setStatus(chainState.getStatus().getValue());
ExceptionSummary chainError = chainState.getError();
if (chainError != null) {
res.setMessage(chainError.getRootCauseClass() + " --> " + chainError.getRootCauseMessage());
}
Map<String, Object> executeResult = chainState.getExecuteResult();
if (executeResult != null && !executeResult.isEmpty()) {
res.setResult(executeResult);
}
return res;
}
private void setNodeStatus(NodeInfo node, NodeState nodeState, ChainState chainState) {
String nodeId = node.getNodeId();
// 如果状态为空或不存在,可能不需要覆盖,这里视具体业务逻辑而定,目前保持原逻辑
node.setStatus(nodeState.getStatus().getValue());
ExceptionSummary error = nodeState.getError();
if (error != null) {
node.setMessage(error.getRootCauseClass() + " --> " + error.getRootCauseMessage());
}
Map<String, Object> nodeExecuteResult = chainState.getNodeExecuteResult(nodeId);
if (nodeExecuteResult != null && !nodeExecuteResult.isEmpty()) {
node.setResult(nodeExecuteResult);
}
// 只有当参数不为空时才覆盖
if (chainState.getSuspendForParameters() != null) {
node.setSuspendForParameters(chainState.getSuspendForParameters());
}
}
}

View File

@@ -0,0 +1,31 @@
package tech.easyflow.ai.entity;
import tech.easyflow.ai.entity.base.BotBase;
import com.mybatisflex.annotation.Table;
import java.util.Map;
/**
* 实体类。
*
* @author michael
* @since 2024-08-23
*/
@Table("tb_bot")
public class Bot extends BotBase {
public static final String KEY_SYSTEM_PROMPT = "systemPrompt";
public static final String KEY_MAX_MESSAGE_COUNT = "maxMessageCount";
public static final String KEY_ENABLE_DEEP_THINKING = "enableDeepThinking";
public boolean isAnonymousEnabled() {
Map<String, Object> options = getOptions();
if (options == null) {
return false;
}
Object o = options.get("anonymousEnabled");
return o != null && (boolean) o;
}
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.BotCategoryBase;
/**
* bot分类 实体类。
*
* @author ArkLight
* @since 2025-12-18
*/
@Table(value = "tb_bot_category", comment = "bot分类")
public class BotCategory extends BotCategoryBase {
}

View File

@@ -0,0 +1,41 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.BotConversationBase;
import java.util.List;
/**
* 实体类。
*
* @author Administrator
* @since 2025-04-15
*/
@Table("tb_bot_conversation")
public class BotConversation extends BotConversationBase {
@Column(ignore = true)
private List<BotMessage> botMessageList;
@RelationOneToOne(selfField = "botId", targetField = "id")
private Bot bot;
public List<BotMessage> getAiBotMessageList() {
return botMessageList;
}
public void setAiBotMessageList(List<BotMessage> botMessageList) {
this.botMessageList = botMessageList;
}
public Bot getBot() {
return bot;
}
public void setBot(Bot bot) {
this.bot = bot;
}
}

View File

@@ -0,0 +1,27 @@
package tech.easyflow.ai.entity;
import tech.easyflow.ai.entity.base.BotDocumentCollectionBase;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.annotation.Table;
/**
* 实体类。
*
* @author michael
* @since 2024-08-28
*/
@Table("tb_bot_document_collection")
public class BotDocumentCollection extends BotDocumentCollectionBase {
@RelationOneToOne(selfField = "documentCollectionId", targetField = "id")
private DocumentCollection knowledge;
public DocumentCollection getKnowledge() {
return knowledge;
}
public void setKnowledge(DocumentCollection knowledge) {
this.knowledge = knowledge;
}
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.BotMcpBase;
/**
* 实体类。
*
* @author wangGangQiang
* @since 2026-01-05
*/
@Table("tb_bot_mcp")
public class BotMcp extends BotMcpBase {
}

View File

@@ -0,0 +1,73 @@
package tech.easyflow.ai.entity;
import com.easyagents.core.message.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.BotMessageBase;
import tech.easyflow.core.chat.protocol.ChatDomain;
import tech.easyflow.core.chat.protocol.MessageRole;
/**
* Bot 消息记录表 实体类。
*
* @author michael
* @since 2024-11-04
*/
@Table(value = "tb_bot_message", comment = "Bot 消息记录表")
public class BotMessage extends BotMessageBase {
@Column(ignore = true)
private String key;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public void setContentAndRole(Message msg) {
String jsonMessage = JSON.toJSONString(msg, SerializerFeature.WriteClassName);
super.setContent(jsonMessage);
if (msg instanceof AiMessage) {
super.setRole(MessageRole.ASSISTANT.getValue());
} else if (msg instanceof UserMessage) {
super.setRole(MessageRole.USER.getValue());
} else if (msg instanceof SystemMessage) {
super.setRole(MessageRole.SYSTEM.getValue());
} else if (msg instanceof ToolMessage) {
super.setRole(MessageRole.TOOL.getValue());
}
}
public Message getContentAsMessage() {
String role = getRole();
if (MessageRole.ASSISTANT.getValue().equals(role)) {
return parseMessage(AiMessage.class);
} else if (MessageRole.USER.getValue().equals(role)) {
return parseMessage(UserMessage.class);
} else if (MessageRole.SYSTEM.getValue().equals(role)) {
return parseMessage(SystemMessage.class);
} else if (MessageRole.TOOL.getValue().equals(role)) {
return parseMessage(ToolMessage.class);
}
return null;
}
private <T extends Message> T parseMessage(Class<T> clazz) {
return JSON.parseObject(
getContent(),
clazz,
Feature.SupportClassForName,
Feature.SupportAutoType);
}
}

View File

@@ -0,0 +1,28 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.BotModelBase;
import java.util.Map;
/**
* 实体类。
*
* @author michael
* @since 2024-08-28
*/
@Table("tb_bot_model")
public class BotModel extends BotModelBase {
public Object getOption(String key) {
Map<String, Object> options = super.getOptions();
return options == null ? null : options.get(key);
}
public Object getOptionOrDefault(String key, Object defaultValue) {
Map<String, Object> options = super.getOptions();
return options == null ? defaultValue : options.getOrDefault(key, defaultValue);
}
}

View File

@@ -0,0 +1,27 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.BotPluginBase;
/**
* 实体类。
*
* @author michael
* @since 2025-04-07
*/
@Table("tb_bot_plugin")
public class BotPlugin extends BotPluginBase {
@RelationOneToOne(selfField = "pluginId", targetField = "id")
private Plugin plugin;
public Plugin getAiPlugin() {
return plugin;
}
public void setAiPlugin(Plugin plugin) {
this.plugin = plugin;
}
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.BotRecentlyUsedBase;
/**
* 最近使用 实体类。
*
* @author ArkLight
* @since 2025-12-18
*/
@Table(value = "tb_bot_recently_used", comment = "最近使用")
public class BotRecentlyUsed extends BotRecentlyUsedBase {
}

View File

@@ -0,0 +1,27 @@
package tech.easyflow.ai.entity;
import tech.easyflow.ai.entity.base.BotWorkflowBase;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.annotation.Table;
/**
* 实体类。
*
* @author michael
* @since 2024-08-28
*/
@Table("tb_bot_workflow")
public class BotWorkflow extends BotWorkflowBase {
@RelationOneToOne(selfField = "workflowId", targetField = "id")
private Workflow workflow;
public Workflow getWorkflow() {
return workflow;
}
public void setWorkflow(Workflow workflow) {
this.workflow = workflow;
}
}

View File

@@ -0,0 +1,89 @@
package tech.easyflow.ai.entity;
import com.easyagents.core.message.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public class ChatRequestParams implements Serializable {
private static final long serialVersionUID = 1L;
private BigInteger botId;
private String conversationId;
private List<Message> messages;
public ChatRequestParams() {
}
@JsonProperty("messages")
public void setMessagesFromJson(List<Object> rawMessages) {
if (rawMessages == null) {
this.messages = null;
return;
}
this.messages = new ArrayList<>();
for (Object raw : rawMessages) {
Message message = convertToMessage(raw);
if (message != null) {
this.messages.add(message);
}
}
}
private Message convertToMessage(Object raw) {
JSONObject jsonObj = JSONObject.from(raw);
if (jsonObj == null) {
return null;
}
String role = jsonObj.getString("role");
String content = jsonObj.getString("content");
if (role == null || role.isBlank()) {
throw new IllegalArgumentException("Invalid role: " + role);
}
if ("user".equals(role)) {
if (content == null || content.isBlank()) {
throw new IllegalArgumentException("User message cannot be empty");
}
}
return switch (role) {
case "user" -> jsonObj.toJavaObject(UserMessage.class);
case "system" -> jsonObj.toJavaObject(SystemMessage.class);
case "assistant" -> jsonObj.toJavaObject(AiMessage.class);
case "tool" -> jsonObj.toJavaObject(ToolMessage.class);
default -> {
UserMessage defaultMsg = new UserMessage();
defaultMsg.setContent(content);
yield defaultMsg;
}
};
}
public List<Message> getMessages() {
return messages;
}
public void setMessages(List<Message> messages) {
this.messages = messages;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public String getConversationId() {return conversationId;}
public void setConversationId(String conversationId) {this.conversationId = conversationId;}
}

View File

@@ -0,0 +1,58 @@
package tech.easyflow.ai.entity;
import tech.easyflow.ai.entity.base.DocumentBase;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import java.math.BigInteger;
/**
* 实体类。
*
* @author michael
* @since 2024-08-23
*/
@Table("tb_document")
public class Document extends DocumentBase {
// 每条document对应的有多少条documentChunk分段
@Column(ignore = true)
private BigInteger chunkCount;
/**
* 分块最大长度
*/
@Column(ignore = true)
private int chunkSize;
/**
* 分块之间的重叠长度
*/
@Column(ignore = true)
private int overlapSize;
public BigInteger getChunkCount() {
return chunkCount;
}
public void setChunkCount(BigInteger chunkCount) {
this.chunkCount = chunkCount;
}
public int getChunkSize() {
return chunkSize;
}
public void setChunkSize(int chunkSize) {
this.chunkSize = chunkSize;
}
public int getOverlapSize() {
return overlapSize;
}
public void setOverlapSize(int overlapSize) {
this.overlapSize = overlapSize;
}
}

View File

@@ -0,0 +1,102 @@
package tech.easyflow.ai.entity;
import tech.easyflow.ai.entity.base.DocumentChunkBase;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.annotation.Table;
/**
* 实体类。
*
* @author michael
* @since 2024-08-23
*/
@Table("tb_document_chunk")
public class DocumentChunk extends DocumentChunkBase {
@RelationOneToOne(selfField = "documentId",
targetTable = "tb_document",
targetField = "id",
valueField = "title")
@Column(ignore = true)
private String title;
/**
* 相似度
*/
@Column(ignore = true)
private Double similarityScore;
/**
* 向量 相似度
*/
@Column(ignore = true)
private Double vectorSimilarityScore;
/**
* elasticSearch 相似度
*/
@Column(ignore = true)
private Double elasticSimilarityScore;
/**
* 元数据关键词
*/
@Column(ignore = true)
private String[] metadataKeyWords;
/**
* 元数据问题
*/
@Column(ignore = true)
private String[] metadataQuestions;
public Double getSimilarityScore() {
return similarityScore;
}
public void setSimilarityScore(Double similarityScore) {
this.similarityScore = similarityScore;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String[] getMetadataKeyWords() {
return metadataKeyWords;
}
public void setMetadataKeyWords(String[] metadataKeyWords) {
this.metadataKeyWords = metadataKeyWords;
}
public String[] getMetadataQuestions() {
return metadataQuestions;
}
public void setMetadataQuestions(String[] metadataQuestions) {
this.metadataQuestions = metadataQuestions;
}
public Double getElasticSimilarityScore() {
return elasticSimilarityScore;
}
public void setElasticSimilarityScore(Double elasticSimilarityScore) {
this.elasticSimilarityScore = elasticSimilarityScore;
}
public Double getVectorSimilarityScore() {
return vectorSimilarityScore;
}
public void setVectorSimilarityScore(Double vectorSimilarityScore) {
this.vectorSimilarityScore = vectorSimilarityScore;
}
}

View File

@@ -0,0 +1,160 @@
package tech.easyflow.ai.entity;
import com.easyagents.core.model.chat.tool.Tool;
import com.easyagents.core.store.DocumentStore;
import com.easyagents.store.aliyun.AliyunVectorStore;
import com.easyagents.store.aliyun.AliyunVectorStoreConfig;
import com.easyagents.store.elasticsearch.ElasticSearchVectorStore;
import com.easyagents.store.elasticsearch.ElasticSearchVectorStoreConfig;
import com.easyagents.store.opensearch.OpenSearchVectorStore;
import com.easyagents.store.opensearch.OpenSearchVectorStoreConfig;
import com.easyagents.store.qcloud.QCloudVectorStore;
import com.easyagents.store.qcloud.QCloudVectorStoreConfig;
import com.easyagents.store.redis.RedisVectorStore;
import com.easyagents.store.redis.RedisVectorStoreConfig;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.easyagents.tool.DocumentCollectionTool;
import tech.easyflow.ai.entity.base.DocumentCollectionBase;
import tech.easyflow.common.util.PropertiesUtil;
import tech.easyflow.common.util.StringUtil;
import tech.easyflow.common.web.exceptions.BusinessException;
import java.math.BigDecimal;
import java.util.Map;
/**
* 实体类。
*
* @author michael
* @since 2024-08-23
*/
@Table("tb_document_collection")
public class DocumentCollection extends DocumentCollectionBase {
/**
* 文档块问题集合配置key
*/
public static final String KEY_CHUNK_QUESTION_VECTOR_STORE_COLLECTION = "chunkQuestionVectorStoreCollection";
/**
* 文档块摘要集合配置key
*/
public static final String KEY_CHUNK_SUMMARY_VECTOR_STORE_COLLECTION = "chunkSummaryVectorStoreCollection";
/**
* 知识召回最大条数
*/
public static final String KEY_DOC_RECALL_MAX_NUM = "docRecallMaxNum";
/**
* 相似度最小值
*/
public static final String KEY_SIMILARITY_THRESHOLD = "simThreshold";
/**
* 搜索引擎类型
*/
public static final String KEY_SEARCH_ENGINE_TYPE = "searchEngineType";
/**
* 是否允许更新向量模型
*/
public static final String KEY_CAN_UPDATE_EMBEDDING_MODEL = "canUpdateEmbeddingModel";
public DocumentStore toDocumentStore() {
String storeType = this.getVectorStoreType();
if (StringUtil.noText(storeType)) {
throw new BusinessException("向量数据库类型未设置");
}
if (storeType == null) {
return null;
}
switch (storeType.toLowerCase()) {
case "redis":
return redisStore();
// case "milvus":
// return milvusStore();
case "opensearch":
return openSearchStore();
case "elasticsearch":
return elasticSearchStore();
case "aliyun":
return aliyunStore();
case "qcloud":
return qcloudStore();
}
return null;
}
public boolean isVectorStoreEnabled() {
return this.getVectorStoreEnable() != null && this.getVectorStoreEnable();
}
public boolean isSearchEngineEnabled() {
return this.getSearchEngineEnable() != null && this.getSearchEngineEnable();
}
private DocumentStore redisStore() {
RedisVectorStoreConfig redisVectorStoreConfig = getStoreConfig(RedisVectorStoreConfig.class);
return new RedisVectorStore(redisVectorStoreConfig);
}
// private DocumentStore milvusStore() {
// MilvusVectorStoreConfig milvusVectorStoreConfig = getStoreConfig(MilvusVectorStoreConfig.class);
// return new MilvusVectorStore(milvusVectorStoreConfig);
// }
private DocumentStore openSearchStore() {
OpenSearchVectorStoreConfig openSearchVectorStoreConfig = getStoreConfig(OpenSearchVectorStoreConfig.class);
return new OpenSearchVectorStore(openSearchVectorStoreConfig);
}
private DocumentStore elasticSearchStore() {
ElasticSearchVectorStoreConfig elasticSearchVectorStoreConfig = getStoreConfig(ElasticSearchVectorStoreConfig.class);
return new ElasticSearchVectorStore(elasticSearchVectorStoreConfig);
}
private DocumentStore aliyunStore() {
AliyunVectorStoreConfig aliyunVectorStoreConfig = getStoreConfig(AliyunVectorStoreConfig.class);
return new AliyunVectorStore(aliyunVectorStoreConfig);
}
private DocumentStore qcloudStore() {
QCloudVectorStoreConfig qCloudVectorStoreConfig = getStoreConfig(QCloudVectorStoreConfig.class);
return new QCloudVectorStore(qCloudVectorStoreConfig);
}
private <T> T getStoreConfig(Class<T> clazz) {
return PropertiesUtil.propertiesTextToEntity(this.getVectorStoreConfig(), clazz);
}
public Tool toFunction(boolean needEnglishName) {
return new DocumentCollectionTool(this, needEnglishName);
}
public Object getOptionsByKey(String key) {
Map<String, Object> options = this.getOptions();
if (options == null) {
return null;
}
if (KEY_DOC_RECALL_MAX_NUM.equals(key) && !options.containsKey(KEY_DOC_RECALL_MAX_NUM)) {
return 5;
}
if (KEY_SIMILARITY_THRESHOLD.equals(key)) {
if (!options.containsKey(KEY_SIMILARITY_THRESHOLD)) {
return 0.6f;
} else {
BigDecimal score = (BigDecimal) options.get(key);
return (float) score.doubleValue();
}
}
if (KEY_SEARCH_ENGINE_TYPE.equals(key)) {
if (!options.containsKey(KEY_SEARCH_ENGINE_TYPE)) {
return "lucene";
}
}
return options.get(key);
}
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.DocumentCollectionCategoryBase;
/**
* 实体类。
*
* @author 12076
* @since 2026-01-23
*/
@Table("tb_document_collection_category")
public class DocumentCollectionCategory extends DocumentCollectionCategoryBase {
}

View File

@@ -0,0 +1,146 @@
package tech.easyflow.ai.entity;
import java.io.Serializable;
import java.math.BigInteger;
/**
* 文本拆分参数
*/
public class DocumentCollectionSplitParams implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNumber = 1;
private Integer pageSize = 10;
/**
* 拆分操作 textSplit 拆分预览/ saveText 保存
*/
private String operation;
/**
* 文件路径
*/
private String filePath;
/**
* 文件原始名称
*/
private String fileOriginName;
/**
* 知识库id
*/
private BigInteger knowledgeId;
/**
* 拆分器名称
*/
private String splitterName;
/**
* 分段大小
*/
private Integer chunkSize = 512;
/**
* 重叠大小
*/
private Integer overlapSize = 128;
/**
* 正则表达式
*/
private String regex;
private Integer rowsPerChunk = 1;
/**
* markDown 层级拆分级别
*/
private Integer mdSplitterLevel;
public Integer getPageNumber() {
return pageNumber;
}
public void setPageNumber(Integer pageNumber) {
this.pageNumber = pageNumber;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFileOriginName() {
return fileOriginName;
}
public void setFileOriginName(String fileOriginName) {
this.fileOriginName = fileOriginName;
}
public BigInteger getKnowledgeId() {
return knowledgeId;
}
public void setKnowledgeId(BigInteger knowledgeId) {
this.knowledgeId = knowledgeId;
}
public String getSplitterName() {
return splitterName;
}
public void setSplitterName(String splitterName) {
this.splitterName = splitterName;
}
public Integer getChunkSize() {
return chunkSize;
}
public void setChunkSize(Integer chunkSize) {
this.chunkSize = chunkSize;
}
public Integer getOverlapSize() {
return overlapSize;
}
public void setOverlapSize(Integer overlapSize) {
this.overlapSize = overlapSize;
}
public String getRegex() {
return regex;
}
public void setRegex(String regex) {
this.regex = regex;
}
public Integer getRowsPerChunk() {
return rowsPerChunk;
}
public void setRowsPerChunk(Integer rowsPerChunk) {
this.rowsPerChunk = rowsPerChunk;
}
public Integer getMdSplitterLevel() {
return mdSplitterLevel;
}
public void setMdSplitterLevel(Integer mdSplitterLevel) {
this.mdSplitterLevel = mdSplitterLevel;
}
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import tech.easyflow.ai.entity.base.DocumentHistoryBase;
import com.mybatisflex.annotation.Table;
/**
* 实体类。
*
* @author michael
* @since 2024-08-23
*/
@Table("tb_document_history")
public class DocumentHistory extends DocumentHistoryBase {
}

View File

@@ -0,0 +1,58 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import io.modelcontextprotocol.spec.McpSchema;
import tech.easyflow.ai.entity.base.McpBase;
import java.util.List;
/**
* 实体类。
*
* @author wangGangQiang
* @since 2026-01-04
*/
@Table("tb_mcp")
public class Mcp extends McpBase {
@Column(ignore = true)
private List<McpSchema.Tool> tools;
/**
* 该MCP服务是否存活
*/
@Column(ignore = true)
private boolean alive;
/**
* 客户端健康状态
*/
@Column(ignore = true)
private Boolean clientOnline;
public boolean isAlive() {
return alive;
}
public void setAlive(boolean alive) {
this.alive = alive;
}
public List<McpSchema.Tool> getTools() {
return tools;
}
public void setTools(List<McpSchema.Tool> tools) {
this.tools = tools;
}
public Boolean getClientOnline() {
return clientOnline;
}
public void setClientOnline(Boolean clientOnline) {
this.clientOnline = clientOnline;
}
}

View File

@@ -0,0 +1,185 @@
package tech.easyflow.ai.entity;
import cn.hutool.core.util.StrUtil;
import com.easyagents.core.model.chat.ChatModel;
import com.easyagents.core.model.embedding.EmbeddingModel;
import com.easyagents.core.model.rerank.RerankModel;
import com.easyagents.core.store.VectorData;
import com.easyagents.embedding.ollama.OllamaEmbeddingConfig;
import com.easyagents.embedding.ollama.OllamaEmbeddingModel;
import com.easyagents.embedding.openai.OpenAIEmbeddingConfig;
import com.easyagents.embedding.openai.OpenAIEmbeddingModel;
import com.easyagents.llm.deepseek.DeepseekChatModel;
import com.easyagents.llm.deepseek.DeepseekConfig;
import com.easyagents.llm.ollama.OllamaChatConfig;
import com.easyagents.llm.ollama.OllamaChatModel;
import com.easyagents.llm.openai.OpenAIChatConfig;
import com.easyagents.llm.openai.OpenAIChatModel;
import com.easyagents.rerank.DefaultRerankModel;
import com.easyagents.rerank.DefaultRerankModelConfig;
import com.easyagents.rerank.gitee.GiteeRerankModel;
import com.easyagents.rerank.gitee.GiteeRerankModelConfig;
import com.mybatisflex.annotation.RelationManyToOne;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.ModelBase;
import tech.easyflow.common.util.StringUtil;
import tech.easyflow.common.web.exceptions.BusinessException;
/**
* 实体类。
*
* @author michael
* @since 2024-08-23
*/
@Table("tb_model")
public class Model extends ModelBase {
@RelationManyToOne(selfField = "providerId", targetField = "id")
private ModelProvider modelProvider;
/**
* 模型类型
*/
public final static String[] MODEL_TYPES = {"chatModel", "embeddingModel", "rerankModel"};
public ModelProvider getModelProvider() {
return modelProvider;
}
public void setModelProvider(ModelProvider modelProvider) {
this.modelProvider = modelProvider;
}
public ChatModel toChatModel() {
String providerType = modelProvider.getProviderType();
if (StringUtil.noText(providerType)) {
return null;
}
switch (providerType.toLowerCase()) {
case "ollama":
OllamaChatConfig ollamaChatConfig = new OllamaChatConfig();
ollamaChatConfig.setEndpoint(checkAndGetEndpoint());
if (StringUtil.hasText(getApiKey())) {
ollamaChatConfig.setApiKey(checkAndGetApiKey());
}
ollamaChatConfig.setModel(checkAndGetModelName());
ollamaChatConfig.setProvider(getModelProvider().getProviderName());
return new OllamaChatModel(ollamaChatConfig);
case "deepseek":
DeepseekConfig deepseekConfig = new DeepseekConfig();
deepseekConfig.setProvider(getModelProvider().getProviderName());
deepseekConfig.setEndpoint(checkAndGetEndpoint());
deepseekConfig.setApiKey(checkAndGetApiKey());
deepseekConfig.setModel(checkAndGetModelName());
deepseekConfig.setRequestPath(checkAndGetRequestPath());
return new DeepseekChatModel(deepseekConfig);
default:
OpenAIChatConfig openAIChatConfig = new OpenAIChatConfig();
openAIChatConfig.setProvider(getModelProvider().getProviderName());
openAIChatConfig.setEndpoint(checkAndGetEndpoint());
openAIChatConfig.setApiKey(checkAndGetApiKey());
openAIChatConfig.setModel(checkAndGetModelName());
openAIChatConfig.setRequestPath(checkAndGetRequestPath());
if (getSupportToolMessage() != null) {
openAIChatConfig.setSupportToolMessage(getSupportToolMessage());
}
return new OpenAIChatModel(openAIChatConfig);
}
}
public RerankModel toRerankModel() {
switch (modelProvider.getProviderType().toLowerCase()) {
case "gitee":
GiteeRerankModelConfig giteeRerankModelConfig = new GiteeRerankModelConfig();
giteeRerankModelConfig.setProvider(getModelProvider().getProviderName());
giteeRerankModelConfig.setApiKey(checkAndGetApiKey());
giteeRerankModelConfig.setEndpoint(checkAndGetEndpoint());
giteeRerankModelConfig.setModel(checkAndGetModelName());
giteeRerankModelConfig.setRequestPath(checkAndGetRequestPath());
return new GiteeRerankModel(giteeRerankModelConfig);
default:
DefaultRerankModelConfig defaultRerankModelConfig = new DefaultRerankModelConfig();
defaultRerankModelConfig.setProvider(getModelProvider().getProviderName());
defaultRerankModelConfig.setApiKey(checkAndGetApiKey());
defaultRerankModelConfig.setEndpoint(checkAndGetEndpoint());
defaultRerankModelConfig.setRequestPath(checkAndGetRequestPath());
defaultRerankModelConfig.setModel(checkAndGetModelName());
return new DefaultRerankModel(defaultRerankModelConfig);
}
}
public EmbeddingModel toEmbeddingModel() {
String providerType = modelProvider.getProviderType();
if (StringUtil.noText(providerType)) {
return null;
}
try {
switch (providerType.toLowerCase()) {
case "ollama":
OllamaEmbeddingConfig ollamaEmbeddingConfig = new OllamaEmbeddingConfig();
ollamaEmbeddingConfig.setProvider(getModelProvider().getProviderName());
ollamaEmbeddingConfig.setEndpoint(checkAndGetEndpoint());
ollamaEmbeddingConfig.setApiKey(getApiKey());
ollamaEmbeddingConfig.setModel(checkAndGetModelName());
ollamaEmbeddingConfig.setRequestPath(getRequestPath());
return new OllamaEmbeddingModel(ollamaEmbeddingConfig);
default:
OpenAIEmbeddingConfig openAIEmbeddingConfig = new OpenAIEmbeddingConfig();
openAIEmbeddingConfig.setProvider(getModelProvider().getProviderName());
openAIEmbeddingConfig.setEndpoint(checkAndGetEndpoint());
openAIEmbeddingConfig.setApiKey(checkAndGetApiKey());
openAIEmbeddingConfig.setModel(checkAndGetModelName());
openAIEmbeddingConfig.setRequestPath(checkAndGetRequestPath());
return new OpenAIEmbeddingModel(openAIEmbeddingConfig);
}
} catch (Exception e) {
throw new BusinessException("向量模型配置失败:" + e.getMessage());
}
}
/**
* 获取模型向量的维度
*
* @return
*/
public static int getEmbeddingDimension(EmbeddingModel embeddingModel) {
if (embeddingModel == null) {
throw new BusinessException("embeddingModel不能为空");
}
VectorData vectorData = embeddingModel.embed("测试向量维度");
return vectorData.getVector().length;
}
public String checkAndGetRequestPath() {
if (StrUtil.isEmpty(getRequestPath())) {
throw new BusinessException("请求地址不能为空");
}
return getRequestPath();
}
public String checkAndGetApiKey() {
if (StrUtil.isEmpty(getApiKey())) {
throw new BusinessException("API 密钥不能为空");
}
return getApiKey();
}
public String checkAndGetEndpoint() {
if (StrUtil.isEmpty(getEndpoint())) {
throw new BusinessException("API 地址不能为空");
}
return getEndpoint();
}
public String checkAndGetModelName() {
if (StrUtil.isEmpty(getModelName())) {
throw new BusinessException("模型名称不能为空");
}
return getModelName();
}
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.ModelProviderBase;
/**
* 实体类。
*
* @author 12076
* @since 2025-12-16
*/
@Table("tb_model_provider")
public class ModelProvider extends ModelProviderBase {
}

View File

@@ -0,0 +1,33 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.RelationOneToMany;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.PluginBase;
import java.util.List;
/**
* 实体类。
*
* @author Administrator
* @since 2025-04-25
*/
@Table("tb_plugin")
public class Plugin extends PluginBase {
@RelationOneToMany(selfField = "id", targetField = "pluginId", targetTable = "tb_plugin_item")
private List<PluginItem> tools;
public String getTitle() {
return this.getName();
}
public List<PluginItem> getTools() {
return tools;
}
public void setTools(List<PluginItem> tools) {
this.tools = tools;
}
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.PluginCategoryBase;
/**
* 实体类。
*
* @author Administrator
* @since 2025-05-21
*/
@Table("tb_plugin_category")
public class PluginCategory extends PluginCategoryBase {
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.PluginCategoryMappingBase;
/**
* 实体类。
*
* @author Administrator
* @since 2025-05-21
*/
@Table("tb_plugin_category_mapping")
public class PluginCategoryMapping extends PluginCategoryMappingBase {
}

View File

@@ -0,0 +1,34 @@
package tech.easyflow.ai.entity;
import com.easyagents.core.model.chat.tool.Tool;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.easyagents.tool.PluginTool;
import tech.easyflow.ai.entity.base.PluginItemBase;
/**
* 实体类。
*
* @author Administrator
* @since 2025-04-27
*/
@Table("tb_plugin_item")
public class PluginItem extends PluginItemBase {
@Column(ignore = true)
private boolean joinBot;
public boolean isJoinBot() {
return joinBot;
}
public void setJoinBot(boolean joinBot) {
this.joinBot = joinBot;
}
public Tool toFunction() {
return new PluginTool(this);
}
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.ResourceBase;
/**
* 素材库 实体类。
*
* @author ArkLight
* @since 2025-06-27
*/
@Table(value = "tb_resource", comment = "素材库")
public class Resource extends ResourceBase {
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.ResourceCategoryBase;
/**
* 素材分类 实体类。
*
* @author ArkLight
* @since 2025-12-24
*/
@Table(value = "tb_resource_category", comment = "素材分类")
public class ResourceCategory extends ResourceCategoryBase {
}

View File

@@ -0,0 +1,21 @@
package tech.easyflow.ai.entity;
import com.easyagents.core.model.chat.tool.Tool;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.easyagents.tool.WorkflowTool;
import tech.easyflow.ai.entity.base.WorkflowBase;
/**
* 实体类。
*
* @author michael
* @since 2024-08-23
*/
@Table("tb_workflow")
public class Workflow extends WorkflowBase {
public Tool toFunction(boolean needEnglishName) {
return new WorkflowTool(this, needEnglishName);
}
}

View File

@@ -0,0 +1,15 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.WorkflowCategoryBase;
/**
* 实体类。
*
* @author ArkLight
* @since 2025-12-11
*/
@Table("tb_workflow_category")
public class WorkflowCategory extends WorkflowCategoryBase {
}

View File

@@ -0,0 +1,22 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.WorkflowExecResultBase;
/**
* 工作流执行记录 实体类。
*
* @author ArkLight
* @since 2025-05-28
*/
@Table(value = "tb_workflow_exec_result", comment = "工作流执行记录")
public class WorkflowExecResult extends WorkflowExecResultBase {
public Long getExecTime() {
if (getEndTime() == null) {
return null;
}
return getEndTime().getTime() - getStartTime().getTime();
}
}

View File

@@ -0,0 +1,37 @@
package tech.easyflow.ai.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import tech.easyflow.ai.entity.base.WorkflowExecStepBase;
/**
* 执行记录步骤 实体类。
*
* @author ArkLight
* @since 2025-05-28
*/
@Table(value = "tb_workflow_exec_step", comment = "执行记录步骤")
public class WorkflowExecStep extends WorkflowExecStepBase {
/**
* 节点类型agentsflex里没有这个属性
*/
@Column(ignore = true)
private String nodeType;
public Long getExecTime() {
if (getEndTime() == null) {
return null;
}
return getEndTime().getTime() - getStartTime().getTime();
}
public String getNodeType() {
return nodeType;
}
public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}
}

View File

@@ -0,0 +1,242 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import tech.easyflow.common.entity.DateEntity;
public class BotBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键ID")
private BigInteger id;
/**
* 别名
*/
@Column(comment = "别名")
private String alias;
/**
* 部门ID
*/
@Column(comment = "部门ID")
private BigInteger deptId;
/**
* 租户ID
*/
@Column(tenantId = true, comment = "租户ID")
private BigInteger tenantId;
/**
* 分类ID
*/
@Column(comment = "分类ID")
private BigInteger categoryId;
/**
* 标题
*/
@Column(comment = "标题")
private String title;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* 图标
*/
@Column(comment = "图标")
private String icon;
/**
* 模型 ID
*/
@Column(comment = "模型 ID")
private BigInteger modelId;
/**
* 模型配置
*/
@Column(typeHandler = FastjsonTypeHandler.class, comment = "模型配置")
private Map<String, Object> modelOptions;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
/**
* 选项
*/
@Column(typeHandler = FastjsonTypeHandler.class, comment = "选项")
private Map<String, Object> options;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者ID
*/
@Column(comment = "创建者ID")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者ID
*/
@Column(comment = "修改者ID")
private BigInteger modifiedBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public BigInteger getDeptId() {
return deptId;
}
public void setDeptId(BigInteger deptId) {
this.deptId = deptId;
}
public BigInteger getTenantId() {
return tenantId;
}
public void setTenantId(BigInteger tenantId) {
this.tenantId = tenantId;
}
public BigInteger getCategoryId() {
return categoryId;
}
public void setCategoryId(BigInteger categoryId) {
this.categoryId = categoryId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public BigInteger getModelId() {
return modelId;
}
public void setModelId(BigInteger modelId) {
this.modelId = modelId;
}
public Map<String, Object> getModelOptions() {
return modelOptions;
}
public void setModelOptions(Map<String, Object> modelOptions) {
this.modelOptions = modelOptions;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
}

View File

@@ -0,0 +1,128 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class BotCategoryBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* 分类名称
*/
@Column(comment = "分类名称")
private String categoryName;
/**
* 排序
*/
@Column(comment = "排序")
private Integer sortNo;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者
*/
@Column(comment = "创建者")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者
*/
@Column(comment = "修改者")
private BigInteger modifiedBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
}

View File

@@ -0,0 +1,116 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class BotConversationBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 会话id
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "会话id")
private BigInteger id;
/**
* 会话标题
*/
@Column(comment = "会话标题")
private String title;
/**
* botid
*/
@Column(comment = "botid")
private BigInteger botId;
/**
* 账户 id
*/
@Column(comment = "账户 id")
private BigInteger accountId;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
private BigInteger createdBy;
private Date modified;
private BigInteger modifiedBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public BigInteger getAccountId() {
return accountId;
}
public void setAccountId(BigInteger accountId) {
this.accountId = accountId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
}

View File

@@ -0,0 +1,58 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Map;
public class BotDocumentCollectionBase implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto, value = "snowFlakeId")
private BigInteger id;
private BigInteger botId;
private BigInteger documentCollectionId;
@Column(typeHandler = FastjsonTypeHandler.class)
private Map<String, Object> options;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public BigInteger getDocumentCollectionId() {
return documentCollectionId;
}
public void setDocumentCollectionId(BigInteger documentCollectionId) {
this.documentCollectionId = documentCollectionId;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
}

View File

@@ -0,0 +1,73 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
public class BotMcpBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "id")
private BigInteger id;
/**
* botId
*/
@Column(comment = "botId")
private BigInteger botId;
/**
* mcpId
*/
@Column(comment = "mcpId")
private BigInteger mcpId;
/**
* mcp工具名称
*/
@Column(comment = "mcp工具名称")
private String mcpToolName;
/**
* mcp工具描述
*/
@Column(comment = "mcp工具描述")
private String mcpToolDescription;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public BigInteger getMcpId() {
return mcpId;
}
public void setMcpId(BigInteger mcpId) {this.mcpId = mcpId;}
public String getMcpToolName() {return mcpToolName;}
public void setMcpToolName(String mcpToolName) {this.mcpToolName = mcpToolName;}
public String getMcpToolDescription() {return mcpToolDescription;}
public void setMcpToolDescription(String mcpToolDescription) {this.mcpToolDescription = mcpToolDescription;}
}

View File

@@ -0,0 +1,158 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import tech.easyflow.common.entity.DateEntity;
public class BotMessageBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "ID")
private BigInteger id;
/**
* botId
*/
@Column(comment = "botId")
private BigInteger botId;
/**
* 关联的账户ID
*/
@Column(comment = "关联的账户ID")
private BigInteger accountId;
/**
* 会话ID
*/
@Column(comment = "会话ID")
private BigInteger conversationId;
/**
* 角色[user|assistant]
*/
@Column(comment = "角色[user|assistant]")
private String role;
/**
* 内容
*/
@Column(comment = "内容")
private String content;
/**
* 图片
*/
@Column(comment = "图片")
private String image;
/**
* 选项
*/
@Column(typeHandler = FastjsonTypeHandler.class, comment = "选项")
private Map<String, Object> options;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 更新时间
*/
@Column(comment = "更新时间")
private Date modified;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public BigInteger getAccountId() {
return accountId;
}
public void setAccountId(BigInteger accountId) {
this.accountId = accountId;
}
public BigInteger getConversationId() {
return conversationId;
}
public void setConversationId(BigInteger conversationId) {
this.conversationId = conversationId;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
}

View File

@@ -0,0 +1,58 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Map;
public class BotModelBase implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Generator, value = "snowFlakeId")
private BigInteger id;
private BigInteger botId;
private BigInteger modelId;
@Column(typeHandler = FastjsonTypeHandler.class)
private Map<String, Object> options;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public BigInteger getModelId() {
return modelId;
}
public void setModelId(BigInteger modelId) {
this.modelId = modelId;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
}

View File

@@ -0,0 +1,58 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Map;
public class BotPluginBase implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Generator, value = "snowFlakeId")
private BigInteger id;
private BigInteger botId;
private BigInteger pluginItemId;
@Column(typeHandler = FastjsonTypeHandler.class)
private Map<String, Object> options;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public BigInteger getPluginItemId() {
return pluginItemId;
}
public void setPluginItemId(BigInteger pluginItemId) {
this.pluginItemId = pluginItemId;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
}

View File

@@ -0,0 +1,85 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
public class BotRecentlyUsedBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* botId
*/
@Column(comment = "botId")
private BigInteger botId;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者
*/
@Column(comment = "创建者")
private BigInteger createdBy;
/**
* 排序
*/
@Column(comment = "排序")
private Integer sortNo;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
}

View File

@@ -0,0 +1,58 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Map;
public class BotWorkflowBase implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Generator, value = "snowFlakeId")
private BigInteger id;
private BigInteger botId;
private BigInteger workflowId;
@Column(typeHandler = FastjsonTypeHandler.class)
private Map<String, Object> options;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getBotId() {
return botId;
}
public void setBotId(BigInteger botId) {
this.botId = botId;
}
public BigInteger getWorkflowId() {
return workflowId;
}
public void setWorkflowId(BigInteger workflowId) {
this.workflowId = workflowId;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
}

View File

@@ -0,0 +1,211 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import tech.easyflow.common.entity.DateEntity;
public class DocumentBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Generator, value = "snowFlakeId")
private BigInteger id;
/**
* 知识库ID
*/
@Column(comment = "知识库ID")
private BigInteger collectionId;
/**
* 文档类型 pdf/word/aieditor 等
*/
@Column(comment = "文档类型 pdf/word/aieditor 等")
private String documentType;
/**
* 文档路径
*/
@Column(comment = "文档路径")
private String documentPath;
/**
* 标题
*/
@Column(comment = "标题")
private String title;
/**
* 内容
*/
@Column(comment = "内容")
private String content;
/**
* 内容类型
*/
@Column(comment = "内容类型")
private String contentType;
/**
* URL 别名
*/
@Column(comment = "URL 别名")
private String slug;
/**
* 排序序号
*/
@Column(comment = "排序序号")
private Integer orderNo;
/**
* 其他配置项
*/
@Column(typeHandler = FastjsonTypeHandler.class, comment = "其他配置项")
private Map<String, Object> options;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建人ID
*/
@Column(comment = "创建人ID")
private BigInteger createdBy;
/**
* 最后的修改时间
*/
@Column(comment = "最后的修改时间")
private Date modified;
/**
* 最后的修改人的ID
*/
@Column(comment = "最后的修改人的ID")
private BigInteger modifiedBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getCollectionId() {
return collectionId;
}
public void setCollectionId(BigInteger collectionId) {
this.collectionId = collectionId;
}
public String getDocumentType() {
return documentType;
}
public void setDocumentType(String documentType) {
this.documentType = documentType;
}
public String getDocumentPath() {
return documentPath;
}
public void setDocumentPath(String documentPath) {
this.documentPath = documentPath;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getSlug() {
return slug;
}
public void setSlug(String slug) {
this.slug = slug;
}
public Integer getOrderNo() {
return orderNo;
}
public void setOrderNo(Integer orderNo) {
this.orderNo = orderNo;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
}

View File

@@ -0,0 +1,81 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
public class DocumentChunkBase implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Generator, value = "snowFlakeId")
private BigInteger id;
/**
* 文档ID
*/
@Column(comment = "文档ID")
private BigInteger documentId;
/**
* 知识库ID
*/
@Column(comment = "知识库ID")
private BigInteger documentCollectionId;
/**
* 分块内容
*/
@Column(comment = "分块内容")
private String content;
/**
* 分割顺序
*/
@Column(comment = "分割顺序")
private Integer sorting;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getDocumentId() {
return documentId;
}
public void setDocumentId(BigInteger documentId) {
this.documentId = documentId;
}
public BigInteger getDocumentCollectionId() {
return documentCollectionId;
}
public void setDocumentCollectionId(BigInteger documentCollectionId) {
this.documentCollectionId = documentCollectionId;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getSorting() {
return sorting;
}
public void setSorting(Integer sorting) {
this.sorting = sorting;
}
}

View File

@@ -0,0 +1,340 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import tech.easyflow.common.entity.DateEntity;
public class DocumentCollectionBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Id
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "Id")
private BigInteger id;
/**
* 别名
*/
@Column(comment = "别名")
private String alias;
/**
* 部门ID
*/
@Column(comment = "部门ID")
private BigInteger deptId;
/**
* 租户ID
*/
@Column(tenantId = true, comment = "租户ID")
private BigInteger tenantId;
/**
* ICON
*/
@Column(comment = "ICON")
private String icon;
/**
* 标题
*/
@Column(comment = "标题")
private String title;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* URL 别名
*/
@Column(comment = "URL 别名")
private String slug;
/**
* 是否启用向量存储
*/
@Column(comment = "是否启用向量存储")
private Boolean vectorStoreEnable;
/**
* 向量数据库类型
*/
@Column(comment = "向量数据库类型")
private String vectorStoreType;
/**
* 向量数据库集合
*/
@Column(comment = "向量数据库集合")
private String vectorStoreCollection;
/**
* 向量数据库配置
*/
@Column(comment = "向量数据库配置")
private String vectorStoreConfig;
/**
* Embedding 模型ID
*/
@Column(comment = "Embedding 模型ID")
private BigInteger vectorEmbedModelId;
/**
* 向量模型维度
*/
@Column(comment = "向量模型维度")
private Integer dimensionOfVectorModel;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建用户ID
*/
@Column(comment = "创建用户ID")
private BigInteger createdBy;
/**
* 最后一次修改时间
*/
@Column(comment = "最后一次修改时间")
private Date modified;
/**
* 最后一次修改用户ID
*/
@Column(comment = "最后一次修改用户ID")
private BigInteger modifiedBy;
/**
* 其他配置
*/
@Column(typeHandler = FastjsonTypeHandler.class, comment = "其他配置")
private Map<String, Object> options;
/**
* 重排模型id
*/
@Column(comment = "重排模型id")
private BigInteger rerankModelId;
/**
* 是否启用搜索引擎
*/
@Column(comment = "是否启用搜索引擎")
private Boolean searchEngineEnable;
/**
* 英文名称
*/
@Column(comment = "英文名称")
private String englishName;
/**
* 分类ID
*/
@Column(comment = "分类ID")
private BigInteger categoryId;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public BigInteger getDeptId() {
return deptId;
}
public void setDeptId(BigInteger deptId) {
this.deptId = deptId;
}
public BigInteger getTenantId() {
return tenantId;
}
public void setTenantId(BigInteger tenantId) {
this.tenantId = tenantId;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSlug() {
return slug;
}
public void setSlug(String slug) {
this.slug = slug;
}
public Boolean getVectorStoreEnable() {
return vectorStoreEnable;
}
public void setVectorStoreEnable(Boolean vectorStoreEnable) {
this.vectorStoreEnable = vectorStoreEnable;
}
public String getVectorStoreType() {
return vectorStoreType;
}
public void setVectorStoreType(String vectorStoreType) {
this.vectorStoreType = vectorStoreType;
}
public String getVectorStoreCollection() {
return vectorStoreCollection;
}
public void setVectorStoreCollection(String vectorStoreCollection) {
this.vectorStoreCollection = vectorStoreCollection;
}
public String getVectorStoreConfig() {
return vectorStoreConfig;
}
public void setVectorStoreConfig(String vectorStoreConfig) {
this.vectorStoreConfig = vectorStoreConfig;
}
public BigInteger getVectorEmbedModelId() {
return vectorEmbedModelId;
}
public void setVectorEmbedModelId(BigInteger vectorEmbedModelId) {
this.vectorEmbedModelId = vectorEmbedModelId;
}
public Integer getDimensionOfVectorModel() {
return dimensionOfVectorModel;
}
public void setDimensionOfVectorModel(Integer dimensionOfVectorModel) {
this.dimensionOfVectorModel = dimensionOfVectorModel;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
public BigInteger getRerankModelId() {
return rerankModelId;
}
public void setRerankModelId(BigInteger rerankModelId) {
this.rerankModelId = rerankModelId;
}
public Boolean getSearchEngineEnable() {
return searchEngineEnable;
}
public void setSearchEngineEnable(Boolean searchEngineEnable) {
this.searchEngineEnable = searchEngineEnable;
}
public String getEnglishName() {
return englishName;
}
public void setEnglishName(String englishName) {
this.englishName = englishName;
}
public BigInteger getCategoryId() {
return categoryId;
}
public void setCategoryId(BigInteger categoryId) {
this.categoryId = categoryId;
}
}

View File

@@ -0,0 +1,128 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class DocumentCollectionCategoryBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* 分类名称
*/
@Column(comment = "分类名称")
private String categoryName;
/**
* 排序
*/
@Column(comment = "排序")
private Integer sortNo;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者
*/
@Column(comment = "创建者")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者
*/
@Column(comment = "修改者")
private BigInteger modifiedBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
}

View File

@@ -0,0 +1,152 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
public class DocumentHistoryBase implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto, value = "snowFlakeId")
private BigInteger id;
/**
* 修改的文档ID
*/
@Column(comment = "修改的文档ID")
private Long documentId;
/**
* 旧标题
*/
@Column(comment = "旧标题")
private String oldTitle;
/**
* 新标题
*/
@Column(comment = "新标题")
private String newTitle;
/**
* 旧内容
*/
@Column(comment = "旧内容")
private String oldContent;
/**
* 新内容
*/
@Column(comment = "新内容")
private String newContent;
/**
* 旧的文档类型
*/
@Column(comment = "旧的文档类型")
private String oldDocumentType;
/**
* 新的额文档类型
*/
@Column(comment = "新的额文档类型")
private String newDocumentType;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建人ID
*/
@Column(comment = "创建人ID")
private Long createdBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public Long getDocumentId() {
return documentId;
}
public void setDocumentId(Long documentId) {
this.documentId = documentId;
}
public String getOldTitle() {
return oldTitle;
}
public void setOldTitle(String oldTitle) {
this.oldTitle = oldTitle;
}
public String getNewTitle() {
return newTitle;
}
public void setNewTitle(String newTitle) {
this.newTitle = newTitle;
}
public String getOldContent() {
return oldContent;
}
public void setOldContent(String oldContent) {
this.oldContent = oldContent;
}
public String getNewContent() {
return newContent;
}
public void setNewContent(String newContent) {
this.newContent = newContent;
}
public String getOldDocumentType() {
return oldDocumentType;
}
public void setOldDocumentType(String oldDocumentType) {
this.oldDocumentType = oldDocumentType;
}
public String getNewDocumentType() {
return newDocumentType;
}
public void setNewDocumentType(String newDocumentType) {
this.newDocumentType = newDocumentType;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Long getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
}

View File

@@ -0,0 +1,170 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class McpBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "id")
private BigInteger id;
/**
* 标题
*/
@Column(comment = "标题")
private String title;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* 完整MCP配置JSON
*/
@Column(comment = "完整MCP配置JSON")
private String configJson;
/**
* 部门ID
*/
@Column(comment = "部门ID")
private BigInteger deptId;
/**
* 租户ID
*/
@Column(tenantId = true, comment = "租户ID")
private BigInteger tenantId;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者ID
*/
@Column(comment = "创建者ID")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者ID
*/
@Column(comment = "修改者ID")
private BigInteger modifiedBy;
/**
* 是否启用
*/
@Column(comment = "是否启用")
private Boolean status;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getConfigJson() {
return configJson;
}
public void setConfigJson(String configJson) {
this.configJson = configJson;
}
public BigInteger getDeptId() {
return deptId;
}
public void setDeptId(BigInteger deptId) {
this.deptId = deptId;
}
public BigInteger getTenantId() {
return tenantId;
}
public void setTenantId(BigInteger tenantId) {
this.tenantId = tenantId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
this.status = status;
}
}

View File

@@ -0,0 +1,352 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Map;
public class ModelBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "ID")
private BigInteger id;
/**
* 部门ID
*/
@Column(comment = "部门ID")
private BigInteger deptId;
/**
* 租户ID
*/
@Column(tenantId = true, comment = "租户ID")
private BigInteger tenantId;
/**
* 供应商id
*/
@Column(comment = "供应商id")
private BigInteger providerId;
/**
* 标题或名称
*/
@Column(comment = "标题或名称")
private String title;
/**
* ICON
*/
@Column(comment = "ICON")
private String icon;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* 大模型请求地址
*/
@Column(comment = "大模型请求地址")
private String endpoint;
/**
* 请求路径
*/
@Column(comment = "请求路径")
private String requestPath;
/**
* 大模型名称
*/
@Column(comment = "大模型名称")
private String modelName;
/**
* 大模型 API KEY
*/
@Column(comment = "大模型 API KEY")
private String apiKey;
/**
* 大模型其他属性配置
*/
@Column(comment = "大模型其他属性配置")
private String extraConfig;
/**
* 其他配置内容
*/
@Column(typeHandler = FastjsonTypeHandler.class, comment = "其他配置内容")
private Map<String, Object> options;
/**
* 分组名称
*/
@Column(comment = "分组名称")
private String groupName;
/**
* 模型类型: chatModel/embeddingModel/rerankModel/orc..
*/
@Column(comment = "模型类型: chatModel/embeddingModel/rerankModel/orc..")
private String modelType;
/**
* 是否使用
*/
@Column(comment = "是否使用")
private Boolean withUsed;
/**
* 是否支持推理
*/
@Column(comment = "是否支持推理")
private Boolean supportThinking;
/**
* 是否支持工具
*/
@Column(comment = "是否支持工具")
private Boolean supportTool;
/**
* 是否支持图片
*/
@Column(comment = "是否支持图片")
private Boolean supportImage;
/**
* 仅支持 base64 的图片类型
*/
@Column(comment = "仅支持 base64 的图片类型")
private Boolean supportImageB64Only;
/**
* 是否支持视频
*/
@Column(comment = "是否支持视频")
private Boolean supportVideo;
/**
* 是否支持音频
*/
@Column(comment = "是否支持音频")
private Boolean supportAudio;
/**
* 是否免费
*/
@Column(comment = "是否免费")
private Boolean supportFree;
/**
* 是否支持tool消息
*/
@Column(comment = "是否支持tool消息")
private Boolean supportToolMessage;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getDeptId() {
return deptId;
}
public void setDeptId(BigInteger deptId) {
this.deptId = deptId;
}
public BigInteger getTenantId() {
return tenantId;
}
public void setTenantId(BigInteger tenantId) {
this.tenantId = tenantId;
}
public BigInteger getProviderId() {
return providerId;
}
public void setProviderId(BigInteger providerId) {
this.providerId = providerId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public String getRequestPath() {
return requestPath;
}
public void setRequestPath(String requestPath) {
this.requestPath = requestPath;
}
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getExtraConfig() {
return extraConfig;
}
public void setExtraConfig(String extraConfig) {
this.extraConfig = extraConfig;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getModelType() {
return modelType;
}
public void setModelType(String modelType) {
this.modelType = modelType;
}
public Boolean getWithUsed() {
return withUsed;
}
public void setWithUsed(Boolean withUsed) {
this.withUsed = withUsed;
}
public Boolean getSupportThinking() {
return supportThinking;
}
public void setSupportThinking(Boolean supportThinking) {
this.supportThinking = supportThinking;
}
public Boolean getSupportTool() {
return supportTool;
}
public void setSupportTool(Boolean supportTool) {
this.supportTool = supportTool;
}
public Boolean getSupportImage() {
return supportImage;
}
public void setSupportImage(Boolean supportImage) {
this.supportImage = supportImage;
}
public Boolean getSupportImageB64Only() {
return supportImageB64Only;
}
public void setSupportImageB64Only(Boolean supportImageB64Only) {
this.supportImageB64Only = supportImageB64Only;
}
public Boolean getSupportVideo() {
return supportVideo;
}
public void setSupportVideo(Boolean supportVideo) {
this.supportVideo = supportVideo;
}
public Boolean getSupportAudio() {
return supportAudio;
}
public void setSupportAudio(Boolean supportAudio) {
this.supportAudio = supportAudio;
}
public Boolean getSupportFree() {
return supportFree;
}
public void setSupportFree(Boolean supportFree) {
this.supportFree = supportFree;
}
public Boolean getSupportToolMessage() {
return supportToolMessage;
}
public void setSupportToolMessage(Boolean supportToolMessage) {
this.supportToolMessage = supportToolMessage;
}
}

View File

@@ -0,0 +1,198 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class ModelProviderBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "id")
private BigInteger id;
/**
* 供应商名称
*/
@Column(comment = "供应商名称")
private String providerName;
/**
* 不同的 client 实现,默认为 openai
*/
@Column(comment = "不同的 client 实现,默认为 openai")
private String providerType;
/**
* 图标
*/
@Column(comment = "图标")
private String icon;
/**
* apiKey
*/
@Column(comment = "apiKey")
private String apiKey;
/**
* endPoint
*/
@Column(comment = "endPoint")
private String endpoint;
/**
* 对话地址
*/
@Column(comment = "对话地址")
private String chatPath;
/**
* 向量地址
*/
@Column(comment = "向量地址")
private String embedPath;
/**
* 重排路径
*/
@Column(comment = "重排路径")
private String rerankPath;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者
*/
@Column(comment = "创建者")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者
*/
@Column(comment = "修改者")
private BigInteger modifiedBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getProviderName() {
return providerName;
}
public void setProviderName(String providerName) {
this.providerName = providerName;
}
public String getProviderType() {
return providerType;
}
public void setProviderType(String providerType) {
this.providerType = providerType;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public String getChatPath() {
return chatPath;
}
public void setChatPath(String chatPath) {
this.chatPath = chatPath;
}
public String getEmbedPath() {
return embedPath;
}
public void setEmbedPath(String embedPath) {
this.embedPath = embedPath;
}
public String getRerankPath() {
return rerankPath;
}
public void setRerankPath(String rerankPath) {
this.rerankPath = rerankPath;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
}

View File

@@ -0,0 +1,239 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
public class PluginBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 插件id
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "插件id")
private BigInteger id;
/**
* 别名
*/
@Column(comment = "别名")
private String alias;
/**
* 名称
*/
@Column(comment = "名称")
private String name;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* 类型
*/
@Column(comment = "类型")
private Integer type;
/**
* 基础URL
*/
@Column(comment = "基础URL")
private String baseUrl;
/**
* 认证方式 【apiKey/none】
*/
@Column(comment = "认证方式 【apiKey/none】")
private String authType;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 图标地址
*/
@Column(comment = "图标地址")
private String icon;
/**
* 认证参数位置 【headers, query】
*/
@Column(comment = "认证参数位置 【headers, query】")
private String position;
/**
* 请求头
*/
@Column(comment = "请求头")
private String headers;
/**
* token键
*/
@Column(comment = "token键")
private String tokenKey;
/**
* token值
*/
@Column(comment = "token值")
private String tokenValue;
/**
* 部门id
*/
@Column(comment = "部门id")
private Long deptId;
/**
* 租户id
*/
@Column(tenantId = true, comment = "租户id")
private Long tenantId;
/**
* 创建人
*/
@Column(comment = "创建人")
private Long createdBy;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public String getAuthType() {
return authType;
}
public void setAuthType(String authType) {
this.authType = authType;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getHeaders() {
return headers;
}
public void setHeaders(String headers) {
this.headers = headers;
}
public String getTokenKey() {
return tokenKey;
}
public void setTokenKey(String tokenKey) {
this.tokenKey = tokenKey;
}
public String getTokenValue() {
return tokenValue;
}
public void setTokenValue(String tokenValue) {
this.tokenValue = tokenValue;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public Long getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
}

View File

@@ -0,0 +1,45 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
public class PluginCategoryBase implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto, value = "snowFlakeId")
private BigInteger id;
private String name;
private Date createdAt;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,31 @@
package tech.easyflow.ai.entity.base;
import java.io.Serializable;
import java.math.BigInteger;
public class PluginCategoryMappingBase implements Serializable {
private static final long serialVersionUID = 1L;
private BigInteger categoryId;
private BigInteger pluginId;
public BigInteger getCategoryId() {
return categoryId;
}
public void setCategoryId(BigInteger categoryId) {
this.categoryId = categoryId;
}
public BigInteger getPluginId() {
return pluginId;
}
public void setPluginId(BigInteger pluginId) {
this.pluginId = pluginId;
}
}

View File

@@ -0,0 +1,197 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
public class PluginItemBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 插件工具id
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "插件工具id")
private BigInteger id;
/**
* 插件id
*/
@Column(comment = "插件id")
private BigInteger pluginId;
/**
* 名称
*/
@Column(comment = "名称")
private String name;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* 基础路径
*/
@Column(comment = "基础路径")
private String basePath;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 是否启用
*/
@Column(comment = "是否启用")
private Integer status;
/**
* 输入参数
*/
@Column(comment = "输入参数")
private String inputData;
/**
* 输出参数
*/
@Column(comment = "输出参数")
private String outputData;
/**
* 请求方式【Post, Get, Put, Delete】
*/
@Column(comment = "请求方式【Post, Get, Put, Delete】")
private String requestMethod;
/**
* 服务状态[0 下线 1 上线]
*/
@Column(comment = "服务状态[0 下线 1 上线]")
private Integer serviceStatus;
/**
* 调试状态【0失败 1成功】
*/
@Column(comment = "调试状态【0失败 1成功】")
private Integer debugStatus;
/**
* 英文名称
*/
@Column(comment = "英文名称")
private String englishName;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getPluginId() {
return pluginId;
}
public void setPluginId(BigInteger pluginId) {
this.pluginId = pluginId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getBasePath() {
return basePath;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getInputData() {
return inputData;
}
public void setInputData(String inputData) {
this.inputData = inputData;
}
public String getOutputData() {
return outputData;
}
public void setOutputData(String outputData) {
this.outputData = outputData;
}
public String getRequestMethod() {
return requestMethod;
}
public void setRequestMethod(String requestMethod) {
this.requestMethod = requestMethod;
}
public Integer getServiceStatus() {
return serviceStatus;
}
public void setServiceStatus(Integer serviceStatus) {
this.serviceStatus = serviceStatus;
}
public Integer getDebugStatus() {
return debugStatus;
}
public void setDebugStatus(Integer debugStatus) {
this.debugStatus = debugStatus;
}
public String getEnglishName() {
return englishName;
}
public void setEnglishName(String englishName) {
this.englishName = englishName;
}
}

View File

@@ -0,0 +1,242 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import tech.easyflow.common.entity.DateEntity;
public class ResourceBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* 部门ID
*/
@Column(comment = "部门ID")
private BigInteger deptId;
/**
* 租户ID
*/
@Column(tenantId = true, comment = "租户ID")
private BigInteger tenantId;
/**
* 素材类型
*/
@Column(comment = "素材类型")
private Integer resourceType;
/**
* 素材名称
*/
@Column(comment = "素材名称")
private String resourceName;
/**
* 后缀
*/
@Column(comment = "后缀")
private String suffix;
/**
* 素材地址
*/
@Column(comment = "素材地址")
private String resourceUrl;
/**
* 素材来源
*/
@Column(comment = "素材来源")
private Integer origin;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者
*/
@Column(comment = "创建者")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者
*/
@Column(comment = "修改者")
private BigInteger modifiedBy;
/**
* 扩展项
*/
@Column(typeHandler = FastjsonTypeHandler.class, comment = "扩展项")
private Map<String, Object> options;
/**
* 文件大小
*/
@Column(comment = "文件大小")
private BigInteger fileSize;
/**
* 分类ID
*/
@Column(comment = "分类ID")
private BigInteger categoryId;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getDeptId() {
return deptId;
}
public void setDeptId(BigInteger deptId) {
this.deptId = deptId;
}
public BigInteger getTenantId() {
return tenantId;
}
public void setTenantId(BigInteger tenantId) {
this.tenantId = tenantId;
}
public Integer getResourceType() {
return resourceType;
}
public void setResourceType(Integer resourceType) {
this.resourceType = resourceType;
}
public String getResourceName() {
return resourceName;
}
public void setResourceName(String resourceName) {
this.resourceName = resourceName;
}
public String getSuffix() {
return suffix;
}
public void setSuffix(String suffix) {
this.suffix = suffix;
}
public String getResourceUrl() {
return resourceUrl;
}
public void setResourceUrl(String resourceUrl) {
this.resourceUrl = resourceUrl;
}
public Integer getOrigin() {
return origin;
}
public void setOrigin(Integer origin) {
this.origin = origin;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Map<String, Object> getOptions() {
return options;
}
public void setOptions(Map<String, Object> options) {
this.options = options;
}
public BigInteger getFileSize() {
return fileSize;
}
public void setFileSize(BigInteger fileSize) {
this.fileSize = fileSize;
}
public BigInteger getCategoryId() {
return categoryId;
}
public void setCategoryId(BigInteger categoryId) {
this.categoryId = categoryId;
}
}

View File

@@ -0,0 +1,128 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class ResourceCategoryBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* 分类名称
*/
@Column(comment = "分类名称")
private String categoryName;
/**
* 排序
*/
@Column(comment = "排序")
private Integer sortNo;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者
*/
@Column(comment = "创建者")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者
*/
@Column(comment = "修改者")
private BigInteger modifiedBy;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@@ -0,0 +1,226 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class WorkflowBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "ID 主键")
private BigInteger id;
/**
* 别名
*/
@Column(comment = "别名")
private String alias;
/**
* 部门ID
*/
@Column(comment = "部门ID")
private BigInteger deptId;
/**
* 租户ID
*/
@Column(tenantId = true, comment = "租户ID")
private BigInteger tenantId;
/**
* 标题
*/
@Column(comment = "标题")
private String title;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* ICON
*/
@Column(comment = "ICON")
private String icon;
/**
* 工作流设计的 JSON 内容
*/
@Column(comment = "工作流设计的 JSON 内容")
private String content;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建人
*/
@Column(comment = "创建人")
private BigInteger createdBy;
/**
* 最后修改时间
*/
@Column(comment = "最后修改时间")
private Date modified;
/**
* 最后修改的人
*/
@Column(comment = "最后修改的人")
private BigInteger modifiedBy;
/**
* 英文名称
*/
@Column(comment = "英文名称")
private String englishName;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
/**
* 分类ID
*/
@Column(comment = "分类ID")
private BigInteger categoryId;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public BigInteger getDeptId() {
return deptId;
}
public void setDeptId(BigInteger deptId) {
this.deptId = deptId;
}
public BigInteger getTenantId() {
return tenantId;
}
public void setTenantId(BigInteger tenantId) {
this.tenantId = tenantId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
public String getEnglishName() {
return englishName;
}
public void setEnglishName(String englishName) {
this.englishName = englishName;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public BigInteger getCategoryId() {
return categoryId;
}
public void setCategoryId(BigInteger categoryId) {
this.categoryId = categoryId;
}
}

View File

@@ -0,0 +1,128 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import tech.easyflow.common.entity.DateEntity;
public class WorkflowCategoryBase extends DateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* 分类名称
*/
@Column(comment = "分类名称")
private String categoryName;
/**
* 排序
*/
@Column(comment = "排序")
private Integer sortNo;
/**
* 创建时间
*/
@Column(comment = "创建时间")
private Date created;
/**
* 创建者
*/
@Column(comment = "创建者")
private BigInteger createdBy;
/**
* 修改时间
*/
@Column(comment = "修改时间")
private Date modified;
/**
* 修改者
*/
@Column(comment = "修改者")
private BigInteger modifiedBy;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public BigInteger getCreatedBy() {
return createdBy;
}
public void setCreatedBy(BigInteger createdBy) {
this.createdBy = createdBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public BigInteger getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(BigInteger modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@@ -0,0 +1,225 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
public class WorkflowExecResultBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* 执行标识
*/
@Column(comment = "执行标识")
private String execKey;
/**
* 工作流ID
*/
@Column(comment = "工作流ID")
private BigInteger workflowId;
/**
* 标题
*/
@Column(comment = "标题")
private String title;
/**
* 描述
*/
@Column(comment = "描述")
private String description;
/**
* 输入
*/
@Column(comment = "输入")
private String input;
/**
* 输出
*/
@Column(comment = "输出")
private String output;
/**
* 工作流执行时的配置
*/
@Column(comment = "工作流执行时的配置")
private String workflowJson;
/**
* 开始时间
*/
@Column(comment = "开始时间")
private Date startTime;
/**
* 结束时间
*/
@Column(comment = "结束时间")
private Date endTime;
/**
* 消耗总token
*/
@Column(comment = "消耗总token")
private BigInteger tokens;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
/**
* 执行人标识[有可能是用户|外部|定时任务等情况]
*/
@Column(comment = "执行人标识[有可能是用户|外部|定时任务等情况]")
private String createdKey;
/**
* 执行人
*/
@Column(comment = "执行人")
private String createdBy;
/**
* 错误信息
*/
@Column(comment = "错误信息")
private String errorInfo;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getExecKey() {
return execKey;
}
public void setExecKey(String execKey) {
this.execKey = execKey;
}
public BigInteger getWorkflowId() {
return workflowId;
}
public void setWorkflowId(BigInteger workflowId) {
this.workflowId = workflowId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
public String getWorkflowJson() {
return workflowJson;
}
public void setWorkflowJson(String workflowJson) {
this.workflowJson = workflowJson;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public BigInteger getTokens() {
return tokens;
}
public void setTokens(BigInteger tokens) {
this.tokens = tokens;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getCreatedKey() {
return createdKey;
}
public void setCreatedKey(String createdKey) {
this.createdKey = createdKey;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(String errorInfo) {
this.errorInfo = errorInfo;
}
}

View File

@@ -0,0 +1,197 @@
package tech.easyflow.ai.entity.base;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
public class WorkflowExecStepBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "主键")
private BigInteger id;
/**
* 执行记录ID
*/
@Column(comment = "执行记录ID")
private BigInteger recordId;
/**
* 执行标识
*/
@Column(comment = "执行标识")
private String execKey;
/**
* 节点ID
*/
@Column(comment = "节点ID")
private String nodeId;
/**
* 节点名称
*/
@Column(comment = "节点名称")
private String nodeName;
/**
* 输入
*/
@Column(comment = "输入")
private String input;
/**
* 输出
*/
@Column(comment = "输出")
private String output;
/**
* 节点信息
*/
@Column(comment = "节点信息")
private String nodeData;
/**
* 开始时间
*/
@Column(comment = "开始时间")
private Date startTime;
/**
* 结束时间
*/
@Column(comment = "结束时间")
private Date endTime;
/**
* 消耗总token
*/
@Column(comment = "消耗总token")
private BigInteger tokens;
/**
* 数据状态
*/
@Column(comment = "数据状态")
private Integer status;
/**
* 错误信息
*/
@Column(comment = "错误信息")
private String errorInfo;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public BigInteger getRecordId() {
return recordId;
}
public void setRecordId(BigInteger recordId) {
this.recordId = recordId;
}
public String getExecKey() {
return execKey;
}
public void setExecKey(String execKey) {
this.execKey = execKey;
}
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getNodeName() {
return nodeName;
}
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
public String getNodeData() {
return nodeData;
}
public void setNodeData(String nodeData) {
this.nodeData = nodeData;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public BigInteger getTokens() {
return tokens;
}
public void setTokens(BigInteger tokens) {
this.tokens = tokens;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(String errorInfo) {
this.errorInfo = errorInfo;
}
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.mapper;
import com.mybatisflex.core.BaseMapper;
import tech.easyflow.ai.entity.BotCategory;
/**
* bot分类 映射层。
*
* @author ArkLight
* @since 2025-12-18
*/
public interface BotCategoryMapper extends BaseMapper<BotCategory> {
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.mapper;
import com.mybatisflex.core.BaseMapper;
import tech.easyflow.ai.entity.BotConversation;
/**
* 映射层。
*
* @author Administrator
* @since 2025-04-15
*/
public interface BotConversationMapper extends BaseMapper<BotConversation> {
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.mapper;
import tech.easyflow.ai.entity.BotDocumentCollection;
import com.mybatisflex.core.BaseMapper;
/**
* 映射层。
*
* @author michael
* @since 2024-08-28
*/
public interface BotDocumentCollectionMapper extends BaseMapper<BotDocumentCollection> {
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.mapper;
import tech.easyflow.ai.entity.Bot;
import com.mybatisflex.core.BaseMapper;
/**
* 映射层。
*
* @author michael
* @since 2024-08-23
*/
public interface BotMapper extends BaseMapper<Bot> {
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.mapper;
import com.mybatisflex.core.BaseMapper;
import tech.easyflow.ai.entity.BotMcp;
/**
* 映射层。
*
* @author wangGangQiang
* @since 2026-01-05
*/
public interface BotMcpMapper extends BaseMapper<BotMcp> {
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.mapper;
import tech.easyflow.ai.entity.BotMessage;
import com.mybatisflex.core.BaseMapper;
/**
* Bot 消息记录表 映射层。
*
* @author michael
* @since 2024-11-04
*/
public interface BotMessageMapper extends BaseMapper<BotMessage> {
}

View File

@@ -0,0 +1,14 @@
package tech.easyflow.ai.mapper;
import tech.easyflow.ai.entity.BotModel;
import com.mybatisflex.core.BaseMapper;
/**
* 映射层。
*
* @author michael
* @since 2024-08-28
*/
public interface BotModelMapper extends BaseMapper<BotModel> {
}

Some files were not shown because too many files have changed in this diff Show More