feat: 优化输入框placeholder动态显示逻辑,支持基于知识库和网络搜索状态的个性化提示
This commit is contained in:
@@ -1,6 +1,23 @@
|
||||
<template>
|
||||
<div class="bot_msg">
|
||||
<div style="display: flex;flex-direction: column; gap:8px">
|
||||
<!-- 显示@的知识库和文件(非 Agent 模式下显示) -->
|
||||
<div v-if="!session.isAgentMode && mentionedItems && mentionedItems.length > 0" class="mentioned_items">
|
||||
<span
|
||||
v-for="item in mentionedItems"
|
||||
:key="item.id"
|
||||
class="mentioned_tag"
|
||||
:class="[
|
||||
item.type === 'kb' ? (item.kb_type === 'faq' ? 'faq-tag' : 'kb-tag') : 'file-tag'
|
||||
]"
|
||||
>
|
||||
<span class="tag_icon">
|
||||
<t-icon v-if="item.type === 'kb'" :name="item.kb_type === 'faq' ? 'chat-bubble-help' : 'folder'" />
|
||||
<t-icon v-else name="file" />
|
||||
</span>
|
||||
<span class="tag_name">{{ item.name }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<docInfo :session="session"></docInfo>
|
||||
<AgentStreamDisplay :session="session" :user-query="userQuery" v-if="session.isAgentMode"></AgentStreamDisplay>
|
||||
<deepThink :deepSession="session" v-if="session.showThink && !session.isAgentMode"></deepThink>
|
||||
@@ -75,6 +92,11 @@ const props = defineProps({
|
||||
required: false,
|
||||
default: ''
|
||||
},
|
||||
mentionedItems: {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: () => []
|
||||
},
|
||||
isFirstEnter: {
|
||||
type: Boolean,
|
||||
required: false
|
||||
@@ -249,6 +271,75 @@ onBeforeUnmount(() => {
|
||||
<style lang="less" scoped>
|
||||
@import '../../../components/css/markdown.less';
|
||||
|
||||
// @提及的知识库和文件标签样式
|
||||
.mentioned_items {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
justify-content: flex-start;
|
||||
max-width: 100%;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.mentioned_tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
max-width: 200px;
|
||||
cursor: default;
|
||||
transition: all 0.15s;
|
||||
background: var(--td-bg-color-secondarycontainer, #f3f3f3);
|
||||
border: 1px solid transparent;
|
||||
color: var(--td-text-color-primary, #333);
|
||||
|
||||
/* KB - Document (Greenish tint) */
|
||||
&.kb-tag {
|
||||
background: rgba(16, 185, 129, 0.08);
|
||||
color: #059669;
|
||||
|
||||
.tag_icon {
|
||||
color: #10b981;
|
||||
}
|
||||
}
|
||||
|
||||
/* KB - FAQ (Blueish tint) */
|
||||
&.faq-tag {
|
||||
background: rgba(0, 82, 217, 0.08);
|
||||
color: #0052d9;
|
||||
|
||||
.tag_icon {
|
||||
color: #0052d9;
|
||||
}
|
||||
}
|
||||
|
||||
/* File (Orange tint) */
|
||||
&.file-tag {
|
||||
background: rgba(237, 123, 47, 0.08);
|
||||
color: #e65100;
|
||||
|
||||
.tag_icon {
|
||||
color: #ed7b2f;
|
||||
}
|
||||
}
|
||||
|
||||
.tag_icon {
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.tag_name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: currentColor;
|
||||
}
|
||||
}
|
||||
|
||||
// 内容包装器 - 与 Agent 模式的 answer 样式一致
|
||||
.content-wrapper {
|
||||
background: #ffffff;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<usermsg :content="session.content" :mentioned_items="session.mentioned_items"></usermsg>
|
||||
</div>
|
||||
<div v-if="session.role == 'assistant'">
|
||||
<botmsg :content="session.content" :session="session" :user-query="getUserQuery(id)" @scroll-bottom="scrollToBottom"
|
||||
<botmsg :content="session.content" :session="session" :user-query="getUserQuery(id)" :mentioned-items="getUserMentionedItems(id)" @scroll-bottom="scrollToBottom"
|
||||
:isFirstEnter="isFirstEnter"></botmsg>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,7 +61,7 @@ const useSettingsStoreInstance = useSettingsStore();
|
||||
const uiStore = useUIStore();
|
||||
const { navigateToKnowledgeBaseList } = useKnowledgeBaseCreationNavigation();
|
||||
const { t } = useI18n();
|
||||
const { menuArr, isFirstSession, firstQuery } = storeToRefs(usemenuStore);
|
||||
const { menuArr, isFirstSession, firstQuery, firstMentionedItems } = storeToRefs(usemenuStore);
|
||||
const { output, onChunk, isStreaming, isLoading, error, startStream, stopStream } = useStream();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -93,6 +93,18 @@ const getUserQuery = (index) => {
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
// 获取用户消息的 mentioned_items(用于 bot 消息显示)
|
||||
const getUserMentionedItems = (index) => {
|
||||
if (index <= 0) {
|
||||
return [];
|
||||
}
|
||||
const previous = messagesList[index - 1];
|
||||
if (previous && previous.role === 'user') {
|
||||
return previous.mentioned_items || [];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
watch([() => route.params], (newvalue) => {
|
||||
isFirstEnter.value = true;
|
||||
if (newvalue[0].chatid) {
|
||||
@@ -790,7 +802,7 @@ onMounted(async () => {
|
||||
checkmenuTitle(session_id.value)
|
||||
if (firstQuery.value) {
|
||||
scrollLock.value = true;
|
||||
sendMsg(firstQuery.value);
|
||||
sendMsg(firstQuery.value, '', firstMentionedItems.value || []);
|
||||
usemenuStore.changeFirstQuery('');
|
||||
} else {
|
||||
scrollLock.value = false;
|
||||
|
||||
@@ -39,11 +39,11 @@ const uiStore = useUIStore();
|
||||
const { t } = useI18n();
|
||||
const { navigateToKnowledgeBaseList } = useKnowledgeBaseCreationNavigation();
|
||||
|
||||
const sendMsg = (value: string) => {
|
||||
createNewSession(value);
|
||||
const sendMsg = (value: string, modelId: string, mentionedItems: any[]) => {
|
||||
createNewSession(value, mentionedItems);
|
||||
}
|
||||
|
||||
async function createNewSession(value: string) {
|
||||
async function createNewSession(value: string, mentionedItems: any[] = []) {
|
||||
const selectedKbs = settingsStore.settings.selectedKnowledgeBases || [];
|
||||
const selectedFiles = settingsStore.settings.selectedFiles || [];
|
||||
|
||||
@@ -63,7 +63,7 @@ async function createNewSession(value: string) {
|
||||
try {
|
||||
const res = await createSessions(sessionData);
|
||||
if (res.data && res.data.id) {
|
||||
await navigateToSession(res.data.id, value);
|
||||
await navigateToSession(res.data.id, value, mentionedItems);
|
||||
} else {
|
||||
console.error('[createChat] Failed to create session');
|
||||
MessagePlugin.error(t('createChat.messages.createFailed'));
|
||||
@@ -74,7 +74,7 @@ async function createNewSession(value: string) {
|
||||
}
|
||||
}
|
||||
|
||||
const navigateToSession = async (sessionId: string, value: string) => {
|
||||
const navigateToSession = async (sessionId: string, value: string, mentionedItems: any[]) => {
|
||||
const now = new Date().toISOString();
|
||||
let obj = {
|
||||
title: t('createChat.newSessionTitle'),
|
||||
@@ -87,7 +87,7 @@ const navigateToSession = async (sessionId: string, value: string) => {
|
||||
};
|
||||
usemenuStore.updataMenuChildren(obj);
|
||||
usemenuStore.changeIsFirstSession(true);
|
||||
usemenuStore.changeFirstQuery(value);
|
||||
usemenuStore.changeFirstQuery(value, mentionedItems);
|
||||
router.push(`/platform/chat/${sessionId}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user