【代码评审】AI:工作流

This commit is contained in:
YunaiV 2025-03-25 09:55:05 +08:00
parent c8e63f4a8c
commit 4bb52bb37d
6 changed files with 12 additions and 9 deletions

View File

@ -67,6 +67,7 @@ public class AiWorkflowController {
return success(BeanUtils.toBean(pageResult, AiWorkflowRespVO.class)); return success(BeanUtils.toBean(pageResult, AiWorkflowRespVO.class));
} }
// TODO @lesan要不融合到 updateWorkflow 接口
@PutMapping("/updateWorkflowModel") @PutMapping("/updateWorkflowModel")
@Operation(summary = "更新 AI 工作流模型") @Operation(summary = "更新 AI 工作流模型")
@PreAuthorize("@ss.hasPermission('ai:workflow:update')") @PreAuthorize("@ss.hasPermission('ai:workflow:update')")

View File

@ -8,7 +8,7 @@ import lombok.Data;
@Data @Data
public class AiWorkflowSaveReqVO { public class AiWorkflowSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "编号", example = "1")
private Long id; private Long id;
@Schema(description = "工作流标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "FLOW") @Schema(description = "工作流标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "FLOW")

View File

@ -21,17 +21,17 @@ public class AiWorkflowDO extends BaseDO {
*/ */
@TableId @TableId
private Long id; private Long id;
/**
* 工作流标识
*/
private String definitionKey;
/** /**
* 工作流名称 * 工作流名称
*/ */
private String name; private String name;
/**
* 工作流标识
*/
// TODO @lesan要不换成 code主要想 bpm 工作流有点区分字段上
private String definitionKey;
// TODO @lesangraph 用这个如何发现大家貌似更爱用这个字段哈
/** /**
* 工作流模型 JSON 数据 * 工作流模型 JSON 数据
*/ */

View File

@ -66,4 +66,5 @@ public interface AiWorkflowService {
* @param testReqVO 测试数据 * @param testReqVO 测试数据
*/ */
Object testWorkflow(AiWorkflowTestReqVO testReqVO); Object testWorkflow(AiWorkflowTestReqVO testReqVO);
} }

View File

@ -117,6 +117,7 @@ public class AiWorkflowServiceImpl implements AiWorkflowService {
} }
private Tinyflow parseFlowParam(String model) { private Tinyflow parseFlowParam(String model) {
// TODO @lesan可以使用 jackson
JSONObject json = JSONObject.parseObject(model); JSONObject json = JSONObject.parseObject(model);
JSONArray nodeArr = json.getJSONArray("nodes"); JSONArray nodeArr = json.getJSONArray("nodes");
Tinyflow tinyflow = new Tinyflow(json.toJSONString()); Tinyflow tinyflow = new Tinyflow(json.toJSONString());
@ -128,6 +129,7 @@ public class AiWorkflowServiceImpl implements AiWorkflowService {
AiApiKeyDO apiKey = apiKeyService.getApiKey(data.getLong("llmId")); AiApiKeyDO apiKey = apiKeyService.getApiKey(data.getLong("llmId"));
switch (apiKey.getPlatform()) { switch (apiKey.getPlatform()) {
// TODO @lesan 需要讨论一下这里怎么弄 // TODO @lesan 需要讨论一下这里怎么弄
// TODO @lesan llmId 对应 model 的编号如何这样的话就是 apiModelService 提供一个获取 LLM 的方法然后创建的方法也在 AiModelFactory 提供可以先接个 deepseek deepseek yyds
case "OpenAI": case "OpenAI":
break; break;
case "Ollama": case "Ollama":
@ -153,5 +155,4 @@ public class AiWorkflowServiceImpl implements AiWorkflowService {
return tinyflow; return tinyflow;
} }
} }

View File

@ -118,8 +118,8 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- TinyFlowAI 工作流 -->
<dependency> <dependency>
<!-- Tinyflow工作流 -->
<groupId>dev.tinyflow</groupId> <groupId>dev.tinyflow</groupId>
<artifactId>tinyflow-java-core</artifactId> <artifactId>tinyflow-java-core</artifactId>
<version>${tinyflow.version}</version> <version>${tinyflow.version}</version>