feat(ai-web): 增加任务和任务模板
This commit is contained in:
@@ -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> {
|
||||||
|
}
|
||||||
@@ -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
|
|
||||||
|
|||||||
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
|
||||||
@@ -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