提交大模型对话保活任务
parent
36345e566f
commit
9c6e740441
@ -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<JSONObject> res = AiChatUtil.chat("你好");
|
||||||
|
if (res.isPresent()) {
|
||||||
|
log.info("大模型保活定时任务成功");
|
||||||
|
} else {
|
||||||
|
log.info("大模型保活定时任务失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue