修改获取历史记录
This commit is contained in:
@@ -3,6 +3,7 @@ package com.peanut.common.utils;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.peanut.modules.common.entity.AiChatContent;
|
import com.peanut.modules.common.entity.AiChatContent;
|
||||||
import com.peanut.modules.common.service.AiChatContentService;
|
import com.peanut.modules.common.service.AiChatContentService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.http.Consts;
|
import org.apache.http.Consts;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
@@ -63,7 +64,18 @@ public class RagFlowApiUtil {
|
|||||||
//聊天助手下对话列表
|
//聊天助手下对话列表
|
||||||
public List<Map<String,Object>> getChats(Map<String,Object> params) throws Exception{
|
public List<Map<String,Object>> getChats(Map<String,Object> params) throws Exception{
|
||||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
String chatId = params.get("chatId").toString();
|
String id = params.get("chatId").toString();
|
||||||
|
List<String> chatIds = new ArrayList<>();
|
||||||
|
if (StringUtils.isEmpty(id)){
|
||||||
|
List<Map<String,Object>> assistants = getChatAssistants("");
|
||||||
|
for (Map<String, Object> map:assistants) {
|
||||||
|
chatIds.add(map.get("id").toString());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
chatIds.add(id);
|
||||||
|
}
|
||||||
|
List<Map<String,Object>> list = new ArrayList();
|
||||||
|
for (String chatId : chatIds){
|
||||||
String page = params.get("page").toString();
|
String page = params.get("page").toString();
|
||||||
String pageSize = params.get("pageSize").toString();
|
String pageSize = params.get("pageSize").toString();
|
||||||
String sessionId = params.get("sessionId").toString();
|
String sessionId = params.get("sessionId").toString();
|
||||||
@@ -79,7 +91,6 @@ public class RagFlowApiUtil {
|
|||||||
HttpEntity responseEntity = response.getEntity();
|
HttpEntity responseEntity = response.getEntity();
|
||||||
String responseString = EntityUtils.toString(responseEntity, Consts.UTF_8);
|
String responseString = EntityUtils.toString(responseEntity, Consts.UTF_8);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(responseString);
|
JSONObject jsonObject = JSONObject.parseObject(responseString);
|
||||||
List<Map<String,Object>> list = new ArrayList();
|
|
||||||
if ("0".equals(jsonObject.get("code").toString())){
|
if ("0".equals(jsonObject.get("code").toString())){
|
||||||
List l = jsonObject.getJSONArray("data");
|
List l = jsonObject.getJSONArray("data");
|
||||||
for (Object o : l) {
|
for (Object o : l) {
|
||||||
@@ -91,6 +102,7 @@ public class RagFlowApiUtil {
|
|||||||
list.add(map);
|
list.add(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user