Compare commits
11 Commits
f6bd7e52e1
...
local-deve
| Author | SHA1 | Date | |
|---|---|---|---|
| c6cdacc48e | |||
| 8884495a89 | |||
| d08a6babbe | |||
| 9a3375bd03 | |||
|
|
2c808a5bc9 | ||
|
|
6e667c45e1 | ||
|
|
635c6537ed | ||
|
|
d6b70b1750 | ||
|
|
c92a374591 | ||
|
|
a2aba82b6e | ||
| 873c1a1d20 |
@@ -1,7 +1,5 @@
|
|||||||
package com.lanyuanxiaoyao.service.configuration;
|
package com.lanyuanxiaoyao.service.configuration;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
@@ -13,6 +11,9 @@ import org.springframework.security.core.userdetails.User;
|
|||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
|
import org.springframework.web.filter.CorsFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
@@ -21,6 +22,20 @@ import org.springframework.security.web.SecurityFilterChain;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfig {
|
public class SecurityConfig {
|
||||||
|
@Bean
|
||||||
|
public CorsFilter corsFilter() {
|
||||||
|
CorsConfiguration configuration = new CorsConfiguration();
|
||||||
|
configuration.setAllowCredentials(true);
|
||||||
|
configuration.addAllowedOriginPattern("*");
|
||||||
|
configuration.addAllowedHeader("*");
|
||||||
|
configuration.addAllowedMethod("*");
|
||||||
|
configuration.setMaxAge(7200L);
|
||||||
|
configuration.setAllowPrivateNetwork(true);
|
||||||
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
source.registerCorsConfiguration("/**", configuration);
|
||||||
|
return new CorsFilter(source);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
return http.authorizeHttpRequests(
|
return http.authorizeHttpRequests(
|
||||||
@@ -31,7 +46,7 @@ public class SecurityConfig {
|
|||||||
.authenticated()
|
.authenticated()
|
||||||
)
|
)
|
||||||
.httpBasic(Customizer.withDefaults())
|
.httpBasic(Customizer.withDefaults())
|
||||||
.cors(AbstractHttpConfigurer::disable)
|
.cors(Customizer.withDefaults())
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.formLogin(AbstractHttpConfigurer::disable)
|
.formLogin(AbstractHttpConfigurer::disable)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.controller.task;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.controller.SimpleControllerSupport;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.entity.SimpleItem;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.entity.FlowTask;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.entity.FlowTaskTemplate;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.service.task.FlowTaskService;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.service.task.FlowTaskTemplateService;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.mapstruct.Context;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("flow_task")
|
||||||
|
public class TaskController extends SimpleControllerSupport<FlowTask, TaskController.SaveItem, TaskController.ListItem, TaskController.DetailItem> {
|
||||||
|
private final FlowTaskTemplateService flowTaskTemplateService;
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
|
public TaskController(FlowTaskService flowTaskService, FlowTaskTemplateService flowTaskTemplateService, Jackson2ObjectMapperBuilder builder) {
|
||||||
|
super(flowTaskService);
|
||||||
|
this.flowTaskTemplateService = flowTaskTemplateService;
|
||||||
|
this.mapper = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SaveItemMapper<FlowTask, SaveItem> saveItemMapper() {
|
||||||
|
return item -> {
|
||||||
|
FlowTask task = new FlowTask();
|
||||||
|
FlowTaskTemplate template = flowTaskTemplateService.detailOrThrow(item.getTemplateId());
|
||||||
|
task.setTemplate(template);
|
||||||
|
task.setInput(mapper.writeValueAsString(item.getInput()));
|
||||||
|
return task;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ListItemMapper<FlowTask, ListItem> listItemMapper() {
|
||||||
|
ListItem.Mapper map = Mappers.getMapper(ListItem.Mapper.class);
|
||||||
|
return task -> map.from(task, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DetailItemMapper<FlowTask, DetailItem> detailItemMapper() {
|
||||||
|
DetailItem.Mapper map = Mappers.getMapper(DetailItem.Mapper.class);
|
||||||
|
return task -> map.from(task, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static final class SaveItem {
|
||||||
|
private Long templateId;
|
||||||
|
private Object input;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class ListItem extends SimpleItem {
|
||||||
|
private Long templateId;
|
||||||
|
private Object input;
|
||||||
|
private FlowTask.Status status;
|
||||||
|
|
||||||
|
@org.mapstruct.Mapper
|
||||||
|
public static abstract class Mapper {
|
||||||
|
@Mapping(target = "templateId", source = "task.template.id")
|
||||||
|
public abstract ListItem from(FlowTask task, @Context ObjectMapper mapper) throws JsonProcessingException;
|
||||||
|
|
||||||
|
protected Object mapInput(String input, @Context ObjectMapper mapper) throws JsonProcessingException {
|
||||||
|
return mapper.readValue(input, Object.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class DetailItem extends ListItem {
|
||||||
|
private String error;
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
@org.mapstruct.Mapper
|
||||||
|
public static abstract class Mapper extends ListItem.Mapper {
|
||||||
|
@Mapping(target = "templateId", source = "task.template.id")
|
||||||
|
public abstract DetailItem from(FlowTask task, @Context ObjectMapper mapper) throws JsonProcessingException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.controller.task;
|
||||||
|
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.controller.SimpleControllerSupport;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.entity.SimpleItem;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.entity.FlowTaskTemplate;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.service.task.FlowTaskTemplateService;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("flow_task/template")
|
||||||
|
public class TaskTemplateController extends SimpleControllerSupport<FlowTaskTemplate, TaskTemplateController.SaveItem, TaskTemplateController.ListItem, TaskTemplateController.DetailItem> {
|
||||||
|
public TaskTemplateController(FlowTaskTemplateService flowTaskTemplateService) {
|
||||||
|
super(flowTaskTemplateService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SaveItemMapper<FlowTaskTemplate, SaveItem> saveItemMapper() {
|
||||||
|
return Mappers.getMapper(SaveItem.Mapper.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ListItemMapper<FlowTaskTemplate, ListItem> listItemMapper() {
|
||||||
|
return Mappers.getMapper(ListItem.Mapper.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DetailItemMapper<FlowTaskTemplate, DetailItem> detailItemMapper() {
|
||||||
|
return Mappers.getMapper(DetailItem.Mapper.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static final class SaveItem {
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String inputSchema;
|
||||||
|
private String flow;
|
||||||
|
|
||||||
|
@org.mapstruct.Mapper
|
||||||
|
public interface Mapper extends SaveItemMapper<FlowTaskTemplate, SaveItem> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class ListItem extends SimpleItem {
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@org.mapstruct.Mapper
|
||||||
|
public interface Mapper extends ListItemMapper<FlowTaskTemplate, ListItem> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class DetailItem extends SimpleItem {
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String inputSchema;
|
||||||
|
private String flow;
|
||||||
|
|
||||||
|
@org.mapstruct.Mapper
|
||||||
|
public interface Mapper extends DetailItemMapper<FlowTaskTemplate, DetailItem> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.entity;
|
||||||
|
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.entity.SimpleEntity;
|
||||||
|
import com.lanyuanxiaoyao.service.common.Constants;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.ConstraintMode;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EntityListeners;
|
||||||
|
import jakarta.persistence.ForeignKey;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Entity
|
||||||
|
@DynamicUpdate
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@Table(catalog = Constants.DATABASE_NAME, name = "service_ai_flow_task")
|
||||||
|
public class FlowTask extends SimpleEntity {
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||||
|
private FlowTaskTemplate template;
|
||||||
|
@Column(columnDefinition = "longtext")
|
||||||
|
private String input;
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Status status = Status.RUNNING;
|
||||||
|
@Column(columnDefinition = "longtext")
|
||||||
|
private String error;
|
||||||
|
@Column(columnDefinition = "longtext")
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
RUNNING,
|
||||||
|
ERROR,
|
||||||
|
FINISHED,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.entity;
|
||||||
|
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.entity.SimpleEntity;
|
||||||
|
import com.lanyuanxiaoyao.service.common.Constants;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EntityListeners;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
@Entity
|
||||||
|
@DynamicUpdate
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@Table(catalog = Constants.DATABASE_NAME, name = "service_ai_flow_task_template")
|
||||||
|
public class FlowTaskTemplate extends SimpleEntity {
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
@Column(nullable = false, columnDefinition = "longtext")
|
||||||
|
private String inputSchema;
|
||||||
|
@Column(nullable = false, columnDefinition = "text")
|
||||||
|
private String flow;
|
||||||
|
@Column(columnDefinition = "longtext")
|
||||||
|
private String flowGraph;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.repository;
|
||||||
|
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.repository.SimpleRepository;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.entity.FlowTask;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface FlowTaskRepository extends SimpleRepository<FlowTask, Long> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.repository;
|
||||||
|
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.repository.SimpleRepository;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.entity.FlowTaskTemplate;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface FlowTaskTemplateRepository extends SimpleRepository<FlowTaskTemplate, Long> {
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class FeedbackService extends SimpleServiceSupport<Feedback> {
|
public class FeedbackService extends SimpleServiceSupport<Feedback> {
|
||||||
private final FlowExecutor executor;
|
private final FlowExecutor executor;
|
||||||
|
|
||||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.service.task;
|
||||||
|
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.service.SimpleServiceSupport;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.entity.FlowTask;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.repository.FlowTaskRepository;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class FlowTaskService extends SimpleServiceSupport<FlowTask> {
|
||||||
|
public FlowTaskService(FlowTaskRepository flowTaskRepository) {
|
||||||
|
super(flowTaskRepository);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.ai.web.service.task;
|
||||||
|
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.base.service.SimpleServiceSupport;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.entity.FlowTaskTemplate;
|
||||||
|
import com.lanyuanxiaoyao.service.ai.web.repository.FlowTaskTemplateRepository;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class FlowTaskTemplateService extends SimpleServiceSupport<FlowTaskTemplate> {
|
||||||
|
public FlowTaskTemplateService(FlowTaskTemplateRepository flowTaskTemplateRepository) {
|
||||||
|
super(flowTaskTemplateRepository);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
server:
|
server:
|
||||||
|
port: 8080
|
||||||
compression:
|
compression:
|
||||||
enabled: true
|
enabled: true
|
||||||
spring:
|
spring:
|
||||||
application:
|
|
||||||
name: service-ai-web
|
|
||||||
profiles:
|
|
||||||
include: random-port,common,discovery,metrics,forest
|
|
||||||
mvc:
|
mvc:
|
||||||
async:
|
async:
|
||||||
request-timeout: 3600000
|
request-timeout: 3600000
|
||||||
@@ -21,27 +18,44 @@ spring:
|
|||||||
ai:
|
ai:
|
||||||
vectorstore:
|
vectorstore:
|
||||||
qdrant:
|
qdrant:
|
||||||
host: 132.121.206.65
|
host: 192.168.100.140
|
||||||
port: 29463
|
port: 6334
|
||||||
api-key: ENC(0/0UkIKeAvyV17yNqSU3v04wmm8CdWKe4BYSSJa2FuBtK12TcZRJPdwk+ZpYnpISv+KmVTUrrmFBzAYrDR3ysA==)
|
|
||||||
llm:
|
llm:
|
||||||
base-url: http://132.121.206.65:10086
|
base-url: https://api.siliconflow.cn
|
||||||
api-key: ENC(K+Hff9QGC+fcyi510VIDd9CaeK/IN5WBJ9rlkUsHEdDgIidW+stHHJlsK0lLPUXXREha+ToQZqqDXJrqSE+GUKCXklFhelD8bRHFXBIeP/ZzT2cxhzgKUXgjw3S0Qw2R)
|
api-key: sk-xrguybusoqndpqvgzgvllddzgjamksuecyqdaygdwnrnqfwo
|
||||||
chat:
|
chat:
|
||||||
base-url: ${spring.llm.base-url}/v1
|
model: 'Qwen/Qwen3-8B'
|
||||||
model: 'Qwen3/qwen3-1.7b'
|
|
||||||
visual:
|
visual:
|
||||||
model: 'Qwen2.5/qwen2.5-vl-7b-q4km'
|
base-url: https://open.bigmodel.cn/api/paas/v4
|
||||||
|
endpoint: /chat/completions
|
||||||
|
model: 'glm-4v-flash'
|
||||||
embedding:
|
embedding:
|
||||||
model: 'Qwen3/qwen3-embedding-4b'
|
model: 'BAAI/bge-m3'
|
||||||
reranker:
|
reranker:
|
||||||
model: 'BGE/beg-reranker-v2'
|
model: 'BAAI/bge-reranker-v2-m3'
|
||||||
|
cloud:
|
||||||
|
discovery:
|
||||||
|
enabled: false
|
||||||
|
zookeeper:
|
||||||
|
enabled: false
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://192.168.100.140:3306/hudi_collect_build_b12?useSSL=false&allowPublicKeyRetrieval=true
|
||||||
|
username: root
|
||||||
|
password: rootless
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
security:
|
||||||
|
meta:
|
||||||
|
authority: ENC(GXKnbq1LS11U2HaONspvH+D/TkIx13aWTaokdkzaF7HSvq6Z0Rv1+JUWFnYopVXu)
|
||||||
|
username: ENC(moIO5mO39V1Z+RDwROK9JXY4GfM8ZjDgM6Si7wRZ1MPVjbhTpmLz3lz28rAiw7c2LeCmizfJzHkEXIwGlB280g==)
|
||||||
|
darkcode: ENC(0jzpQ7T6S+P7bZrENgYsUoLhlqGvw7DA2MN3BRqEOwq7plhtg72vuuiPQNnr3DaYz0CpyTvxInhpx11W3VZ1trD6NINh7O3LN70ZqO5pWXk=)
|
||||||
jpa:
|
jpa:
|
||||||
show-sql: true
|
generate-ddl: true
|
||||||
generate-ddl: false
|
jasypt:
|
||||||
|
encryptor:
|
||||||
|
password: 'r#(R,P"Dp^A47>WSn:Wn].gs/+"v:q_Q*An~zF*g-@j@jtSTv5H/,S-3:R?r9R}.'
|
||||||
|
fenix:
|
||||||
|
print-banner: false
|
||||||
liteflow:
|
liteflow:
|
||||||
rule-source: liteflow.xml
|
rule-source: liteflow.xml
|
||||||
print-banner: false
|
print-banner: false
|
||||||
check-node-exists: false
|
check-node-exists: false
|
||||||
fenix:
|
|
||||||
print-banner: false
|
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
package com.lanyuanxiaoyao.service.ai.web.flow;
|
package com.lanyuanxiaoyao.service.ai.web.flow;
|
||||||
|
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
* @version 20250625
|
* @version 20250625
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public abstract class BaseNode extends NodeComponent {
|
public abstract class BaseNode extends NodeComponent {
|
||||||
|
@Override
|
||||||
|
public void process() throws Exception {
|
||||||
|
log.info(getClass().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,20 @@ package com.lanyuanxiaoyao.service.ai.web.flow;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
|
||||||
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
|
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
|
||||||
import com.yomahub.liteflow.builder.el.ELBus;
|
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||||
import java.util.List;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Queue;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.collections.api.factory.Lists;
|
||||||
|
import org.eclipse.collections.api.factory.Maps;
|
||||||
|
import org.eclipse.collections.api.list.ImmutableList;
|
||||||
|
import org.eclipse.collections.api.list.MutableList;
|
||||||
|
import org.eclipse.collections.api.map.ImmutableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
@@ -35,11 +39,254 @@ public class LiteFlowService {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws JsonProcessingException {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.registerModule(new EclipseCollectionsModule());
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
// language=JSON
|
||||||
|
String source = """
|
||||||
|
{
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"id": "A",
|
||||||
|
"type": "start",
|
||||||
|
"position": {
|
||||||
|
"x": 8,
|
||||||
|
"y": 272
|
||||||
|
},
|
||||||
|
"data": {},
|
||||||
|
"measured": {
|
||||||
|
"width": 256,
|
||||||
|
"height": 75
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "F",
|
||||||
|
"type": "end",
|
||||||
|
"position": {
|
||||||
|
"x": 1439.5556937134281,
|
||||||
|
"y": 282.2797340760818
|
||||||
|
},
|
||||||
|
"data": {},
|
||||||
|
"measured": {
|
||||||
|
"width": 256,
|
||||||
|
"height": 75
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "C",
|
||||||
|
"type": "normal",
|
||||||
|
"position": {
|
||||||
|
"x": 902.6781018665707,
|
||||||
|
"y": 115.31234529524048
|
||||||
|
},
|
||||||
|
"data": {},
|
||||||
|
"measured": {
|
||||||
|
"width": 256,
|
||||||
|
"height": 75
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "B",
|
||||||
|
"type": "normal",
|
||||||
|
"position": {
|
||||||
|
"x": 338,
|
||||||
|
"y": 287
|
||||||
|
},
|
||||||
|
"data": {},
|
||||||
|
"measured": {
|
||||||
|
"width": 256,
|
||||||
|
"height": 75
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "E",
|
||||||
|
"type": "normal",
|
||||||
|
"position": {
|
||||||
|
"x": 1086.6322978498904,
|
||||||
|
"y": 371.3061114283591
|
||||||
|
},
|
||||||
|
"data": {},
|
||||||
|
"measured": {
|
||||||
|
"width": 256,
|
||||||
|
"height": 75
|
||||||
|
},
|
||||||
|
"selected": true,
|
||||||
|
"dragging": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "D",
|
||||||
|
"type": "normal",
|
||||||
|
"position": {
|
||||||
|
"x": 700.0944461714178,
|
||||||
|
"y": 369.84258971430364
|
||||||
|
},
|
||||||
|
"data": {},
|
||||||
|
"measured": {
|
||||||
|
"width": 256,
|
||||||
|
"height": 75
|
||||||
|
},
|
||||||
|
"selected": false,
|
||||||
|
"dragging": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"source": "A",
|
||||||
|
"target": "B",
|
||||||
|
"id": "xy-edge__A-B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "B",
|
||||||
|
"target": "C",
|
||||||
|
"id": "xy-edge__B-C"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "C",
|
||||||
|
"target": "F",
|
||||||
|
"id": "xy-edge__C-F"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "D",
|
||||||
|
"target": "E",
|
||||||
|
"id": "xy-edge__D-E"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "B",
|
||||||
|
"target": "D",
|
||||||
|
"id": "xy-edge__B-D"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "E",
|
||||||
|
"target": "F",
|
||||||
|
"id": "xy-edge__E-F"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"data": {
|
||||||
|
"A": {
|
||||||
|
"inputs": {
|
||||||
|
"name": {
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "text",
|
||||||
|
"description": "文件描述"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"C": {
|
||||||
|
"model": "qwen3",
|
||||||
|
"outputs": {
|
||||||
|
"text": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systemPrompt": "你是个沙雕"
|
||||||
|
},
|
||||||
|
"B": {
|
||||||
|
"count": 3,
|
||||||
|
"score": 0.75,
|
||||||
|
"knowledgeId": 3585368238960640,
|
||||||
|
"query": "hello world"
|
||||||
|
},
|
||||||
|
"E": {
|
||||||
|
"type": "python",
|
||||||
|
"content": "code='hello'\\nprint(code)"
|
||||||
|
},
|
||||||
|
"D": {
|
||||||
|
"model": "qwen3",
|
||||||
|
"outputs": {
|
||||||
|
"text": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systemPrompt": "你是个聪明人"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
FlowData root = mapper.readValue(StrUtil.trim(source), FlowData.class);
|
||||||
|
log.info("\n{}", buildEl(root.nodes, root.edges));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String buildEl(ImmutableList<FlowData.Node> nodes, ImmutableList<FlowData.Edge> edges) {
|
||||||
|
var nodeMap = nodes.toMap(FlowData.Node::getId, node -> node);
|
||||||
|
var adjacencyGraph = Maps.mutable.<String, MutableList<String>>empty();
|
||||||
|
var reverseAdjacencyGraph = Maps.mutable.<String, MutableList<String>>empty();
|
||||||
|
var inDegree = Maps.mutable.<String, Integer>empty();
|
||||||
|
|
||||||
|
nodes.forEach(node -> {
|
||||||
|
adjacencyGraph.put(node.getId(), Lists.mutable.empty());
|
||||||
|
reverseAdjacencyGraph.put(node.getId(), Lists.mutable.empty());
|
||||||
|
inDegree.put(node.getId(), 0);
|
||||||
|
});
|
||||||
|
edges.forEach(edge -> {
|
||||||
|
adjacencyGraph.get(edge.getSource()).add(edge.getTarget());
|
||||||
|
reverseAdjacencyGraph.get(edge.getTarget()).add(edge.getSource());
|
||||||
|
inDegree.put(edge.getTarget(), inDegree.get(edge.getTarget()) + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
Queue<String> queue = new LinkedList<>();
|
||||||
|
var topologicalSortedList = Lists.mutable.<String>empty();
|
||||||
|
|
||||||
|
inDegree.forEachKeyValue((id, count) -> {
|
||||||
|
if (count == 0) {
|
||||||
|
queue.offer(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
while (!queue.isEmpty()) {
|
||||||
|
String id = queue.poll();
|
||||||
|
topologicalSortedList.add(id);
|
||||||
|
for (var neighborId : adjacencyGraph.get(id)) {
|
||||||
|
inDegree.put(neighborId, inDegree.get(neighborId) - 1);
|
||||||
|
if (inDegree.get(neighborId) == 0) {
|
||||||
|
queue.offer(neighborId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
topologicalSortedList.forEach(id -> log.info("{} {}", id, adjacencyGraph.get(id)));
|
||||||
|
topologicalSortedList.forEach(id -> log.info("{} {}", id, reverseAdjacencyGraph.get(id)));
|
||||||
|
|
||||||
|
var nodeQueue = new LinkedList<>(topologicalSortedList);
|
||||||
|
var chains = Lists.mutable.<MutableList<String>>empty();
|
||||||
|
while (!nodeQueue.isEmpty()) {
|
||||||
|
String currentId = nodeQueue.poll();
|
||||||
|
var subChain = Lists.mutable.<String>empty();
|
||||||
|
while (true) {
|
||||||
|
subChain.add(currentId);
|
||||||
|
nodeQueue.remove(currentId);
|
||||||
|
if (adjacencyGraph.get(currentId).size() != 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String nextId = adjacencyGraph.get(currentId).get(0);
|
||||||
|
if (reverseAdjacencyGraph.get(nextId).size() > 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
currentId = nextId;
|
||||||
|
}
|
||||||
|
chains.add(subChain);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("{}", chains);
|
||||||
|
|
||||||
|
return StrUtil.join(",", topologicalSortedList);
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class FlowData {
|
public static class FlowData {
|
||||||
private List<Node> nodes;
|
private ImmutableList<Node> nodes;
|
||||||
private List<Edge> edges;
|
private ImmutableList<Edge> edges;
|
||||||
private Map<String, Object> data;
|
private ImmutableMap<String, Object> data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Node {
|
public static class Node {
|
||||||
@@ -54,104 +301,4 @@ public class LiteFlowService {
|
|||||||
private String target;
|
private String target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws JsonProcessingException {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
// language=JSON
|
|
||||||
String source = """
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"id": "BMFP3Eov94",
|
|
||||||
"type": "start-amis-node",
|
|
||||||
"position": {
|
|
||||||
"x": 10,
|
|
||||||
"y": 100
|
|
||||||
},
|
|
||||||
"data": {},
|
|
||||||
"measured": {
|
|
||||||
"width": 256,
|
|
||||||
"height": 83
|
|
||||||
},
|
|
||||||
"selected": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "PYK8LjduQ1",
|
|
||||||
"type": "end-amis-node",
|
|
||||||
"position": {
|
|
||||||
"x": 654,
|
|
||||||
"y": 332
|
|
||||||
},
|
|
||||||
"data": {},
|
|
||||||
"measured": {
|
|
||||||
"width": 256,
|
|
||||||
"height": 83
|
|
||||||
},
|
|
||||||
"selected": false,
|
|
||||||
"dragging": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "nCm-ij5I6o",
|
|
||||||
"type": "llm-amis-node",
|
|
||||||
"position": {
|
|
||||||
"x": 318,
|
|
||||||
"y": 208
|
|
||||||
},
|
|
||||||
"data": {},
|
|
||||||
"measured": {
|
|
||||||
"width": 256,
|
|
||||||
"height": 83
|
|
||||||
},
|
|
||||||
"selected": true,
|
|
||||||
"dragging": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"edges": [
|
|
||||||
{
|
|
||||||
"source": "BMFP3Eov94",
|
|
||||||
"target": "nCm-ij5I6o",
|
|
||||||
"id": "xy-edge__BMFP3Eov94-nCm-ij5I6o"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "nCm-ij5I6o",
|
|
||||||
"target": "PYK8LjduQ1",
|
|
||||||
"id": "xy-edge__nCm-ij5I6o-PYK8LjduQ1"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"data": {
|
|
||||||
"BMFP3Eov94": {
|
|
||||||
"inputs": {
|
|
||||||
"name": {
|
|
||||||
"type": "text"
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
"type": "text",
|
|
||||||
"description": "文件描述"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nCm-ij5I6o": {
|
|
||||||
"model": "qwen3",
|
|
||||||
"outputs": {
|
|
||||||
"text": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systemPrompt": "你是个沙雕"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
""";
|
|
||||||
FlowData root = mapper.readValue(StrUtil.trim(source), FlowData.class);
|
|
||||||
log.info("{}", root);
|
|
||||||
log.info(
|
|
||||||
"\n{}",
|
|
||||||
ELBus.ser(
|
|
||||||
"start-amis-node",
|
|
||||||
ELBus.ser("start-amis-node", "end-amis-node"),
|
|
||||||
"end-amis-node"
|
|
||||||
).toEL(true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-router": "^7.6.2",
|
"react-router": "^7.6.2",
|
||||||
"styled-components": "^6.1.19",
|
"styled-components": "^6.1.19",
|
||||||
|
"yocto-queue": "^1.2.1",
|
||||||
"zustand": "^5.0.5"
|
"zustand": "^5.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
9
service-web/client/pnpm-lock.yaml
generated
9
service-web/client/pnpm-lock.yaml
generated
@@ -71,6 +71,9 @@ importers:
|
|||||||
styled-components:
|
styled-components:
|
||||||
specifier: ^6.1.19
|
specifier: ^6.1.19
|
||||||
version: 6.1.19(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 6.1.19(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
|
yocto-queue:
|
||||||
|
specifier: ^1.2.1
|
||||||
|
version: 1.2.1
|
||||||
zustand:
|
zustand:
|
||||||
specifier: ^5.0.5
|
specifier: ^5.0.5
|
||||||
version: 5.0.5(@types/react@18.3.23)(react@18.3.1)(use-sync-external-store@1.5.0(react@18.3.1))
|
version: 5.0.5(@types/react@18.3.23)(react@18.3.1)(use-sync-external-store@1.5.0(react@18.3.1))
|
||||||
@@ -3480,6 +3483,10 @@ packages:
|
|||||||
yallist@4.0.0:
|
yallist@4.0.0:
|
||||||
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
|
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
|
||||||
|
|
||||||
|
yocto-queue@1.2.1:
|
||||||
|
resolution: {integrity: sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg==}
|
||||||
|
engines: {node: '>=12.20'}
|
||||||
|
|
||||||
zip-stream@4.1.1:
|
zip-stream@4.1.1:
|
||||||
resolution: {integrity: sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==}
|
resolution: {integrity: sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
@@ -7500,6 +7507,8 @@ snapshots:
|
|||||||
yallist@4.0.0:
|
yallist@4.0.0:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
yocto-queue@1.2.1: {}
|
||||||
|
|
||||||
zip-stream@4.1.1:
|
zip-stream@4.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
archiver-utils: 3.0.4
|
archiver-utils: 3.0.4
|
||||||
|
|||||||
76
service-web/client/src/pages/ai/flow/ElParser.tsx
Normal file
76
service-web/client/src/pages/ai/flow/ElParser.tsx
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import {type Edge, type Node} from '@xyflow/react'
|
||||||
|
|
||||||
|
export const buildEL = (nodes: Node[], edges: Edge[]): string => {
|
||||||
|
const nodeMap: Map<string, Node> = new Map<string, Node>()
|
||||||
|
// 构建邻接列表和内图
|
||||||
|
const adjList = new Map<string, string[]>()
|
||||||
|
const inDegree = new Map<string, number>()
|
||||||
|
for (const node of nodes) {
|
||||||
|
nodeMap.set(node.id, node)
|
||||||
|
adjList.set(node.id, [])
|
||||||
|
inDegree.set(node.id, 0)
|
||||||
|
}
|
||||||
|
for (const edge of edges) {
|
||||||
|
adjList.get(edge.source)!.push(edge.target)
|
||||||
|
inDegree.set(edge.target, inDegree.get(edge.target)! + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute levels (longest path from start)
|
||||||
|
const levelMap = new Map<string, number>()
|
||||||
|
|
||||||
|
function computeLevel(nodeId: string): number {
|
||||||
|
if (levelMap.has(nodeId)) return levelMap.get(nodeId)!
|
||||||
|
const preds = edges.filter(e => e.target === nodeId).map(e => e.source)
|
||||||
|
const level = preds.length === 0 ? 0 : Math.max(...preds.map(p => computeLevel(p))) + 1
|
||||||
|
levelMap.set(nodeId, level)
|
||||||
|
return level
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const node of nodes) computeLevel(node.id)
|
||||||
|
|
||||||
|
// Group nodes by level
|
||||||
|
const maxLevel = Math.max(...Array.from(levelMap.values()))
|
||||||
|
const levels: string[][] = Array.from({length: maxLevel + 1}, () => [])
|
||||||
|
for (const node of nodes) levels[levelMap.get(node.id)!].push(node.id)
|
||||||
|
|
||||||
|
const covertNodeFromId = (id: string) => {
|
||||||
|
let node = nodeMap.get(id)!
|
||||||
|
return `node("${node.type}").bind("nodeId", ${node.id})`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build EL expression
|
||||||
|
const expressions: string[] = []
|
||||||
|
for (let i = 0; i <= maxLevel; i++) {
|
||||||
|
const nodesAtLevel = levels[i]
|
||||||
|
if (nodesAtLevel.length === 0) continue
|
||||||
|
|
||||||
|
// 识别从这个级别开始的串行链
|
||||||
|
const serialChains: string[] = []
|
||||||
|
for (const nodeId of nodesAtLevel) {
|
||||||
|
let chain = [nodeId]
|
||||||
|
let current = nodeId
|
||||||
|
while (adjList.get(current)?.length === 1) {
|
||||||
|
const next = adjList.get(current)![0]
|
||||||
|
if (inDegree.get(next) === 1 && levelMap.get(next) === i + chain.length) {
|
||||||
|
chain.push(next)
|
||||||
|
current = next
|
||||||
|
} else break
|
||||||
|
}
|
||||||
|
if (chain.length > 1) {
|
||||||
|
serialChains.push(`THEN(${chain.map(id => covertNodeFromId(id)).join(',')})`)
|
||||||
|
// Remove processed nodes from their levels
|
||||||
|
for (let j = 1; j < chain.length; j++) {
|
||||||
|
const level = levelMap.get(chain[j])!
|
||||||
|
levels[level] = levels[level].filter(n => n !== chain[j])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
serialChains.push(covertNodeFromId(nodeId))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine chains or nodes at this level
|
||||||
|
expressions.push(serialChains.length > 1 ? `WHEN(${serialChains.join(', ')})` : serialChains[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
return `THEN(${expressions.join(',')})`
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
BackgroundVariant,
|
BackgroundVariant,
|
||||||
type Connection,
|
type Connection,
|
||||||
Controls,
|
Controls,
|
||||||
getIncomers,
|
type Edge,
|
||||||
getOutgoers,
|
getOutgoers,
|
||||||
MiniMap,
|
MiniMap,
|
||||||
type Node,
|
type Node,
|
||||||
@@ -19,6 +19,7 @@ import {type JSX, useState} from 'react'
|
|||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import '@xyflow/react/dist/style.css'
|
import '@xyflow/react/dist/style.css'
|
||||||
import {amisRender, commonInfo, horizontalFormOptions} from '../../../util/amis.tsx'
|
import {amisRender, commonInfo, horizontalFormOptions} from '../../../util/amis.tsx'
|
||||||
|
import {buildEL} from './ElParser.tsx'
|
||||||
import CodeNode from './node/CodeNode.tsx'
|
import CodeNode from './node/CodeNode.tsx'
|
||||||
import EndNode from './node/EndNode.tsx'
|
import EndNode from './node/EndNode.tsx'
|
||||||
import KnowledgeNode from './node/KnowledgeNode.tsx'
|
import KnowledgeNode from './node/KnowledgeNode.tsx'
|
||||||
@@ -72,27 +73,27 @@ function FlowEditor() {
|
|||||||
component: (props: NodeProps) => JSX.Element
|
component: (props: NodeProps) => JSX.Element
|
||||||
}[]>([
|
}[]>([
|
||||||
{
|
{
|
||||||
key: 'start-amis-node',
|
key: 'start-node',
|
||||||
name: '开始',
|
name: '开始',
|
||||||
component: StartNode,
|
component: StartNode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'end-amis-node',
|
key: 'end-node',
|
||||||
name: '结束',
|
name: '结束',
|
||||||
component: EndNode,
|
component: EndNode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'llm-amis-node',
|
key: 'llm-node',
|
||||||
name: '大模型',
|
name: '大模型',
|
||||||
component: LlmNode,
|
component: LlmNode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'knowledge-amis-node',
|
key: 'knowledge-node',
|
||||||
name: '知识库',
|
name: '知识库',
|
||||||
component: KnowledgeNode,
|
component: KnowledgeNode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'code-amis-node',
|
key: 'code-node',
|
||||||
name: '代码执行',
|
name: '代码执行',
|
||||||
component: CodeNode,
|
component: CodeNode,
|
||||||
},
|
},
|
||||||
@@ -184,10 +185,10 @@ function FlowEditor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkNode = (type: string) => {
|
const checkNode = (type: string) => {
|
||||||
if (isEqual(type, 'start-amis-node') && findIdx(nodes, (node: Node) => isEqual(type, node.type)) > -1) {
|
if (isEqual(type, 'start-node') && findIdx(nodes, (node: Node) => isEqual(type, node.type)) > -1) {
|
||||||
throw new Error('只能存在1个开始节点')
|
throw new Error('只能存在1个开始节点')
|
||||||
}
|
}
|
||||||
if (isEqual(type, 'end-amis-node') && findIdx(nodes, (node: Node) => isEqual(type, node.type)) > -1) {
|
if (isEqual(type, 'end-node') && findIdx(nodes, (node: Node) => isEqual(type, node.type)) > -1) {
|
||||||
throw new Error('只能存在1个结束节点')
|
throw new Error('只能存在1个结束节点')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,12 +203,12 @@ function FlowEditor() {
|
|||||||
throw new Error('连线目标节点未找到')
|
throw new Error('连线目标节点未找到')
|
||||||
}
|
}
|
||||||
// 禁止短路整个流程
|
// 禁止短路整个流程
|
||||||
if (isEqual('start-amis-node', sourceNode.type) && isEqual('end-amis-node', targetNode.type)) {
|
if (isEqual('start-node', sourceNode.type) && isEqual('end-node', targetNode.type)) {
|
||||||
throw new Error('开始节点不能直连结束节点')
|
throw new Error('开始节点不能直连结束节点')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 禁止流程出现环,必须是有向无环图
|
// 禁止流程出现环,必须是有向无环图
|
||||||
const hasCycle = (node: Node, visited = new Set()) => {
|
const hasCycle = (node: Node, visited = new Set<string>()) => {
|
||||||
if (visited.has(node.id)) return false
|
if (visited.has(node.id)) return false
|
||||||
visited.add(node.id)
|
visited.add(node.id)
|
||||||
for (const outgoer of getOutgoers(node, nodes, edges)) {
|
for (const outgoer of getOutgoers(node, nodes, edges)) {
|
||||||
@@ -221,20 +222,52 @@ function FlowEditor() {
|
|||||||
throw new Error('禁止流程循环')
|
throw new Error('禁止流程循环')
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasShortcut = (node: Node, visited = new Set()) => {
|
/*const hasRedundant = (source: Node, target: Node) => {
|
||||||
if (visited.has(node.id)) return false
|
const visited = new Set<string>()
|
||||||
visited.add(node.id)
|
const queue = new Queue<Node>()
|
||||||
for (const incomer of getIncomers(node, nodes, edges)) {
|
queue.enqueue(source)
|
||||||
if (isEqual(incomer.id, sourceNode?.id)) return true
|
visited.add(source.id)
|
||||||
if (hasShortcut(incomer, visited)) return true
|
while (queue.size > 0) {
|
||||||
|
const current = queue.dequeue()!
|
||||||
|
console.log(current.id)
|
||||||
|
for (const incomer of getIncomers(current, nodes, edges)) {
|
||||||
|
if (isEqual(incomer.id, target.id)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (!visited.has(incomer.id)) {
|
||||||
|
visited.add(incomer.id)
|
||||||
|
queue.enqueue(incomer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(getIncomers(targetNode, nodes, edges))
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (hasRedundant(sourceNode, targetNode)) {
|
||||||
|
throw new Error('出现冗余边')
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const checkSave = (nodes: Node[], edges: Edge[], data: any) => {
|
||||||
|
if (nodes.filter(n => isEqual('start-node', n.type)).length < 1) {
|
||||||
|
throw new Error('至少存在1个开始节点')
|
||||||
|
}
|
||||||
|
if (nodes.filter(n => isEqual('end-node', n.type)).length < 1) {
|
||||||
|
throw new Error('至少存在1个结束节点')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用于透传node操作到主流程
|
||||||
|
const initialNodeHandlers = {
|
||||||
|
getDataById,
|
||||||
|
setDataById,
|
||||||
|
removeNode,
|
||||||
|
editNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
useMount(() => {
|
useMount(() => {
|
||||||
// language=JSON
|
// language=JSON
|
||||||
let initialData = JSON.parse('{\n "nodes": [\n {\n "id": "BMFP3Eov94",\n "type": "start-amis-node",\n "position": {\n "x": 8,\n "y": 272\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "PYK8LjduQ1",\n "type": "end-amis-node",\n "position": {\n "x": 1439.5556937134281,\n "y": 282.2797340760818\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "nCm-ij5I6o",\n "type": "llm-amis-node",\n "position": {\n "x": 902.6781018665707,\n "y": 115.31234529524048\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "9RIg65O0YQ",\n "type": "knowledge-amis-node",\n "position": {\n "x": 338,\n "y": 287\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "2vTyjP0Gu9",\n "type": "code-amis-node",\n "position": {\n "x": 1086.6322978498904,\n "y": 371.3061114283591\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": true,\n "dragging": false\n },\n {\n "id": "s9VfZpvb4P",\n "type": "llm-amis-node",\n "position": {\n "x": 700.0944461714178,\n "y": 369.84258971430364\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n }\n ],\n "edges": [\n {\n "source": "BMFP3Eov94",\n "target": "9RIg65O0YQ",\n "id": "xy-edge__BMFP3Eov94-9RIg65O0YQ"\n },\n {\n "source": "9RIg65O0YQ",\n "target": "nCm-ij5I6o",\n "id": "xy-edge__9RIg65O0YQ-nCm-ij5I6o"\n },\n {\n "source": "nCm-ij5I6o",\n "target": "PYK8LjduQ1",\n "id": "xy-edge__nCm-ij5I6o-PYK8LjduQ1"\n },\n {\n "source": "s9VfZpvb4P",\n "target": "2vTyjP0Gu9",\n "id": "xy-edge__s9VfZpvb4P-2vTyjP0Gu9"\n },\n {\n "source": "9RIg65O0YQ",\n "target": "s9VfZpvb4P",\n "id": "xy-edge__9RIg65O0YQ-s9VfZpvb4P"\n },\n {\n "source": "2vTyjP0Gu9",\n "target": "PYK8LjduQ1",\n "id": "xy-edge__2vTyjP0Gu9-PYK8LjduQ1"\n }\n ],\n "data": {\n "BMFP3Eov94": {\n "inputs": {\n "name": {\n "type": "text"\n },\n "description": {\n "type": "text",\n "description": "文件描述"\n }\n }\n },\n "nCm-ij5I6o": {\n "model": "qwen3",\n "outputs": {\n "text": {\n "type": "string"\n }\n },\n "systemPrompt": "你是个沙雕"\n },\n "9RIg65O0YQ": {\n "count": 3,\n "score": 0.75,\n "knowledgeId": 3585368238960640,\n "query": "hello world"\n },\n "2vTyjP0Gu9": {\n "type": "python",\n "content": "code=\'hello\'\\nprint(code)"\n },\n "s9VfZpvb4P": {\n "model": "qwen3",\n "outputs": {\n "text": {\n "type": "string"\n }\n },\n "systemPrompt": "你是个聪明人"\n }\n }\n}')
|
let initialData = JSON.parse('{\n "nodes": [\n {\n "id": "ldoKAzHnKF",\n "type": "llm-node",\n "position": {\n "x": 207,\n "y": -38\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 105\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "1eJtMoJWs6",\n "type": "llm-node",\n "position": {\n "x": 207,\n "y": 172.5\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 105\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "7e5vQLDGTl",\n "type": "start-node",\n "position": {\n "x": -162.3520537805597,\n "y": 67.84901301708827\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 105\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "Wyqg_bXILg",\n "type": "knowledge-node",\n "position": {\n "x": 560.402133595296,\n "y": -38.892263766178665\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "7DaF-0G-yv",\n "type": "llm-node",\n "position": {\n "x": 634.9924233956513,\n "y": 172.01821084172227\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n },\n {\n "id": "mymIbw_W6k",\n "type": "end-node",\n "position": {\n "x": 953.9302142661356,\n "y": 172.0182108417223\n },\n "data": {},\n "measured": {\n "width": 256,\n "height": 75\n },\n "selected": false,\n "dragging": false\n }\n ],\n "edges": [\n {\n "source": "7e5vQLDGTl",\n "target": "ldoKAzHnKF",\n "id": "xy-edge__7e5vQLDGTl-ldoKAzHnKF"\n },\n {\n "source": "ldoKAzHnKF",\n "target": "Wyqg_bXILg",\n "id": "xy-edge__ldoKAzHnKF-Wyqg_bXILg"\n },\n {\n "source": "7e5vQLDGTl",\n "target": "1eJtMoJWs6",\n "id": "xy-edge__7e5vQLDGTl-1eJtMoJWs6"\n },\n {\n "source": "Wyqg_bXILg",\n "target": "7DaF-0G-yv",\n "id": "xy-edge__Wyqg_bXILg-7DaF-0G-yv"\n },\n {\n "source": "1eJtMoJWs6",\n "target": "7DaF-0G-yv",\n "id": "xy-edge__1eJtMoJWs6-7DaF-0G-yv"\n },\n {\n "source": "7DaF-0G-yv",\n "target": "mymIbw_W6k",\n "id": "xy-edge__7DaF-0G-yv-mymIbw_W6k"\n }\n ],\n "data": {\n "7e5vQLDGTl": {\n "inputs": {\n "question": {\n "type": "text",\n "description": "问题"\n }\n }\n },\n "ldoKAzHnKF": {\n "model": "qwen3",\n "outputs": {\n "text": {\n "type": "string"\n }\n },\n "systemPrompt": "你是个聪明人"\n },\n "1eJtMoJWs6": {\n "model": "deepseek",\n "outputs": {\n "text": {\n "type": "string"\n }\n },\n "systemPrompt": "你也是个好人"\n }\n }\n}')
|
||||||
let initialNodes = initialData['nodes'] ?? []
|
let initialNodes = initialData['nodes'] ?? []
|
||||||
let initialEdges = initialData['edges'] ?? []
|
let initialEdges = initialData['edges'] ?? []
|
||||||
|
|
||||||
@@ -242,12 +275,7 @@ function FlowEditor() {
|
|||||||
setData(initialNodeData)
|
setData(initialNodeData)
|
||||||
|
|
||||||
for (let node of initialNodes) {
|
for (let node of initialNodes) {
|
||||||
node.data = {
|
node.data = initialNodeHandlers
|
||||||
getDataById,
|
|
||||||
setDataById,
|
|
||||||
removeNode,
|
|
||||||
editNode,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setNodes(initialNodes)
|
setNodes(initialNodes)
|
||||||
setEdges(initialEdges)
|
setEdges(initialEdges)
|
||||||
@@ -267,12 +295,7 @@ function FlowEditor() {
|
|||||||
id: randomId(10),
|
id: randomId(10),
|
||||||
type: key,
|
type: key,
|
||||||
position: {x: 100, y: 100},
|
position: {x: 100, y: 100},
|
||||||
data: {
|
data: initialNodeHandlers,
|
||||||
getDataById,
|
|
||||||
setDataById,
|
|
||||||
removeNode,
|
|
||||||
editNode,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -287,8 +310,15 @@ function FlowEditor() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Button type="primary" onClick={() => {
|
<Button type="primary" onClick={() => {
|
||||||
|
try {
|
||||||
|
checkSave(nodes, edges, data)
|
||||||
let saveData = {nodes, edges, data}
|
let saveData = {nodes, edges, data}
|
||||||
console.log(JSON.stringify(saveData, null, 2))
|
console.log(JSON.stringify(saveData, null, 2))
|
||||||
|
console.log(buildEL(nodes, edges))
|
||||||
|
} catch (e) {
|
||||||
|
// @ts-ignore
|
||||||
|
messageApi.error(e.message)
|
||||||
|
}
|
||||||
}}>
|
}}>
|
||||||
<SaveFilled/>
|
<SaveFilled/>
|
||||||
保存
|
保存
|
||||||
|
|||||||
@@ -1,13 +1,41 @@
|
|||||||
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
||||||
import {Handle, type NodeProps, Position} from '@xyflow/react'
|
import {Handle, type HandleProps, type NodeProps, Position, useNodeConnections} from '@xyflow/react'
|
||||||
import type {Schema} from 'amis'
|
import type {Schema} from 'amis'
|
||||||
import {Card, Dropdown} from 'antd'
|
import {Card, Dropdown} from 'antd'
|
||||||
import {isEmpty, isEqual} from 'licia'
|
import {isEmpty, isEqual, isNil} from 'licia'
|
||||||
import type {JSX} from 'react'
|
import {type JSX} from 'react'
|
||||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||||
|
|
||||||
export type AmisNodeType = 'normal' | 'start' | 'end'
|
export type AmisNodeType = 'normal' | 'start' | 'end'
|
||||||
|
|
||||||
|
export function inputsFormColumns(required: boolean = false, preload?: any): Schema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'input-kvs',
|
||||||
|
name: 'inputs',
|
||||||
|
label: '输入变量',
|
||||||
|
value: preload,
|
||||||
|
addButtonText: '新增输入',
|
||||||
|
draggable: false,
|
||||||
|
keyItem: {
|
||||||
|
...horizontalFormOptions(),
|
||||||
|
label: '参数名称',
|
||||||
|
},
|
||||||
|
required: required,
|
||||||
|
valueItems: [
|
||||||
|
{
|
||||||
|
...horizontalFormOptions(),
|
||||||
|
type: 'select',
|
||||||
|
name: 'type',
|
||||||
|
label: '变量',
|
||||||
|
required: true,
|
||||||
|
options: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
export function outputsFormColumns(editable: boolean = false, required: boolean = false, preload?: any): Schema[] {
|
export function outputsFormColumns(editable: boolean = false, required: boolean = false, preload?: any): Schema[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -55,15 +83,38 @@ export function outputsFormColumns(editable: boolean = false, required: boolean
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const AmisNode = (
|
export const LimitHandler = (props: HandleProps & { limit: number }) => {
|
||||||
props: NodeProps,
|
const connections = useNodeConnections({
|
||||||
type: AmisNodeType,
|
handleType: props.type,
|
||||||
defaultNodeName: String,
|
})
|
||||||
defaultNodeDescription?: String,
|
return (
|
||||||
extraNodeDescription?: (nodeData: any) => JSX.Element,
|
<Handle
|
||||||
columnSchema?: Schema[],
|
{...props}
|
||||||
) => {
|
isConnectable={connections.length < props.limit}
|
||||||
const {id, data} = props
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type AmisNodeProps = {
|
||||||
|
nodeProps: NodeProps
|
||||||
|
type: AmisNodeType
|
||||||
|
defaultNodeName: String
|
||||||
|
defaultNodeDescription?: String
|
||||||
|
extraNodeDescription?: (nodeData: any) => JSX.Element
|
||||||
|
handlers?: (nodeData: any) => JSX.Element
|
||||||
|
columnSchema?: Schema[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const AmisNode: (props: AmisNodeProps) => JSX.Element = ({
|
||||||
|
nodeProps,
|
||||||
|
type,
|
||||||
|
defaultNodeName,
|
||||||
|
defaultNodeDescription,
|
||||||
|
extraNodeDescription,
|
||||||
|
handlers,
|
||||||
|
columnSchema,
|
||||||
|
}) => {
|
||||||
|
const {id, data} = nodeProps
|
||||||
const {getDataById, removeNode, editNode} = data
|
const {getDataById, removeNode, editNode} = data
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const nodeData = getDataById(id)
|
const nodeData = getDataById(id)
|
||||||
@@ -124,6 +175,7 @@ const AmisNode = (
|
|||||||
<Card
|
<Card
|
||||||
className="node-card"
|
className="node-card"
|
||||||
title={nodeName}
|
title={nodeName}
|
||||||
|
extra={<span className="text-gray-300 text-xs">{id}</span>}
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
<div className="card-description p-2 text-secondary text-sm">
|
<div className="card-description p-2 text-secondary text-sm">
|
||||||
@@ -132,10 +184,14 @@ const AmisNode = (
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
{isNil(handlers)
|
||||||
|
? <>
|
||||||
{isEqual(type, 'start') || isEqual(type, 'normal')
|
{isEqual(type, 'start') || isEqual(type, 'normal')
|
||||||
? <Handle type="source" position={Position.Right}/> : undefined}
|
? <Handle type="source" position={Position.Right}/> : undefined}
|
||||||
{isEqual(type, 'end') || isEqual(type, 'normal')
|
{isEqual(type, 'end') || isEqual(type, 'normal')
|
||||||
? <Handle type="target" position={Position.Left}/> : undefined}
|
? <Handle type="target" position={Position.Left}/> : undefined}
|
||||||
|
</>
|
||||||
|
: handlers?.(nodeData)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,13 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
import AmisNode, {inputsFormColumns, outputsFormColumns} from './AmisNode.tsx'
|
||||||
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
|
||||||
|
|
||||||
const CodeNode = (props: NodeProps) => AmisNode(
|
const CodeNode = (props: NodeProps) => AmisNode({
|
||||||
props,
|
nodeProps: props,
|
||||||
'normal',
|
type: 'normal',
|
||||||
'代码执行',
|
defaultNodeName: '代码执行',
|
||||||
'执行自定义的处理代码',
|
defaultNodeDescription: '执行自定义的处理代码',
|
||||||
undefined,
|
columnSchema: [
|
||||||
[
|
...inputsFormColumns(),
|
||||||
{
|
|
||||||
type: 'input-kvs',
|
|
||||||
name: 'inputs',
|
|
||||||
label: '输入变量',
|
|
||||||
addButtonText: '新增输入',
|
|
||||||
draggable: false,
|
|
||||||
keyItem: {
|
|
||||||
...horizontalFormOptions(),
|
|
||||||
label: '参数名称',
|
|
||||||
},
|
|
||||||
valueItems: [
|
|
||||||
{
|
|
||||||
...horizontalFormOptions(),
|
|
||||||
type: 'select',
|
|
||||||
name: 'type',
|
|
||||||
label: '变量',
|
|
||||||
required: true,
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'divider',
|
type: 'divider',
|
||||||
},
|
},
|
||||||
@@ -68,6 +46,6 @@ const CodeNode = (props: NodeProps) => AmisNode(
|
|||||||
},
|
},
|
||||||
...outputsFormColumns(true, true, {result: {type: 'string'}}),
|
...outputsFormColumns(true, true, {result: {type: 'string'}}),
|
||||||
],
|
],
|
||||||
)
|
})
|
||||||
|
|
||||||
export default CodeNode
|
export default CodeNode
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
||||||
|
|
||||||
const EndNode = (props: NodeProps) => AmisNode(
|
const EndNode = (props: NodeProps) => AmisNode({
|
||||||
props,
|
nodeProps: props,
|
||||||
'end',
|
type: 'end',
|
||||||
'结束节点',
|
defaultNodeName: '结束节点',
|
||||||
'定义输出变量',
|
defaultNodeDescription: '定义输出变量',
|
||||||
undefined,
|
columnSchema: outputsFormColumns(true),
|
||||||
outputsFormColumns(true),
|
})
|
||||||
)
|
|
||||||
|
|
||||||
export default EndNode
|
export default EndNode
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import {commonInfo} from '../../../../util/amis.tsx'
|
import {commonInfo} from '../../../../util/amis.tsx'
|
||||||
import AmisNode from './AmisNode.tsx'
|
import AmisNode, {inputsFormColumns, outputsFormColumns} from './AmisNode.tsx'
|
||||||
|
|
||||||
const KnowledgeNode = (props: NodeProps) => AmisNode(
|
const KnowledgeNode = (props: NodeProps) => AmisNode({
|
||||||
props,
|
nodeProps: props,
|
||||||
'normal',
|
type: 'normal',
|
||||||
'知识库',
|
defaultNodeName: '知识库',
|
||||||
'查询知识库获取外部知识',
|
defaultNodeDescription: '查询知识库获取外部知识',
|
||||||
undefined,
|
columnSchema: [
|
||||||
[
|
...inputsFormColumns(),
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
name: 'knowledgeId',
|
name: 'knowledgeId',
|
||||||
@@ -24,7 +27,7 @@ const KnowledgeNode = (props: NodeProps) => AmisNode(
|
|||||||
...payload,
|
...payload,
|
||||||
data: {
|
data: {
|
||||||
items: payload.data.items.map((item: any) => ({value: item['id'], label: item['name']})),
|
items: payload.data.items.map((item: any) => ({value: item['id'], label: item['name']})),
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -52,7 +55,11 @@ const KnowledgeNode = (props: NodeProps) => AmisNode(
|
|||||||
max: 1,
|
max: 1,
|
||||||
step: 0.05,
|
step: 0.05,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
|
...outputsFormColumns(false, true, {result: {type: 'array-string'}}),
|
||||||
],
|
],
|
||||||
)
|
})
|
||||||
|
|
||||||
export default KnowledgeNode
|
export default KnowledgeNode
|
||||||
@@ -1,29 +1,38 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
import AmisNode, {outputsFormColumns} from './AmisNode.tsx'
|
import {Tag} from 'antd'
|
||||||
|
import AmisNode, {inputsFormColumns, outputsFormColumns} from './AmisNode.tsx'
|
||||||
|
|
||||||
const LlmNode = (props: NodeProps) => AmisNode(
|
const modelMap: Record<string, string> = {
|
||||||
props,
|
qwen3: 'Qwen3',
|
||||||
'normal',
|
deepseek: 'Deepseek',
|
||||||
'大模型',
|
}
|
||||||
'使用大模型对话',
|
|
||||||
undefined,
|
const LlmNode = (props: NodeProps) => AmisNode({
|
||||||
[
|
nodeProps: props,
|
||||||
|
type: 'normal',
|
||||||
|
defaultNodeName: '大模型',
|
||||||
|
defaultNodeDescription: '使用大模型对话',
|
||||||
|
extraNodeDescription: nodeData => {
|
||||||
|
const model = nodeData?.model as string | undefined
|
||||||
|
return model
|
||||||
|
? <div className="mt-2 flex justify-between">
|
||||||
|
<span>大模型</span>
|
||||||
|
<Tag className="m-0" color="blue">{modelMap[model]}</Tag>
|
||||||
|
</div>
|
||||||
|
: <></>
|
||||||
|
},
|
||||||
|
columnSchema: [
|
||||||
|
...inputsFormColumns(),
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
name: 'model',
|
name: 'model',
|
||||||
label: '大模型',
|
label: '大模型',
|
||||||
required: true,
|
required: true,
|
||||||
selectFirst: true,
|
selectFirst: true,
|
||||||
options: [
|
options: Object.keys(modelMap).map(key => ({label: modelMap[key], value: key})),
|
||||||
{
|
|
||||||
label: 'Qwen3',
|
|
||||||
value: 'qwen3',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Deepseek',
|
|
||||||
value: 'deepseek',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
@@ -36,6 +45,6 @@ const LlmNode = (props: NodeProps) => AmisNode(
|
|||||||
},
|
},
|
||||||
...outputsFormColumns(false, true, {text: {type: 'string'}}),
|
...outputsFormColumns(false, true, {text: {type: 'string'}}),
|
||||||
],
|
],
|
||||||
)
|
})
|
||||||
|
|
||||||
export default LlmNode
|
export default LlmNode
|
||||||
@@ -1,14 +1,39 @@
|
|||||||
import type {NodeProps} from '@xyflow/react'
|
import type {NodeProps} from '@xyflow/react'
|
||||||
|
import {Tag} from 'antd'
|
||||||
|
import {each} from 'licia'
|
||||||
|
import type {JSX} from 'react'
|
||||||
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
import {horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||||
import AmisNode from './AmisNode.tsx'
|
import AmisNode from './AmisNode.tsx'
|
||||||
|
|
||||||
const StartNode = (props: NodeProps) => AmisNode(
|
const typeMap: Record<string, string> = {
|
||||||
props,
|
text: '文本',
|
||||||
'start',
|
number: '数字',
|
||||||
'开始节点',
|
files: '文件',
|
||||||
'定义输入变量',
|
}
|
||||||
undefined,
|
|
||||||
[
|
const StartNode = (props: NodeProps) => AmisNode({
|
||||||
|
nodeProps: props,
|
||||||
|
type: 'start',
|
||||||
|
defaultNodeName: '开始节点',
|
||||||
|
defaultNodeDescription: '定义输入变量',
|
||||||
|
extraNodeDescription: nodeData => {
|
||||||
|
const variables: JSX.Element[] = []
|
||||||
|
const inputs = (nodeData['inputs'] ?? {}) as Record<string, { type: string, description: string }>
|
||||||
|
each(inputs, (value, key) => {
|
||||||
|
variables.push(
|
||||||
|
<div className="mt-1 flex justify-between" key={key}>
|
||||||
|
<span>{key}</span>
|
||||||
|
<Tag className="m-0" color="blue">{typeMap[value.type]}</Tag>
|
||||||
|
</div>,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
return (
|
||||||
|
<div className="mt-2">
|
||||||
|
{...variables}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
columnSchema: [
|
||||||
{
|
{
|
||||||
type: 'input-kvs',
|
type: 'input-kvs',
|
||||||
name: 'inputs',
|
name: 'inputs',
|
||||||
@@ -33,24 +58,11 @@ const StartNode = (props: NodeProps) => AmisNode(
|
|||||||
label: '参数类型',
|
label: '参数类型',
|
||||||
required: true,
|
required: true,
|
||||||
selectFirst: true,
|
selectFirst: true,
|
||||||
options: [
|
options: Object.keys(typeMap).map(key => ({label: typeMap[key], value: key})),
|
||||||
{
|
|
||||||
label: '文本',
|
|
||||||
value: 'text',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '数字',
|
|
||||||
value: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '文件',
|
|
||||||
value: 'files',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
})
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
export default StartNode
|
export default StartNode
|
||||||
95
service-web/client/src/pages/ai/task/FlowTask.tsx
Normal file
95
service-web/client/src/pages/ai/task/FlowTask.tsx
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {amisRender, commonInfo, crudCommonOptions, paginationTemplate,} from '../../../util/amis.tsx'
|
||||||
|
import {useNavigate} from 'react-router'
|
||||||
|
|
||||||
|
const FlowTask: React.FC = () => {
|
||||||
|
const navigate = useNavigate()
|
||||||
|
return (
|
||||||
|
<div className="task-template">
|
||||||
|
{amisRender(
|
||||||
|
{
|
||||||
|
type: 'page',
|
||||||
|
title: '任务记录',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'crud',
|
||||||
|
api: {
|
||||||
|
method: 'post',
|
||||||
|
url: `${commonInfo.baseAiUrl}/flow_task/list`,
|
||||||
|
data: {
|
||||||
|
page: {
|
||||||
|
index: '${page}',
|
||||||
|
size: '${perPage}',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...crudCommonOptions(),
|
||||||
|
...paginationTemplate(
|
||||||
|
10,
|
||||||
|
5,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '',
|
||||||
|
icon: 'fa fa-plus',
|
||||||
|
size: 'sm',
|
||||||
|
onEvent: {
|
||||||
|
click: {
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
actionType: 'custom',
|
||||||
|
// @ts-ignore
|
||||||
|
script: (context, action, event) => {
|
||||||
|
navigate(`/ai/flow_task/add`)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
label: '任务ID',
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'status',
|
||||||
|
label: '状态',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'operation',
|
||||||
|
label: '操作',
|
||||||
|
width: 200,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '重新执行',
|
||||||
|
level: 'link',
|
||||||
|
size: 'sm',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '删除',
|
||||||
|
className: 'text-danger btn-deleted',
|
||||||
|
level: 'link',
|
||||||
|
size: 'sm',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: `get:${commonInfo.baseAiUrl}/task/remove/\${id}`,
|
||||||
|
confirmText: '确认删除任务记录:${name}',
|
||||||
|
confirmTitle: '删除',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FlowTask
|
||||||
36
service-web/client/src/pages/ai/task/FlowTaskAdd.tsx
Normal file
36
service-web/client/src/pages/ai/task/FlowTaskAdd.tsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {amisRender,} from '../../../util/amis.tsx'
|
||||||
|
|
||||||
|
const FlowTaskAdd: React.FC = () => {
|
||||||
|
// const navigate = useNavigate()
|
||||||
|
return (
|
||||||
|
<div className="task-template">
|
||||||
|
{amisRender(
|
||||||
|
{
|
||||||
|
type: 'page',
|
||||||
|
title: '发起任务',
|
||||||
|
body: {
|
||||||
|
type: 'wizard',
|
||||||
|
wrapWithPanel: false,
|
||||||
|
steps:[
|
||||||
|
{
|
||||||
|
title: '选择任务模板',
|
||||||
|
body: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '填写任务信息',
|
||||||
|
body: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '完成',
|
||||||
|
body: []
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FlowTaskAdd
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {amisRender, commonInfo, crudCommonOptions, paginationTemplate,} from '../../../../util/amis.tsx'
|
||||||
|
import {useNavigate} from 'react-router'
|
||||||
|
|
||||||
|
const FlowTaskTemplate: React.FC = () => {
|
||||||
|
const navigate = useNavigate()
|
||||||
|
return (
|
||||||
|
<div className="task-template">
|
||||||
|
{amisRender(
|
||||||
|
{
|
||||||
|
type: 'page',
|
||||||
|
title: '任务模板',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'crud',
|
||||||
|
api: {
|
||||||
|
method: 'post',
|
||||||
|
url: `${commonInfo.baseAiUrl}/flow_task/template/list`,
|
||||||
|
data: {
|
||||||
|
page: {
|
||||||
|
index: '${page}',
|
||||||
|
size: '${perPage}',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...crudCommonOptions(),
|
||||||
|
...paginationTemplate(
|
||||||
|
10,
|
||||||
|
5,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '',
|
||||||
|
icon: 'fa fa-plus',
|
||||||
|
size: 'sm',
|
||||||
|
onEvent: {
|
||||||
|
click: {
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
actionType: 'custom',
|
||||||
|
// @ts-ignore
|
||||||
|
script: (context, action, event) => {
|
||||||
|
navigate(`/ai/flow_task_template/edit/-1`)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
label: '名称',
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'description',
|
||||||
|
label: '描述',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'operation',
|
||||||
|
label: '操作',
|
||||||
|
width: 200,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '编辑',
|
||||||
|
level: 'link',
|
||||||
|
size: 'sm',
|
||||||
|
onEvent: {
|
||||||
|
click: {
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
actionType: 'custom',
|
||||||
|
// @ts-ignore
|
||||||
|
script: (context, action, event) => {
|
||||||
|
navigate(`/ai/flow_task_template/edit/${context.props.data['id']}`)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '删除',
|
||||||
|
className: 'text-danger btn-deleted',
|
||||||
|
level: 'link',
|
||||||
|
size: 'sm',
|
||||||
|
actionType: 'ajax',
|
||||||
|
api: `get:${commonInfo.baseAiUrl}/flow_task/template/remove/\${id}`,
|
||||||
|
confirmText: '确认删除任务模板:${name}',
|
||||||
|
confirmTitle: '删除',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FlowTaskTemplate
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {useParams} from 'react-router'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
import {amisRender, commonInfo, horizontalFormOptions} from '../../../../util/amis.tsx'
|
||||||
|
import {isEqual} from 'licia'
|
||||||
|
|
||||||
|
const TemplateEditDiv = styled.div`
|
||||||
|
.antd-EditorControl {
|
||||||
|
min-height: 500px !important;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const FlowTaskTemplateEdit: React.FC = () => {
|
||||||
|
const {template_id} = useParams()
|
||||||
|
const preloadTemplateId = isEqual(template_id, '-1') ? undefined : template_id
|
||||||
|
console.log('preloadTemplateId', preloadTemplateId)
|
||||||
|
return (
|
||||||
|
<TemplateEditDiv className="task-template-edit h-full">
|
||||||
|
{amisRender({
|
||||||
|
type: 'page',
|
||||||
|
title: '模板编辑',
|
||||||
|
body: {
|
||||||
|
debug: commonInfo.debug,
|
||||||
|
type: 'form',
|
||||||
|
api: {
|
||||||
|
method: 'POST',
|
||||||
|
url: `${commonInfo.baseAiUrl}/flow_task/template/save`,
|
||||||
|
data: {
|
||||||
|
name: '${template.name}',
|
||||||
|
description: '${template.description}',
|
||||||
|
inputSchema: '${template.inputSchema}',
|
||||||
|
flow: '${template.flow}',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initApi: preloadTemplateId
|
||||||
|
? {
|
||||||
|
method: 'GET',
|
||||||
|
url: `${commonInfo.baseAiUrl}/flow_task/template/detail/${preloadTemplateId}`,
|
||||||
|
// @ts-ignore
|
||||||
|
adaptor: (payload, response, api, context) => {
|
||||||
|
return {
|
||||||
|
...payload,
|
||||||
|
data: {
|
||||||
|
template: payload.data,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
wrapWithPanel: false,
|
||||||
|
...horizontalFormOptions(),
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'input-text',
|
||||||
|
name: 'template.name',
|
||||||
|
label: '名称',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'textarea',
|
||||||
|
name: 'template.description',
|
||||||
|
label: '描述',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'group',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'editor',
|
||||||
|
required: true,
|
||||||
|
label: '入参表单',
|
||||||
|
description: '使用amis代码编写入参表单结构,流程会解析所有name对应的变量传入流程开始阶段;只需要编写form的columns部分',
|
||||||
|
name: 'template.inputSchema',
|
||||||
|
value: '[]',
|
||||||
|
language: 'json',
|
||||||
|
options: {
|
||||||
|
wordWrap: 'bounded',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'amis',
|
||||||
|
name: 'template.inputSchema',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'editor',
|
||||||
|
required: true,
|
||||||
|
label: '任务流程',
|
||||||
|
name: 'template.flow',
|
||||||
|
description: '使用标准的LiteFlow语法',
|
||||||
|
language: 'xml',
|
||||||
|
options: {
|
||||||
|
wordWrap: 'bounded',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'button-toolbar',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
type: 'submit',
|
||||||
|
label: '提交',
|
||||||
|
level: 'primary',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'reset',
|
||||||
|
label: '重置',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})}
|
||||||
|
</TemplateEditDiv>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FlowTaskTemplateEdit
|
||||||
@@ -31,7 +31,7 @@ const queueCrud = (name: string) => {
|
|||||||
{
|
{
|
||||||
name: 'data.flinkJobId',
|
name: 'data.flinkJobId',
|
||||||
label: '任务 ID',
|
label: '任务 ID',
|
||||||
width: 190,
|
width: 200,
|
||||||
...copyField('data.flinkJobId'),
|
...copyField('data.flinkJobId'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
ClusterOutlined,
|
ClusterOutlined,
|
||||||
CompressOutlined,
|
CompressOutlined,
|
||||||
DatabaseOutlined,
|
DatabaseOutlined,
|
||||||
|
FileTextOutlined,
|
||||||
GatewayOutlined,
|
GatewayOutlined,
|
||||||
InfoCircleOutlined,
|
InfoCircleOutlined,
|
||||||
OpenAIOutlined,
|
OpenAIOutlined,
|
||||||
@@ -34,6 +35,10 @@ import YarnCluster from './pages/overview/YarnCluster.tsx'
|
|||||||
import Test from './pages/Test.tsx'
|
import Test from './pages/Test.tsx'
|
||||||
import {commonInfo} from './util/amis.tsx'
|
import {commonInfo} from './util/amis.tsx'
|
||||||
import FlowEditor from './pages/ai/flow/FlowEditor.tsx'
|
import FlowEditor from './pages/ai/flow/FlowEditor.tsx'
|
||||||
|
import FlowTaskTemplate from './pages/ai/task/template/FlowTaskTemplate.tsx'
|
||||||
|
import FlowTaskTemplateEdit from './pages/ai/task/template/FlowTaskTemplateEdit.tsx'
|
||||||
|
import FlowTask from './pages/ai/task/FlowTask.tsx'
|
||||||
|
import FlowTaskAdd from './pages/ai/task/FlowTaskAdd.tsx'
|
||||||
|
|
||||||
export const routes: RouteObject[] = [
|
export const routes: RouteObject[] = [
|
||||||
{
|
{
|
||||||
@@ -111,6 +116,22 @@ export const routes: RouteObject[] = [
|
|||||||
path: 'knowledge/detail/:knowledge_id/segment/:group_id',
|
path: 'knowledge/detail/:knowledge_id/segment/:group_id',
|
||||||
Component: DataSegment,
|
Component: DataSegment,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'flow_task',
|
||||||
|
Component: FlowTask,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'flow_task/add',
|
||||||
|
Component: FlowTaskAdd,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'flow_task_template',
|
||||||
|
Component: FlowTaskTemplate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'flow_task_template/edit/:template_id',
|
||||||
|
Component: FlowTaskTemplateEdit,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'flowable',
|
path: 'flowable',
|
||||||
Component: FlowEditor,
|
Component: FlowEditor,
|
||||||
@@ -158,7 +179,7 @@ export const menus = {
|
|||||||
icon: <SyncOutlined/>,
|
icon: <SyncOutlined/>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `/yarn/${commonInfo.clusters.compaction_names()}/${values(commonInfo.clusters.compaction).join(",")}/Compaction`,
|
path: `/yarn/${commonInfo.clusters.compaction_names()}/${values(commonInfo.clusters.compaction).join(',')}/Compaction`,
|
||||||
name: '压缩集群',
|
name: '压缩集群',
|
||||||
icon: <SyncOutlined/>,
|
icon: <SyncOutlined/>,
|
||||||
},
|
},
|
||||||
@@ -222,6 +243,23 @@ export const menus = {
|
|||||||
name: '流程编排',
|
name: '流程编排',
|
||||||
icon: <GatewayOutlined/>,
|
icon: <GatewayOutlined/>,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '1089caa6-9477-44a5-99f1-a9c179f6cfd3',
|
||||||
|
name: '任务',
|
||||||
|
icon: <FileTextOutlined/>,
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: '/ai/flow_task',
|
||||||
|
name: '任务列表',
|
||||||
|
icon: <FileTextOutlined/>,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/ai/flow_task_template',
|
||||||
|
name: '任务模板',
|
||||||
|
icon: <FileTextOutlined/>,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import {isEqual} from 'licia'
|
|||||||
export const commonInfo = {
|
export const commonInfo = {
|
||||||
debug: isEqual(import.meta.env.MODE, 'development'),
|
debug: isEqual(import.meta.env.MODE, 'development'),
|
||||||
baseUrl: 'http://132.126.207.130:35690/hudi_services/service_web',
|
baseUrl: 'http://132.126.207.130:35690/hudi_services/service_web',
|
||||||
baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web',
|
// baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web',
|
||||||
// baseAiUrl: 'http://localhost:8080',
|
baseAiUrl: 'http://localhost:8080',
|
||||||
authorizationHeaders: {
|
authorizationHeaders: {
|
||||||
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
|
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
Reference in New Issue
Block a user