|
@@ -0,0 +1,141 @@
|
|
|
+import { AgentTaskStep } from 'src/agent/agent.task';
|
|
|
+import { getUserInput } from 'src/agent/agent.input';
|
|
|
+import { ModalController } from '@ionic/angular/standalone';
|
|
|
+import { FmodeChatCompletion } from 'fmode-ng';
|
|
|
+import { extactAndParseJsonFromString } from 'src/agent/agent.json';
|
|
|
+
|
|
|
+export function TaskInqueryUserAnswer(options:{
|
|
|
+ modalCtrl:ModalController
|
|
|
+ shareData:any}
|
|
|
+ ):AgentTaskStep{
|
|
|
+
|
|
|
+ shareData.userStory
|
|
|
+ {
|
|
|
+ "questionList": [
|
|
|
+ {
|
|
|
+ "title": "头痛的性质",
|
|
|
+ "desc": "请问您的偏头痛是怎样的感觉?是刺痛、跳动还是压迫感?"
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ */
|
|
|
+ let task1 = new AgentTaskStep({title:"诊断:患者回答具体内容后,医生给出诊断结果",shareData:options.shareData})
|
|
|
+ task1.handle = ()=>{
|
|
|
+ return new Promise(async (resolve,reject)=>{
|
|
|
+
|
|
|
+ let questionList = options.shareData.userStory.questionList.map((item:any)=>{return {name:item.title,desc:item.desc,type:"text"}})
|
|
|
+
|
|
|
+ let userInputResult = await getUserInput(options.modalCtrl,{filedsArray:questionList});
|
|
|
+ console.log(userInputResult)
|
|
|
+ questionList.forEach((question:any)=>{
|
|
|
+ question.answer = userInputResult[question.name]
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ let qaContent = options.shareData.userStory.questionList.map((item:any)=>`医生问:${item.title},${item.desc}\n患者答:${item.answer||"没回答"}`).join("\n")
|
|
|
+ let PromptTemplate = `您是一名专业的${options.shareData.userStory.keshi}主任医生,根据具体的询问,给出初步诊断。
|
|
|
+ 症状口述:${options.shareData.userStory['症状口述']}
|
|
|
+ 具体询问:${qaContent}
|
|
|
+ 结果以JSON格式表示:
|
|
|
+ 症状名称为具体的症状,症状描述为用户的感受,持续时间若没有直接说,可以写近期即可。
|
|
|
+ {
|
|
|
+ "title":"病例标题",
|
|
|
+ "desc":"病情概括",
|
|
|
+ "content":"给出完整的治疗方案和建议"
|
|
|
+ }
|
|
|
+ `
|
|
|
+ let completion = new FmodeChatCompletion([
|
|
|
+ {role:"system",content:""},
|
|
|
+ {role:"user",content:PromptTemplate}
|
|
|
+ ])
|
|
|
+ completion.sendCompletion().subscribe((message:any)=>{
|
|
|
+ if(task1.progress < 0.5){
|
|
|
+ task1.progress += 0.1
|
|
|
+ }
|
|
|
+ if(task1.progress >= 0.5 && task1.progress <= 0.9){
|
|
|
+ task1.progress += 0.01
|
|
|
+ }
|
|
|
+ if(task1.progress >= 0.9){
|
|
|
+ task1.progress += 0.001
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(message.content)
|
|
|
+
|
|
|
+ if(message.complete){
|
|
|
+ options.shareData.diagResult = extactAndParseJsonFromString(message.content)
|
|
|
+ task1.progress = 1
|
|
|
+ resolve(true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ return task1
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const TestShareData = {
|
|
|
+userStory : {
|
|
|
+ "keshi": "神经内科",
|
|
|
+ "sympList": [
|
|
|
+ {
|
|
|
+ "title": "偏头疼",
|
|
|
+ "desc": "已经持续了2天了",
|
|
|
+ "duration": "2天"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "发冷",
|
|
|
+ "desc": "感觉已经有一天",
|
|
|
+ "duration": "1天"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "症状口述": "偏头疼已经持续了2天了,发冷感觉已经有一天。",
|
|
|
+ "questionList": [
|
|
|
+ {
|
|
|
+ "title": "头痛的性质",
|
|
|
+ "desc": "请描述您的头痛是搏动性、压迫性还是其他类型?",
|
|
|
+ "answer":"压迫性头疼"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "头痛的部位",
|
|
|
+ "desc": "您的头痛主要集中在头部的哪个区域?",
|
|
|
+ "answer":"左侧头疼"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "伴随症状",
|
|
|
+ "desc": "除了头痛和发冷,您还有其他的症状吗?例如恶心、呕吐、视力模糊或对光敏感等?",
|
|
|
+ "answer":"有点恶心但是没有呕吐"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "发冷的性质",
|
|
|
+ "desc": "您感到发冷时是否伴随有发热、出汗或其他症状?",
|
|
|
+ "answer":"没有"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "既往病史",
|
|
|
+ "desc": "您是否有偏头痛或其他头痛的病史?",
|
|
|
+ "answer":"没有"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "生活习惯",
|
|
|
+ "desc": "您最近的生活习惯是否有变化?例如睡眠不足、压力增大或饮食不规律?",
|
|
|
+ "answer":"经常熬夜,学习压力大"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "药物使用",
|
|
|
+ "desc": "您是否有服用任何药物来缓解头痛或其他症状?",
|
|
|
+ "answer":"没有"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "家族病史",
|
|
|
+ "desc": "您的家族中是否有人有类似的头痛或神经系统疾病史?",
|
|
|
+ "answer":"没有"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "过敏史",
|
|
|
+ "desc": "您是否有药物或其他物质的过敏史?",
|
|
|
+ "answer":"没有"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+}
|