Cuong2004 commited on
Commit
dc5847f
·
1 Parent(s): addc239

hospital if any

Browse files
Files changed (1) hide show
  1. src/agent/agent-executor.ts +14 -3
src/agent/agent-executor.ts CHANGED
@@ -409,9 +409,12 @@ Ví dụ format markdown NGẮN GỌN:
409
  if (bestHospital) {
410
  logger.info(`[AGENT] Found best matching hospital: ${bestHospital.name} (${bestHospital.distance_km}km away${bestHospital.specialty_score ? `, specialty match: ${bestHospital.specialty_score.toFixed(2)}` : ''})`);
411
  logger.info(`[REPORT] ✓ Hospital tool (MCP) executed successfully: ${bestHospital.name}`);
 
 
412
  return {
413
  ...finalResult,
414
- nearest_clinic: bestHospital
 
415
  };
416
  } else {
417
  logger.warn('[AGENT] No hospital found nearby');
@@ -545,12 +548,17 @@ Ví dụ format markdown NGẮN GỌN:
545
  );
546
  if (bestHospital) {
547
  logger.info(`[AGENT] Found best matching hospital: ${bestHospital.name} (${bestHospital.distance_km}km away${bestHospital.specialty_score ? `, specialty match: ${bestHospital.specialty_score.toFixed(2)}` : ''})`);
 
 
 
548
  return {
549
  ...finalResult,
550
- nearest_clinic: bestHospital
 
551
  };
552
  } else {
553
  logger.warn('[AGENT] No hospital found nearby');
 
554
  }
555
  } catch (error) {
556
  logger.error({ error }, '[AGENT] Failed to find best matching hospital');
@@ -570,9 +578,12 @@ Ví dụ format markdown NGẮN GỌN:
570
  if (bestHospital) {
571
  logger.info(`[AGENT] Found best matching hospital: ${bestHospital.name} (${bestHospital.distance_km}km away${bestHospital.specialty_score ? `, specialty match: ${bestHospital.specialty_score.toFixed(2)}` : ''})`);
572
  logger.info(`[REPORT] ✓ Hospital tool (MCP) executed successfully: ${bestHospital.name}`);
 
 
573
  return {
574
  ...finalResult,
575
- nearest_clinic: bestHospital
 
576
  };
577
  }
578
  } catch (error) {
 
409
  if (bestHospital) {
410
  logger.info(`[AGENT] Found best matching hospital: ${bestHospital.name} (${bestHospital.distance_km}km away${bestHospital.specialty_score ? `, specialty match: ${bestHospital.specialty_score.toFixed(2)}` : ''})`);
411
  logger.info(`[REPORT] ✓ Hospital tool (MCP) executed successfully: ${bestHospital.name}`);
412
+ // Append hospital info to message markdown
413
+ const hospitalInfo = `\n\n## 🏥 Bệnh viện gần nhất\n\n**${bestHospital.name}**\n- Khoảng cách: ${bestHospital.distance_km}km\n- Địa chỉ: ${bestHospital.address || 'Địa chỉ không có sẵn'}${bestHospital.rating ? `\n- Đánh giá: ${bestHospital.rating}/5` : ''}`;
414
  return {
415
  ...finalResult,
416
+ nearest_clinic: bestHospital,
417
+ message: (finalResult.message || '') + hospitalInfo
418
  };
419
  } else {
420
  logger.warn('[AGENT] No hospital found nearby');
 
548
  );
549
  if (bestHospital) {
550
  logger.info(`[AGENT] Found best matching hospital: ${bestHospital.name} (${bestHospital.distance_km}km away${bestHospital.specialty_score ? `, specialty match: ${bestHospital.specialty_score.toFixed(2)}` : ''})`);
551
+ logger.info(`[REPORT] ✓ Hospital tool (MCP) executed successfully: ${bestHospital.name}`);
552
+ // Append hospital info to message markdown
553
+ const hospitalInfo = `\n\n## 🏥 Bệnh viện gần nhất\n\n**${bestHospital.name}**\n- Khoảng cách: ${bestHospital.distance_km}km\n- Địa chỉ: ${bestHospital.address || 'Địa chỉ không có sẵn'}${bestHospital.rating ? `\n- Đánh giá: ${bestHospital.rating}/5` : ''}`;
554
  return {
555
  ...finalResult,
556
+ nearest_clinic: bestHospital,
557
+ message: (finalResult.message || '') + hospitalInfo
558
  };
559
  } else {
560
  logger.warn('[AGENT] No hospital found nearby');
561
+ logger.info('[REPORT] Hospital tool (MCP) executed but no hospital found');
562
  }
563
  } catch (error) {
564
  logger.error({ error }, '[AGENT] Failed to find best matching hospital');
 
578
  if (bestHospital) {
579
  logger.info(`[AGENT] Found best matching hospital: ${bestHospital.name} (${bestHospital.distance_km}km away${bestHospital.specialty_score ? `, specialty match: ${bestHospital.specialty_score.toFixed(2)}` : ''})`);
580
  logger.info(`[REPORT] ✓ Hospital tool (MCP) executed successfully: ${bestHospital.name}`);
581
+ // Append hospital info to message markdown
582
+ const hospitalInfo = `\n\n## 🏥 Bệnh viện gần nhất\n\n**${bestHospital.name}**\n- Khoảng cách: ${bestHospital.distance_km}km\n- Địa chỉ: ${bestHospital.address || 'Địa chỉ không có sẵn'}${bestHospital.rating ? `\n- Đánh giá: ${bestHospital.rating}/5` : ''}`;
583
  return {
584
  ...finalResult,
585
+ nearest_clinic: bestHospital,
586
+ message: (finalResult.message || '') + hospitalInfo
587
  };
588
  }
589
  } catch (error) {