haungxing
7 months ago
9 changed files with 206 additions and 28 deletions
@ -0,0 +1,34 @@ |
|||||||
|
package com.hnac.hzims.bigmodel.configuration; |
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.util.concurrent.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: huangxing |
||||||
|
* @Date: 2024/05/06 11:58 |
||||||
|
*/ |
||||||
|
@Component |
||||||
|
public class ThreadPoolManager { |
||||||
|
|
||||||
|
@Bean |
||||||
|
public ThreadPoolExecutor getAnswerPoolExecutor() { |
||||||
|
// 核心线程数
|
||||||
|
int corePoolSize = 5; |
||||||
|
// 最大线程数
|
||||||
|
int maximumPoolSize = 10; |
||||||
|
// 线程空闲时的存活时间
|
||||||
|
long keepAliveTime = 60L; |
||||||
|
// 时间单位
|
||||||
|
TimeUnit unit = TimeUnit.SECONDS; |
||||||
|
// 任务队列
|
||||||
|
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(100); |
||||||
|
// 线程工厂
|
||||||
|
ThreadFactory threadFactory = Executors.defaultThreadFactory(); |
||||||
|
// 拒绝策略
|
||||||
|
RejectedExecutionHandler handler = new ThreadPoolExecutor.AbortPolicy(); |
||||||
|
return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory,handler); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
package com.hnac.hzims.bigmodel.interactive.vo; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: huangxing |
||||||
|
* @Date: 2024/05/06 14:37 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ApiModel("HZLLM答案VO对象") |
||||||
|
@EqualsAndHashCode |
||||||
|
public class AnswerVO implements Serializable { |
||||||
|
|
||||||
|
@ApiModelProperty("发起问答时的随机ID") |
||||||
|
@JSONField(name = "id") |
||||||
|
private String sessionId; |
||||||
|
|
||||||
|
@ApiModelProperty("发起问答时的用户ID") |
||||||
|
@JSONField(name = "userid") |
||||||
|
private String userId; |
||||||
|
|
||||||
|
@ApiModelProperty("1代表代表正在进行问答,0代表已完成") |
||||||
|
private Integer running; |
||||||
|
|
||||||
|
/** |
||||||
|
* 正常发起一次问答,status会经历0、1、2、3、9、0的过程,如果问答需要执行多次指令,则可能会是0、1、2、3、2、3、9、0。 |
||||||
|
* 9为大模型回复中,answer中会不断填充内容 |
||||||
|
*/ |
||||||
|
@ApiModelProperty("1代表代表正在进行问答,0代表已完成") |
||||||
|
private Integer status; |
||||||
|
|
||||||
|
@ApiModelProperty("当running为1时,用于显示状态文本") |
||||||
|
private String text; |
||||||
|
|
||||||
|
@ApiModelProperty("最近一次发起的问题") |
||||||
|
private String query; |
||||||
|
|
||||||
|
@ApiModelProperty("query对应的答案") |
||||||
|
private String answer; |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue