|
@@ -35,6 +35,157 @@ export class PageFlowTestComponent {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ async farmWorkflow() {
|
|
|
+ const collectProblemTask = new TaskUserForm({
|
|
|
+ title: '农业问题描述采集',
|
|
|
+ input: [], // 初始任务不需要输入
|
|
|
+ output: [
|
|
|
+ { name: 'cropType', type: 'string', required: true },
|
|
|
+ { name: 'growthStage', type: 'string', required: false },
|
|
|
+ { name: 'problemDesc', type: 'string', required: true },
|
|
|
+ { name: 'symptoms', type: 'string', required: false },
|
|
|
+ { name: 'urgency', type: 'number', required: false }
|
|
|
+ ],
|
|
|
+ modalCtrl: this.modalCtrl,
|
|
|
+ fieldList: [
|
|
|
+ {
|
|
|
+ type: "String",
|
|
|
+ key: "cropType",
|
|
|
+ name: "作物种类",
|
|
|
+ required: true,
|
|
|
+ placeholder: "如:水稻、玉米、西红柿"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "Select",
|
|
|
+ key: "growthStage",
|
|
|
+ name: "生长阶段",
|
|
|
+ options: [
|
|
|
+ { label: "育苗期", value: "seedling" },
|
|
|
+ { label: "生长期", value: "growth" },
|
|
|
+ { label: "开花期", value: "blooming" },
|
|
|
+ { label: "结果期", value: "fruiting" }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "Textarea",
|
|
|
+ key: "problemDesc",
|
|
|
+ name: "问题描述",
|
|
|
+ required: true,
|
|
|
+ placeholder: "请详细描述作物异常情况..."
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "Textarea",
|
|
|
+ key: "symptoms",
|
|
|
+ name: "症状表现",
|
|
|
+ options: [
|
|
|
+ { label: "叶片发黄", value: "yellowing" },
|
|
|
+ { label: "枯萎", value: "wilting" },
|
|
|
+ { label: "病斑", value: "spots" },
|
|
|
+ { label: "虫害痕迹", value: "pests" },
|
|
|
+ { label: "霉变", value: "mold" }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "Radio",
|
|
|
+ key: "urgency",
|
|
|
+ name: "紧急程度",
|
|
|
+ options: [
|
|
|
+ { label: "轻微观察", value: 1 },
|
|
|
+ { label: "需要处理", value: 2 },
|
|
|
+ { label: "紧急", value: 3 }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ const problemClassificationTask = new TaskCompletionJson({
|
|
|
+ title: '农业问题分类',
|
|
|
+ input: [
|
|
|
+ { name: 'cropType', type: 'string', required: true },
|
|
|
+ { name: 'growthStage', type: 'string', required: false },
|
|
|
+ { name: 'problemDesc', type: 'string', required: true },
|
|
|
+ { name: 'symptoms', type: 'string', required: false }
|
|
|
+ ],
|
|
|
+ output: [
|
|
|
+ { name: 'problemDesc', type: 'string', required: true },
|
|
|
+ { name: 'symptoms', type: 'string', required: true },
|
|
|
+ { name: 'cropType', type: 'string', required: false }
|
|
|
+ ],
|
|
|
+ promptTemplate: `作为农业专家,请分析问题并返回JSON:
|
|
|
+ {
|
|
|
+ "problemType": ["病虫害|营养缺乏|种植技术|气候影响"],
|
|
|
+ "confidence": "置信度(0-1)",
|
|
|
+ "tags": ["关键词标签"]
|
|
|
+ }
|
|
|
+ 输入数据:{{problemDesc}} {{symptoms}} {{growthStage}} {{cropType}} {{urgency}}`,
|
|
|
+ });
|
|
|
+
|
|
|
+ const solutionGenerationTask = new TaskCompletionText({
|
|
|
+ title: '农业解决方案生成',
|
|
|
+ input: [
|
|
|
+ { name: 'cropType', type: 'string', required: true },
|
|
|
+ { name: 'problemType', type: 'array', required: true },
|
|
|
+ { name: 'symptoms', type: 'string', required: false }
|
|
|
+ ],
|
|
|
+ output: [
|
|
|
+ { name: 'solution', type: 'string', required: true }
|
|
|
+ ],
|
|
|
+ promptTemplate: `根据以下信息生成解决方案:
|
|
|
+ **作物**:{{cropType}}
|
|
|
+ **问题类型**:{{problemType}}
|
|
|
+ **症状**:{{symptoms}}
|
|
|
+
|
|
|
+ 要求:
|
|
|
+ 1. 分步骤说明处理措施
|
|
|
+ 2. 包含安全注意事项
|
|
|
+ 3. 语言通俗易懂`,
|
|
|
+ outputProperty: 'solution'
|
|
|
+ });
|
|
|
+
|
|
|
+ const pesticideRecommendationTask = new TaskCompletionJson({
|
|
|
+ title: '安全农药推荐',
|
|
|
+ input: [
|
|
|
+ { name: 'cropType', type: 'string', required: true },
|
|
|
+ { name: 'problemType', type: 'array', required: true }
|
|
|
+ ],
|
|
|
+ output: [
|
|
|
+ {
|
|
|
+ name: 'recommendations',
|
|
|
+ type: 'array',
|
|
|
+ required: true,
|
|
|
+ description: '推荐的农药列表'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ promptTemplate: `推荐合规农药(返回JSON):
|
|
|
+ {
|
|
|
+ "recommendations": [{
|
|
|
+ "name": "农药名称",
|
|
|
+ "type": "杀虫剂|杀菌剂|除草剂",
|
|
|
+ "dosage": "每亩用量",
|
|
|
+ "safetyLevel": "低毒|中毒|高毒"
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ 作物:{{cropType}}
|
|
|
+ 病虫害:{{problemType}}`
|
|
|
+ });
|
|
|
+ // 创建工作流
|
|
|
+ let workflow = {
|
|
|
+ title: '农业咨询工作流',
|
|
|
+ desc: '农业种植问题',
|
|
|
+ taskList: [collectProblemTask, problemClassificationTask, solutionGenerationTask, pesticideRecommendationTask]
|
|
|
+ };
|
|
|
+
|
|
|
+ this.executor.setWorkflow(workflow);
|
|
|
+ const modal = await this.modalCtrl.create({
|
|
|
+ component: FlowDisplayComponent,
|
|
|
+ componentProps: { executor: this.executor }
|
|
|
+ });
|
|
|
+
|
|
|
+ await modal.present();
|
|
|
+ await this.executor.start();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
async getForm() {
|
|
|
const fieldList = [
|
|
|
{ type: "String", key: "name", name: "姓名", required: true },
|
|
@@ -202,7 +353,7 @@ export class PageFlowTestComponent {
|
|
|
output: [
|
|
|
{ name: 'diagnosis', type: 'string', required: true },
|
|
|
{ name: 'treatmentPlan', type: 'string', required: true },
|
|
|
- { name: 'medications', type: 'array', required: false },
|
|
|
+ { name: 'medications', type: 'string', required: false },
|
|
|
{ name: 'followUp', type: 'string', required: false },
|
|
|
{ name: 'notes', type: 'string', required: false }
|
|
|
],
|