阿里千问优化
This commit is contained in:
parent
6ef3d637be
commit
af64a3caaa
@ -28,13 +28,7 @@ public class AliYunQianWen {
|
|||||||
/**
|
/**
|
||||||
* 阿里千问配置参数
|
* 阿里千问配置参数
|
||||||
*/
|
*/
|
||||||
static final QwenParam qwenParam = QwenParam.builder().model(Generation.Models.QWEN_PLUS)
|
QwenParam qwenParam;
|
||||||
.resultFormat(QwenParam.ResultFormat.MESSAGE)
|
|
||||||
.topP(0.8)
|
|
||||||
.apiKey(SpringUtil.getProperty("Ali.qianwen"))
|
|
||||||
.enableSearch(true)
|
|
||||||
.incrementalOutput(true) // get streaming output incrementally
|
|
||||||
.build();;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息管理,上下文。默认最多10个
|
* 消息管理,上下文。默认最多10个
|
||||||
@ -45,6 +39,16 @@ public class AliYunQianWen {
|
|||||||
|
|
||||||
GenerationResult lastGenerationResult = null;
|
GenerationResult lastGenerationResult = null;
|
||||||
|
|
||||||
|
public AliYunQianWen(String key) {
|
||||||
|
qwenParam = QwenParam.builder().model(Generation.Models.QWEN_PLUS)
|
||||||
|
.resultFormat(QwenParam.ResultFormat.MESSAGE)
|
||||||
|
.topP(0.8)
|
||||||
|
.apiKey(key)
|
||||||
|
.enableSearch(true)
|
||||||
|
.incrementalOutput(true) // get streaming output incrementally
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void sendMessage(String msg,
|
public void sendMessage(String msg,
|
||||||
Consumer<? super String> onNext,
|
Consumer<? super String> onNext,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.qiuguo.iot.third.service;
|
package com.qiuguo.iot.third.service;
|
||||||
|
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.qiuguo.iot.base.constans.RedisConstans;
|
import com.qiuguo.iot.base.constans.RedisConstans;
|
||||||
@ -39,7 +40,7 @@ public class QWenService {
|
|||||||
public Mono<QWenReplyResponse> communication(TongYiCommunicationRest rest, Consumer<? super String> onNext){
|
public Mono<QWenReplyResponse> communication(TongYiCommunicationRest rest, Consumer<? super String> onNext){
|
||||||
AliYunQianWen aliQianWen = null;
|
AliYunQianWen aliQianWen = null;
|
||||||
if (!qianwenGroup.containsKey(rest.getOnlyId())) {
|
if (!qianwenGroup.containsKey(rest.getOnlyId())) {
|
||||||
aliQianWen = new AliYunQianWen();
|
aliQianWen = new AliYunQianWen(SpringUtil.getProperty("Ali.qianwen"));
|
||||||
qianwenGroup.put(rest.getOnlyId(), aliQianWen);
|
qianwenGroup.put(rest.getOnlyId(), aliQianWen);
|
||||||
} else {
|
} else {
|
||||||
aliQianWen = qianwenGroup.get(rest.getOnlyId());
|
aliQianWen = qianwenGroup.get(rest.getOnlyId());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user