Commit 854104e8 authored by 赵灿灿's avatar 赵灿灿

修改信息

parent 5886cdac
Pipeline #21110 passed with stages
in 3 minutes and 28 seconds
...@@ -294,7 +294,7 @@ public class LangChainController { ...@@ -294,7 +294,7 @@ public class LangChainController {
{ {
condition=",排除"+regionName; condition=",排除"+regionName;
} }
logger.info("开始调用1");
String urlAddr = "http://10.32.41.35:40517/scene_gateway/agent/6809d0895428476bb6789ad70c525c97"; String urlAddr = "http://10.32.41.35:40517/scene_gateway/agent/6809d0895428476bb6789ad70c525c97";
//String urlAddr = "http://10.32.41.35:40517/scene_gateway/agent/83f77143b09c461993dd9a7db403eb94"; //String urlAddr = "http://10.32.41.35:40517/scene_gateway/agent/83f77143b09c461993dd9a7db403eb94";
SseEmitter emitter = new SseEmitter(0L); SseEmitter emitter = new SseEmitter(0L);
...@@ -318,6 +318,7 @@ public class LangChainController { ...@@ -318,6 +318,7 @@ public class LangChainController {
chatService.insertMessage(conversations,messagesContent); chatService.insertMessage(conversations,messagesContent);
String params = JsonUtils.objectToJson(questionRequest); String params = JsonUtils.objectToJson(questionRequest);
StringBuffer content =new StringBuffer(); StringBuffer content =new StringBuffer();
StringBuffer lineCotent =new StringBuffer();
new Thread(() -> { new Thread(() -> {
HttpURLConnection connection = null; HttpURLConnection connection = null;
try { try {
...@@ -333,20 +334,16 @@ public class LangChainController { ...@@ -333,20 +334,16 @@ public class LangChainController {
// 设置超时为0,表示无限制 // 设置超时为0,表示无限制
connection.setConnectTimeout(0); connection.setConnectTimeout(0);
connection.setReadTimeout(0); connection.setReadTimeout(0);
logger.info(params);
try (OutputStream os = connection.getOutputStream()) { try (OutputStream os = connection.getOutputStream()) {
os.write(params.getBytes(StandardCharsets.UTF_8)); os.write(params.getBytes(StandardCharsets.UTF_8));
os.flush(); os.flush();
} }
logger.info("开始调用2");
// 检查响应码 // 检查响应码
int responseCode = connection.getResponseCode(); int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) { if (responseCode != HttpURLConnection.HTTP_OK) {
emitter.completeWithError(new RuntimeException("SSE 连接失败: " + responseCode)); emitter.completeWithError(new RuntimeException("SSE 连接失败: " + responseCode));
return; return;
} }
logger.info("开始调用3");
// 持续读取 SSE 数据流 // 持续读取 SSE 数据流
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line; String line;
...@@ -360,6 +357,7 @@ public class LangChainController { ...@@ -360,6 +357,7 @@ public class LangChainController {
emitter.send(SseEmitter.event().data("stop"),MediaType.parseMediaType("application/json; charset=UTF-8")); emitter.send(SseEmitter.event().data("stop"),MediaType.parseMediaType("application/json; charset=UTF-8"));
}else }else
{ {
lineCotent.append(data);
String sendData=data.replace("attachment#[]#attachment","").replace("source#[]#source","") String sendData=data.replace("attachment#[]#attachment","").replace("source#[]#source","")
.replace("<br />", "\n").replace("#","").replace("*",""); .replace("<br />", "\n").replace("#","").replace("*","");
emitter.send(SseEmitter.event().data(sendData), MediaType.parseMediaType("application/json; charset=UTF-8")); emitter.send(SseEmitter.event().data(sendData), MediaType.parseMediaType("application/json; charset=UTF-8"));
...@@ -371,6 +369,7 @@ public class LangChainController { ...@@ -371,6 +369,7 @@ public class LangChainController {
} }
} }
emitter.complete(); // 流结束 emitter.complete(); // 流结束
logger.info(lineCotent.toString());
} catch (Exception e) { } catch (Exception e) {
emitter.completeWithError(e); emitter.completeWithError(e);
logger.info(e.getMessage()); logger.info(e.getMessage());
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>推荐专家智能助手</title> <title>智能推荐专家</title>
<link rel="stylesheet" href="style/ai-chat.css"> <link rel="stylesheet" href="style/ai-chat.css">
<style> <style>
[v-cloak] { [v-cloak] {
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<!-- 左侧历史对话列表 --> <!-- 左侧历史对话列表 -->
<div class="sidebar"> <div class="sidebar">
<div class="sidebar-header"> <div class="sidebar-header">
<h1>推荐专家智能助手</h1> <h1>智能推荐专家</h1>
<!-- 添加主题切换按钮 --> <!-- 添加主题切换按钮 -->
<div id="theme-toggle" class="theme-toggle" title="切换主题" @click="toggleTheme"> <div id="theme-toggle" class="theme-toggle" title="切换主题" @click="toggleTheme">
<svg id="light-icon" viewBox="0 0 24 24" :style="{display: isDarkTheme ? 'block' : 'none'}"> <svg id="light-icon" viewBox="0 0 24 24" :style="{display: isDarkTheme ? 'block' : 'none'}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment