From 9c6e74044199a2c8e18f933887c62e69a6e83473 Mon Sep 17 00:00:00 2001 From: liu Date: Wed, 12 Jun 2024 09:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E4=BF=9D=E6=B4=BB=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/supervision/task/KeepAliveTask.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 virtual-patient-web/src/main/java/com/supervision/task/KeepAliveTask.java diff --git a/virtual-patient-web/src/main/java/com/supervision/task/KeepAliveTask.java b/virtual-patient-web/src/main/java/com/supervision/task/KeepAliveTask.java new file mode 100644 index 00000000..421782c8 --- /dev/null +++ b/virtual-patient-web/src/main/java/com/supervision/task/KeepAliveTask.java @@ -0,0 +1,31 @@ +package com.supervision.task; + +import cn.hutool.json.JSONObject; +import com.supervision.util.AiChatUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class KeepAliveTask { + + /** + * 保活,每3分钟一次 + */ + @Scheduled(fixedDelay = 1000 * 60 * 3) + public void keepAlive() { + log.info("大模型保活定时任务"); + Optional res = AiChatUtil.chat("你好"); + if (res.isPresent()) { + log.info("大模型保活定时任务成功"); + } else { + log.info("大模型保活定时任务失败"); + } + + } +}