|
@@ -0,0 +1,491 @@
|
|
|
+package com.ch.jedge.jbot2;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.ch.jedge.jbot2.dict.JEDictUtil;
|
|
|
+import com.ch.jedge.jbot2.dict.JedgeWordDict;
|
|
|
+import com.ch.jedge.jbot2.llm.JedgeLLMContext;
|
|
|
+import com.ch.jedge.jbot2.context.JedgeTalkSession;
|
|
|
+import com.ch.jedge.jbot2.context.JedgeSmartTaskContext;
|
|
|
+import com.ch.jedge.utils.JedgeBotConst;
|
|
|
+import com.ch.jedge.utils.JedgeLlmUtil;
|
|
|
+import com.changhong.jedge.JMgbusModual;
|
|
|
+import com.changhong.jedge.JMgbusService;
|
|
|
+import com.changhong.jedge.JMgbusUtil;
|
|
|
+import com.changhong.jedge.MgbusApi;
|
|
|
+import com.changhong.qlib.QData;
|
|
|
+import com.changhong.qlib.intf.QIData;
|
|
|
+import com.changhong.qlib.util.NumberUtils;
|
|
|
+import com.changhong.qlib.util.StringUtils;
|
|
|
+import com.changhong.qlib.util.TimeUtils;
|
|
|
+import com.changhong.qlib.util.file.FileUtils;
|
|
|
+import com.changhong.qlib.util.sync.SystemUtils;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import static com.ch.jedge.jbot.other.agent.JedgeGdeConsts.sval_default_app;
|
|
|
+import static com.ch.jedge.utils.JedgeBotConst.*;
|
|
|
+
|
|
|
+public class JedgeBotGptService extends JMgbusService {
|
|
|
+
|
|
|
+ protected final Map<String, JedgeWordDict> dict_ = new HashMap<>();
|
|
|
+ protected final Map<String, JedgeTalkSession> sessions_ = new HashMap<>();
|
|
|
+ protected final Queue<QIData> ret_msgs_ = new LinkedList<>();
|
|
|
+
|
|
|
+ private boolean quit_ = false;
|
|
|
+ private boolean active_ = false;
|
|
|
+ private String kn_talk_log_file;
|
|
|
+ private String talk_log_org_;
|
|
|
+
|
|
|
+ private final JedgeSmartTaskContext smartTaskContext;
|
|
|
+ private final JedgeLLMContext llmCtx;
|
|
|
+
|
|
|
+ //基本词库
|
|
|
+ //
|
|
|
+ public JedgeBotGptService(JMgbusModual holder) {
|
|
|
+ super(holder);
|
|
|
+ llmCtx = new JedgeLLMContext(module, this);
|
|
|
+ smartTaskContext = new JedgeSmartTaskContext(llmCtx);
|
|
|
+ auto_remove_call_info = false;
|
|
|
+
|
|
|
+ kn_talk_log_file = talk_log_org_ = FileUtils.contactPath("./", "logs");
|
|
|
+ try {
|
|
|
+ new File(talk_log_org_).mkdirs();
|
|
|
+ } catch (Exception ignored) {}
|
|
|
+ talk_log_org_ = FileUtils.contactPath(talk_log_org_,"userAsk.log");
|
|
|
+ kn_talk_log_file = FileUtils.contactPath(kn_talk_log_file,"knTalk.log");
|
|
|
+
|
|
|
+ //加载动态词库
|
|
|
+ JEDictUtil.loadStaticCommonDicts(dict_, FileUtils.contactPath("./", "cfg", "dict", "common"));
|
|
|
+
|
|
|
+ watchLocalEvent("OnModuleConnected", (w, keyVal, msg) -> {
|
|
|
+ String host = msg.getString("host");
|
|
|
+ int port = msg.getInteger("port");
|
|
|
+ reactiveCommonDictionaries();
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ watchLocalEvent("OnModuleDisconnected", (w, keyVal, msg) -> {
|
|
|
+ String host = msg.getString("host");
|
|
|
+ int port = msg.getInteger("port");
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void reactiveCommonDictionaries() {
|
|
|
+ //将词库的所有词汇添加到jieba分词中
|
|
|
+ synchronized (dict_) {
|
|
|
+ for(JedgeWordDict d : dict_.values()) {
|
|
|
+ activeWordDict(d);
|
|
|
+// SystemUtils.tryWait(50);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void activeWordDict(JedgeWordDict dict) {
|
|
|
+ if(dict==null) return;
|
|
|
+ JSONArray items = dict.getWordItemsInJson(false);
|
|
|
+ if(!items.isEmpty()) {
|
|
|
+ postServiceMessage(sval_modual_word_cut, "/cw/word", new QData().put("w", items));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void knItemPoolHeartBeat() {
|
|
|
+ module.warnLog("knItemPoolHeartBeat thread start ok.");
|
|
|
+ while (!quit_) {
|
|
|
+ SystemUtils.tryWaitforSingal(smartTaskContext, 1000);
|
|
|
+ try {
|
|
|
+ smartTaskContext.onHeartbeat();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ module.warnLog("knItemPoolHeartBeat thread end.");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onServiceStart() {
|
|
|
+ quit_ = false;
|
|
|
+ module.postThread(this::postTextRetSourceMessage);
|
|
|
+ module.postThread(this::clearTimeoutSession);
|
|
|
+ module.postThread(this::knItemPoolHeartBeat);
|
|
|
+
|
|
|
+ super.onServiceStart();
|
|
|
+ }
|
|
|
+
|
|
|
+ public JSONArray cutWords(String query) {
|
|
|
+ if(query.contains("、")) {
|
|
|
+ query = query.replaceAll("、","_");
|
|
|
+ }
|
|
|
+ QIData p = postServiceRequest(sval_modual_word_cut, "/cw/cut", new QData().put("t", query));
|
|
|
+ if(JMgbusUtil.isMgbusResultOk(p)) {
|
|
|
+ JSONArray re = p.getJsonArray("payload");
|
|
|
+ if(re != null)
|
|
|
+ return re;
|
|
|
+ }
|
|
|
+ return new JSONArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onServiceStop() {
|
|
|
+ quit_ = true;
|
|
|
+ SystemUtils.notifyAllObject(sessions_);
|
|
|
+ SystemUtils.notifyAllObject(ret_msgs_);
|
|
|
+ //等待退出完成
|
|
|
+ while(active_) {
|
|
|
+ SystemUtils.tryWaitforSingal(ret_msgs_, 20);
|
|
|
+ }
|
|
|
+ super.onServiceStop();
|
|
|
+ }
|
|
|
+
|
|
|
+ //切换知识库(默认,如果不存在则添加)
|
|
|
+ @MgbusApi
|
|
|
+ public QIData knTalk(QIData req) {
|
|
|
+ String prompt = req.getString("text");
|
|
|
+// module.SimpleMark("用户输入>>" + prompt);
|
|
|
+ if(StringUtils.isNotValidStr(prompt)) {
|
|
|
+ prompt = req.getObjSimpleFmtString("param.text");
|
|
|
+ if(StringUtils.isNotValidStr(prompt)) {
|
|
|
+ return JMgbusUtil.MgbusResult(401,"未知输入");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JedgeTalkSession s = findSession(req, prompt);
|
|
|
+
|
|
|
+ if(!s.isStream) { //非流式请求,目前只针对chatGPT
|
|
|
+ return JMgbusUtil.MgbusResult(200, makeRealGptChatCall(s, prompt));
|
|
|
+ }
|
|
|
+
|
|
|
+ String finalPrompt = prompt;
|
|
|
+ module.postThread(() -> {
|
|
|
+ if(s.knTalk) {
|
|
|
+ module.highLog(String.format("GPT Prompt>>%s", finalPrompt));
|
|
|
+ //根据各种类对象,完成对 提示词的多级划分。
|
|
|
+ knTalkLog(finalPrompt);
|
|
|
+ smartTaskContext.handleTask(s, finalPrompt);
|
|
|
+ } else {
|
|
|
+ knTalkLog(finalPrompt);
|
|
|
+ makeRealGptStreamCall(s, finalPrompt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QIData resp = JedgeLlmUtil.simpleOk();
|
|
|
+ resp.put("sid", s.sid);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @MgbusApi
|
|
|
+ public QIData registerDomain(QIData req) {
|
|
|
+ return smartTaskContext.getKnWorld().addNewDomain(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @MgbusApi
|
|
|
+ public QIData removeDomain(QIData req) {
|
|
|
+ return smartTaskContext.getKnWorld().removeDomain(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @MgbusApi
|
|
|
+ public QIData registerDmDomain(QIData req) {
|
|
|
+ return smartTaskContext.getDmWorld().addNewDmDomain(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @MgbusApi
|
|
|
+ public QIData removeDmDomain(QIData req) {
|
|
|
+ return smartTaskContext.getDmWorld().removeDmDomain(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @MgbusApi
|
|
|
+ public QIData registerDmObject(QIData req) {
|
|
|
+ return smartTaskContext.getDmWorld().addNewDmObjects(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @MgbusApi
|
|
|
+ public QIData removeDmObject(QIData req) {
|
|
|
+ return smartTaskContext.getDmWorld().removeDmObjects(req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @MgbusApi
|
|
|
+ public QIData LocalStream(QIData req) {
|
|
|
+ String sid = req.getString("sid");
|
|
|
+ String text = req.asJsonObject().getString("delta");
|
|
|
+ boolean isEnd = req.getBoolean("finished", false);
|
|
|
+ JedgeTalkSession session;
|
|
|
+ synchronized (sessions_) {
|
|
|
+ session = sessions_.get(sid);
|
|
|
+ }
|
|
|
+ if(session != null) {
|
|
|
+ if(session.printSingle) {
|
|
|
+// module.infoLog(String.format("Gpt>>%s(%s)", text, isEnd));
|
|
|
+ if (isEnd) {
|
|
|
+ session.buildLastHistory();
|
|
|
+ } else {
|
|
|
+ //text = text.trim();
|
|
|
+ if(StringUtils.isValidStr(text) &&
|
|
|
+ StringUtils.isValidStr(session.currentPrompt))
|
|
|
+ session.append2LastQA(text);
|
|
|
+ }
|
|
|
+ if (session.srcMod != null && session.cbUri != null) {
|
|
|
+ returnDirectGptMessage(session, text, isEnd);
|
|
|
+ } else
|
|
|
+ module.warnLog(String.format("Unknown mod to return, discussed : %s", text));
|
|
|
+ } else {
|
|
|
+ text += ("\n");
|
|
|
+ module.warnLog(String.format("Unhandled yet content : %s", text));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ module.warnLog(String.format("Dropping no session return content : %s", text));
|
|
|
+ }
|
|
|
+ return JMgbusUtil.MgbusResult(200,"ok");
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void postTextRetSourceMessage() {
|
|
|
+ active_ = true;
|
|
|
+ module.warnLog("Posting thread start ok.");
|
|
|
+ while(!quit_) {
|
|
|
+ try {
|
|
|
+ QIData msg = null;
|
|
|
+ {
|
|
|
+ if(!ret_msgs_.isEmpty()) {
|
|
|
+ msg = ret_msgs_.poll();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(msg!= null) {
|
|
|
+ String jeMod = msg.getString("~m");
|
|
|
+ String jeUriCb = msg.getString("~u");
|
|
|
+ postServiceMessage(jeMod, jeUriCb, msg);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ synchronized (ret_msgs_) {
|
|
|
+ SystemUtils.tryWaitforSingal(ret_msgs_, ival_mufis_text_message_gap_time_);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ module.warnLog("Posting thread end.");
|
|
|
+ active_ = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void clearTimeoutSession() {
|
|
|
+ module.warnLog("clearTimeoutSession thread start ok.");
|
|
|
+ while (!quit_) {
|
|
|
+ synchronized (sessions_) {
|
|
|
+ List<String> toDel = new ArrayList<>();
|
|
|
+ Set<String> keys = sessions_.keySet();
|
|
|
+ for(String k : keys) {
|
|
|
+ JedgeTalkSession s = sessions_.get(k);
|
|
|
+ s.ttl ++;
|
|
|
+ if(s.ttl > JedgeBotConst.ival_timeout_session_ ) { //会话3分钟没有任何返回,清空
|
|
|
+ toDel.add(k);
|
|
|
+ module.highLog(String.format("Timeout talk session %s from %s", k, s.srcMod));
|
|
|
+ // returnMgbusMessage(s.srcMod, s.cbUri, "会话超时", true, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(String key : toDel)
|
|
|
+ sessions_.remove(key);
|
|
|
+ }
|
|
|
+ SystemUtils.tryWaitforSingal(sessions_, 100);
|
|
|
+ }
|
|
|
+ module.warnLog("clearTimeoutSession thread end.");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnGptMessage(JedgeTalkSession s, String txtMessage) {
|
|
|
+ returnGptMessage(s, txtMessage, false, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnGptMessage(JedgeTalkSession s, String txtMessage, boolean isEndMsg) {
|
|
|
+ returnGptMessage(s, txtMessage, isEndMsg, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnDirectGptMessage(JedgeTalkSession s, String txtMessage) {
|
|
|
+ returnDirectGptMessage(s, txtMessage, false, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnDirectGptMessage(JedgeTalkSession s, String txtMessage, boolean isEndMsg) {
|
|
|
+ returnDirectGptMessage(s, txtMessage, isEndMsg, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnDirectGptMessage(JedgeTalkSession s, String txtMessage, boolean isEndMsg, boolean isErr) {
|
|
|
+ QIData msg = makeGptReturnMessage(txtMessage, isEndMsg, isErr);
|
|
|
+ postServiceMessage(s.srcMod, s.cbUri, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnGptMessage(JedgeTalkSession s, String txtMessage, boolean isEndMsg, boolean isErr) {
|
|
|
+ QIData msg = makeGptReturnMessage(txtMessage, isEndMsg, isErr);
|
|
|
+ msg.putString("~m", s.srcMod);
|
|
|
+ msg.putString("~u", s.cbUri);
|
|
|
+ synchronized (ret_msgs_) {
|
|
|
+ ret_msgs_.add(msg);
|
|
|
+ ret_msgs_.notify();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private QIData makeGptReturnMessage(String txtMessage, boolean isEndMsg, boolean isErr) {
|
|
|
+ QIData msg = new QData();
|
|
|
+ msg.putString("msg", txtMessage);
|
|
|
+ if(isEndMsg)
|
|
|
+ msg.putBoolean("end", isEndMsg);
|
|
|
+ if(isErr)
|
|
|
+ msg.putBoolean("err", isErr);
|
|
|
+ QIData d = msg.getData("~c");
|
|
|
+ if(d==null || d.isEmpty()) {
|
|
|
+ d = new QData();
|
|
|
+ }
|
|
|
+ d.put("nb",true);
|
|
|
+ msg.put("~c", d);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnGptMessageWithKey(JedgeTalkSession s, String key, String txtMessage,
|
|
|
+ boolean isEndMsg , boolean isErr ) {
|
|
|
+ module.exMarkLog(String.format("Corpus More >>%s",txtMessage));
|
|
|
+ QIData msg = makeGptReturnMessage(txtMessage, isEndMsg, isErr);
|
|
|
+ msg.setKey(key);
|
|
|
+ postServiceMessage(s.srcMod, s.cbUri, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void makeRealGptStreamCall(JedgeTalkSession s, String realPrompt) {
|
|
|
+ //发起gpt的stream请求
|
|
|
+ // chatGLM的聊天
|
|
|
+ // // "history":[["你好","你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。"]
|
|
|
+ QIData gr = new QData();
|
|
|
+ gr.put("history", s.history_);
|
|
|
+ gr.put("query", realPrompt);
|
|
|
+ gr.put("cb", "/gpt/LocalStream");//本地stream返回
|
|
|
+ gr.put("sid", s.sid);
|
|
|
+ QIData p = postServiceRequest(sval_module_llm, "/glm6b/stream", gr);
|
|
|
+ if (!JMgbusUtil.isMgbusResultOk(p)) {
|
|
|
+ returnGptMessage(s, "中转服务器请求Stream GPT数据失败", true, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public String makeRealGptChatCall(JedgeTalkSession s, String realPrompt) {
|
|
|
+ QIData gr = new QData();
|
|
|
+// gr.put("history", s.history_);
|
|
|
+ gr.put("query", realPrompt);
|
|
|
+ gr.put("cb", "/gpt/LocalStream");//本地stream返回
|
|
|
+ gr.put("sid", s.sid);
|
|
|
+ JMgbusUtil.setRequestTimeout(gr,60000);
|
|
|
+ QIData p = postServiceRequest(sval_module_llm, "/glm6b/chat", gr);
|
|
|
+ if (!JMgbusUtil.isMgbusResultOk(p)) {
|
|
|
+ returnDirectGptMessage(s, "中转服务器请求Chat GPT数据失败", true, true);
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ return p.getString("r");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public QIData getJsonResultForPrompt(JedgeTalkSession s, String realPrompt) {
|
|
|
+ String result = makeRealGptChatCall(s, realPrompt);
|
|
|
+ if(result!=null) {
|
|
|
+ result = result.trim();
|
|
|
+ result = JedgeLlmUtil.unescapeString(result);
|
|
|
+ QIData re = QData.fromString(result);
|
|
|
+ if(!re.isEmpty()) {
|
|
|
+ return re;
|
|
|
+ } else {
|
|
|
+ result = JedgeLlmUtil.unescapeString(result);
|
|
|
+ re = QData.fromString(result);
|
|
|
+ if(!re.isEmpty())
|
|
|
+ return re;
|
|
|
+ }
|
|
|
+ String newResult = StringUtils.getSubStrBetween(result, '{',1,'}',-1);
|
|
|
+ re = QData.fromString(newResult);
|
|
|
+ if(!re.isEmpty())
|
|
|
+ return re;
|
|
|
+ newResult = StringUtils.getSubStrBetween(result, '[',1,']',-1);
|
|
|
+ re = QData.fromString(newResult);
|
|
|
+ if(!re.isEmpty())
|
|
|
+ return re;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void knTalkLog(String realPrompt) {
|
|
|
+ knTalkLog(realPrompt, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void knTalkLog(String prompt, boolean succ) {
|
|
|
+ String log = "["+ TimeUtils.getNowShortStrWithMillis()+"] ["+(succ?"SUC":"FAL")+"]>>" + prompt;
|
|
|
+ log = log.replaceAll( "\n","");
|
|
|
+ FileUtils.appendLine(kn_talk_log_file, log+"\n", "UTF-8");
|
|
|
+ }
|
|
|
+
|
|
|
+ protected JedgeTalkSession findSession(QIData req, String prompt) {
|
|
|
+ String sid = String.valueOf(req.getInteger("sid"));
|
|
|
+ JedgeTalkSession s = sessions_.get(sid);
|
|
|
+ if(s!=null && req.getBoolean("c", false)) { //清理会话
|
|
|
+ sessions_.remove(sid);
|
|
|
+ s = null; //清空原会话,重新创建新的对话历史
|
|
|
+ }
|
|
|
+ //更新会话的部分状态
|
|
|
+ if(s!=null) {
|
|
|
+ if(req.containsKey("v") && req.get("v") instanceof Boolean) {
|
|
|
+ s.voiceTalk = req.getBoolean("v", false);
|
|
|
+ }
|
|
|
+ if(req.containsKey("k") && req.get("k") instanceof Boolean) {
|
|
|
+ s.knTalk = req.getBoolean("k", false);
|
|
|
+ }
|
|
|
+ if(req.containsKey("r") && req.get("r") instanceof String) {
|
|
|
+ String Domain = req.getString("r");
|
|
|
+ if(StringUtils.isValidStr(Domain))
|
|
|
+ s.domain = Domain;
|
|
|
+ }
|
|
|
+ if(req.containsKey("n") && req.get("n") instanceof Integer) {
|
|
|
+ s.rn = req.getInteger("n");
|
|
|
+ }
|
|
|
+ s.srcMod = JMgbusUtil.GetMgModSource(req);
|
|
|
+ // s.cbUri = req.getString("cb", "/spmp/PostGptStream");
|
|
|
+ } else {
|
|
|
+ //创建新的Session
|
|
|
+ boolean localGlm = req.getBoolean("l", true);
|
|
|
+ boolean knTalk = req.getBoolean("k", false);
|
|
|
+ int rn = req.getInteger("n", 6);
|
|
|
+ boolean printSingle = req.getBoolean("talkStream", true);
|
|
|
+ boolean isStream = req.getBoolean("stream", true); //默认是stream对话
|
|
|
+
|
|
|
+ String currentKnBase = null;
|
|
|
+ if((req.containsKey("knn"))) {
|
|
|
+ Object val = req.get("knn");
|
|
|
+ if(val instanceof String)
|
|
|
+ currentKnBase = (String) val;
|
|
|
+ else
|
|
|
+ currentKnBase = sval_default_app;
|
|
|
+ } else {
|
|
|
+ //提供一个默认的知识库对话窗口。
|
|
|
+ currentKnBase = sval_default_app;
|
|
|
+ }
|
|
|
+ s = new JedgeTalkSession(this, llmCtx);
|
|
|
+ s.currentKnBase = currentKnBase;
|
|
|
+ s.srcMod = JMgbusUtil.GetMgModSource(req);
|
|
|
+ s.cbUri = req.getString("cb", "/spmp/PostGptStream");
|
|
|
+ s.sid = 0x10000000 + NumberUtils.randomLong(0x6FFFFFFF);
|
|
|
+ sid = String.valueOf(s.sid);
|
|
|
+ s.printSingle = printSingle;
|
|
|
+
|
|
|
+ s.rn = rn;
|
|
|
+ s.localGlm = localGlm;
|
|
|
+ s.knTalk = knTalk;
|
|
|
+ s.voiceTalk = req.getBoolean("v", false);
|
|
|
+ s.isStream = isStream;
|
|
|
+
|
|
|
+ synchronized (sessions_) {
|
|
|
+ sessions_.put(sid, s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ s.currentPrompt = prompt;
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+
|
|
|
+ public JMgbusModual getModule() {
|
|
|
+ return module;
|
|
|
+ }
|
|
|
+
|
|
|
+ public JedgeSmartTaskContext getLLMContext() {
|
|
|
+ return smartTaskContext;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isActive() {
|
|
|
+ return active_;
|
|
|
+ }
|
|
|
+}
|