Commit dcc49878 authored by 赵灿灿's avatar 赵灿灿

增加外部专家智能体

parent 6aea9c72
Pipeline #21444 passed with stages
in 4 minutes and 27 seconds
...@@ -287,23 +287,24 @@ public class LangChainController { ...@@ -287,23 +287,24 @@ public class LangChainController {
@RequestParam String selectedExpert ,@RequestParam String selectedOrg) { @RequestParam String selectedExpert ,@RequestParam String selectedOrg) {
String condition=""; String condition="";
String regionName= chatService.getAuthRegionName(); String regionName= chatService.getAuthRegionName();
if("组织内".equals(selectedOrg)&&StringUtils.isNotEmpty(regionName)) if("内部专家".equals(selectedExpert)) {
{ if ("组织内".equals(selectedOrg) && StringUtils.isNotEmpty(regionName)) {
condition=",只能查找"+regionName; condition = ",只能查找" + regionName;
}else if("组织外".equals(selectedOrg)&&StringUtils.isNotEmpty(regionName)) } else if ("组织外".equals(selectedOrg) && StringUtils.isNotEmpty(regionName)) {
{ condition = ",排除" + regionName;
condition=",排除"+regionName; }
} }
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 = chatService.getUrl(selectedExpert);
//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);
QuestionRequest questionRequest=new QuestionRequest(); QuestionRequest questionRequest=new QuestionRequest();
questionRequest.setKeyword(chatMessage+condition); questionRequest.setKeyword(chatMessage+condition);
questionRequest.setRequestId(getRequestId()); questionRequest.setRequestId(getRequestId());
questionRequest.setDialogId(dialogId); questionRequest.setDialogId(dialogId);
Conversations conversations=chatService.saveConversations(dialogId,chatMessage,selectedExpert);
Conversations conversations=chatService.saveConversations(dialogId,chatMessage,"内部专家");
Messages messagesQusetion=new Messages(); Messages messagesQusetion=new Messages();
messagesQusetion.setRequestId(dialogId); messagesQusetion.setRequestId(dialogId);
messagesQusetion.setContent(chatMessage); messagesQusetion.setContent(chatMessage);
......
...@@ -235,6 +235,7 @@ public class ChatService { ...@@ -235,6 +235,7 @@ public class ChatService {
td.put("time",simpleDateFormat.format(conversations.getRecordTime())); td.put("time",simpleDateFormat.format(conversations.getRecordTime()));
td.put("active",false); td.put("active",false);
td.put("showMenu",false); td.put("showMenu",false);
td.put("selectedExpert",conversations.getAiType());
todayMapList.add(td); todayMapList.add(td);
}else if(conversations.getRecordTime().before(todayDate)&&conversations.getRecordTime().after(yesterday)) }else if(conversations.getRecordTime().before(todayDate)&&conversations.getRecordTime().after(yesterday))
{ {
...@@ -244,6 +245,7 @@ public class ChatService { ...@@ -244,6 +245,7 @@ public class ChatService {
yd.put("time",simpleDateFormat.format(conversations.getRecordTime())); yd.put("time",simpleDateFormat.format(conversations.getRecordTime()));
yd.put("active",false); yd.put("active",false);
yd.put("showMenu",false); yd.put("showMenu",false);
yd.put("selectedExpert",conversations.getAiType());
yesterdayMapList.add(yd); yesterdayMapList.add(yd);
}else }else
{ {
...@@ -253,6 +255,7 @@ public class ChatService { ...@@ -253,6 +255,7 @@ public class ChatService {
sd.put("time",simpleDateFormat.format(conversations.getRecordTime())); sd.put("time",simpleDateFormat.format(conversations.getRecordTime()));
sd.put("active",false); sd.put("active",false);
sd.put("showMenu",false); sd.put("showMenu",false);
sd.put("selectedExpert",conversations.getAiType());
sevendayMapList.add(sd); sevendayMapList.add(sd);
} }
} }
...@@ -335,4 +338,14 @@ public class ChatService { ...@@ -335,4 +338,14 @@ public class ChatService {
return regionName; return regionName;
} }
//获取调用地址
public String getUrl(String selectedExpert)
{
String url="http://10.32.41.35:40517/scene_gateway/agent/6809d0895428476bb6789ad70c525c97";
if("外部专家".equals(selectedExpert))
url="http://10.32.41.35:40517/scene_gateway/agent/b6d5bceecb5644cf953d9cc859bd36d3";
return url;
}
} }
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
:key="item.id" :key="item.id"
class="history-item" class="history-item"
:class="{ active: item.active }" :class="{ active: item.active }"
:data-id="item.id" @click="loadChatHistory(item.id)"> :data-id="item.id" @click="loadChatHistory(item)">
<div class="history-title" >{{ item.title }}</div> <div class="history-title" >{{ item.title }}</div>
<button class="delete-btn" @click.stop="deleteChat(item.id)"> <button class="delete-btn" @click.stop="deleteChat(item.id)">
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"> <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
...@@ -94,8 +94,9 @@ ...@@ -94,8 +94,9 @@
<div class="input-area-content"> <div class="input-area-content">
<div style="display: flex;align-items: center;justify-content: flex-start;"> <div style="display: flex;align-items: center;justify-content: flex-start;">
<div class="custom-select" v-click-outside="closeExpertDropdown"> <div class="custom-select" v-click-outside="closeExpertDropdown">
<div class="selected-option" @click.stop="toggleExpertDropdown"> <div class="selected-option" @click.stop="selectExpert('内部专家')"
<span>{{ selectedExpert }}</span> :class="{ 'active': selectedExpert === '内部专家' }">
<span>内部专家</span>
<!-- <svg class="dropdown-icon" :class="{ 'rotated': showExpertDropdown }" viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none">--> <!-- <svg class="dropdown-icon" :class="{ 'rotated': showExpertDropdown }" viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none">-->
<!-- <polyline points="6 9 12 15 18 9"></polyline>--> <!-- <polyline points="6 9 12 15 18 9"></polyline>-->
<!-- </svg>--> <!-- </svg>-->
...@@ -110,12 +111,13 @@ ...@@ -110,12 +111,13 @@
<!-- </div>--> <!-- </div>-->
</div> </div>
<div class="custom-select" v-click-outside="closeExpertDropdown"> <div class="custom-select" v-click-outside="closeExpertDropdown">
<div class="selected-option" @click.stop="toggleExpertDropdown"> <div class="selected-option" @click.stop="selectExpert('外部专家')"
:class="{ 'active': selectedExpert === '外部专家' }">
<span> 外部专家 </span> <span> 外部专家 </span>
</div> </div>
</div> </div>
<div class="custom-select" v-click-outside="closeOrgDropdown"> <div class="custom-select" v-click-outside="closeOrgDropdown" v-show="showOrgSelection">
<div class="selected-option" @click.stop="toggleOrgDropdown"> <div class="selected-option" @click.stop="toggleOrgDropdown" style="background-color: rgba(230, 220, 250, 0.5);color: #6633ff;">
<span>{{ selectedOrg }}</span> <span>{{ selectedOrg }}</span>
<svg class="dropdown-icon" :class="{ 'rotated': showOrgDropdown }" viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"> <svg class="dropdown-icon" :class="{ 'rotated': showOrgDropdown }" viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none">
<polyline points="6 9 12 15 18 9"></polyline> <polyline points="6 9 12 15 18 9"></polyline>
...@@ -157,4 +159,4 @@ ...@@ -157,4 +159,4 @@
<!-- 引入Vue相关JS --> <!-- 引入Vue相关JS -->
<script type="text/javascript" src="js/ai-chat-vue.js"></script> <script type="text/javascript" src="js/ai-chat-vue.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file \ No newline at end of file
...@@ -58,7 +58,8 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V ...@@ -58,7 +58,8 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V
// 消息列表 // 消息列表
messages: [ messages: [
// { role: 'ai', content: '您好!我是您的专家推荐助手,有什么可以帮助您的吗?' } // { role: 'ai', content: '您好!我是您的专家推荐助手,有什么可以帮助您的吗?' }
] ],
showOrgSelection: true
}, },
computed: { computed: {
isDarkTheme() { isDarkTheme() {
...@@ -208,6 +209,10 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V ...@@ -208,6 +209,10 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V
this.sendMessage(); this.sendMessage();
}, },
sendMessage() { sendMessage() {
if (!this.selectedExpert) {
this.showToast('请先选择专家类型(内部/外部专家)');
return;
}
const message = this.userInput.trim(); const message = this.userInput.trim();
if (!message) return; if (!message) return;
if (this.fistLoading) { if (this.fistLoading) {
...@@ -363,14 +368,18 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V ...@@ -363,14 +368,18 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V
// this.addChatToHistory('新对话', new Date()); // this.addChatToHistory('新对话', new Date());
}); });
this.fistLoading=true; this.fistLoading=true;
this.selectedExpert = '内部专家';
this.showOrgSelection = this.selectedExpert === '内部专家';
this.selectedOrg = '全部组织';
// 重置滚动位置并重新启动自动滚动 // 重置滚动位置并重新启动自动滚动
this.scrollOffset = 0; this.scrollOffset = 0;
this.startAutoScroll(); this.startAutoScroll();
}, },
loadChatHistory(chatId) { loadChatHistory(chat) {
var that=this var that=this
var chatId=chat.id;
// 关闭所有菜单 // 关闭所有菜单
this.historySections.forEach(section => { this.historySections.forEach(section => {
section.items.forEach(item => { section.items.forEach(item => {
...@@ -395,7 +404,10 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V ...@@ -395,7 +404,10 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V
this.stopAutoScroll(); this.stopAutoScroll();
} }
this.fistLoading = false; this.fistLoading = false;
this.selectedExpert = '内部专家';
this.showOrgSelection = this.selectedExpert === '内部专家';
this.selectedOrg = '全部组织';
//这里添加加载对应对话历史的逻辑 //这里添加加载对应对话历史的逻辑
//实际实现时可以调用API获取历史记录 //实际实现时可以调用API获取历史记录
$.ajax({ $.ajax({
...@@ -459,9 +471,18 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V ...@@ -459,9 +471,18 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V
}, },
selectExpert(expert) { selectExpert(expert) {
this.selectedExpert = expert; // this.selectedExpert = expert;
if (this.selectedExpert === expert) {
this.selectedExpert = '';
} else {
this.selectedExpert = expert;
}
this.showOrgSelection = expert === '内部专家';
this.selectedOrg = '全部组织';
// 立即关闭下拉框 // 立即关闭下拉框
this.showExpertDropdown = false; this.showExpertDropdown = false;
}, },
//组织内外选择相关方法 //组织内外选择相关方法
toggleOrgDropdown() { toggleOrgDropdown() {
...@@ -474,6 +495,17 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V ...@@ -474,6 +495,17 @@ require(['jquery', 'vue', 'utils','marked','markdown', 'global'], function ($, V
this.selectedOrg = org; this.selectedOrg = org;
// 立即关闭下拉框 // 立即关闭下拉框
this.showOrgDropdown = false; this.showOrgDropdown = false;
},
showToast(message) {
// 使用你项目中已有的提示组件,或创建一个简单的提示
const toast = document.createElement('div');
toast.className = 'expert-toast';
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.remove();
}, 3000);
} }
} }
}); });
......
...@@ -577,8 +577,10 @@ body { ...@@ -577,8 +577,10 @@ body {
justify-content: center; justify-content: center;
padding: 2px 5px; padding: 2px 5px;
border-radius: 8px; border-radius: 8px;
background-color: rgba(230, 220, 250, 0.5); /*background-color: rgba(230, 220, 250, 0.5);*/
color: #6633ff; background-color: #f5f6fa;
/*color: #6633ff;*/
color: #4c4c4c;
font-size: 14px; font-size: 14px;
transition: all 0.2s; transition: all 0.2s;
} }
...@@ -652,4 +654,22 @@ body { ...@@ -652,4 +654,22 @@ body {
.input-area-content { .input-area-content {
display: flex; display: flex;
align-items: center; align-items: center;
} }
\ No newline at end of file
.selected-option.active {
/* 选中样式 */
/*background-color: #f5f6fa;*/
background-color: rgba(230, 220, 250, 0.5);
/*color: #272933;*/
color: #6633ff;
}
.expert-toast {
position: fixed;
left: 50%;
top: 65%; /* 垂直居中 */
background-color: rgba(230, 220, 250, 0.5);
color: #6633ff;
padding: 10px 20px;
border-radius: 4px;
z-index: 1000;
}
\ No newline at end of file
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