feat: 新增对话重新生成功能(关联 Issue #104)
This commit is contained in:
parent
2207484eae
commit
c25278cec3
@ -122,7 +122,7 @@
|
||||
你停止生成了本次回答
|
||||
<span class="retry-link" @click="retryStoppedMessage(message)">重新编辑问题</span>
|
||||
</div>
|
||||
<RefsComponent v-if="message.role=='received' && message.status=='finished'" :message="message" />
|
||||
<RefsComponent v-if="message.role=='received' && message.status=='finished'" :message="message" :conv="conv" @regenerateMessage="regenerateMessage" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
@ -220,7 +220,9 @@ import {
|
||||
BulbOutlined,
|
||||
CaretRightOutlined,
|
||||
DeploymentUnitOutlined,
|
||||
StopOutlined
|
||||
StopOutlined,
|
||||
ReloadOutlined,
|
||||
CopyOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { onClickOutside } from '@vueuse/core'
|
||||
import { Marked } from 'marked';
|
||||
@ -702,6 +704,24 @@ const selectModel = (provider, name) => {
|
||||
message.success(`已切换到模型: ${provider}/${name}`)
|
||||
|
||||
}
|
||||
|
||||
// 添加重新生成方法
|
||||
const regenerateMessage = (message) => {
|
||||
// 找到用户的原始问题
|
||||
const messageIndex = conv.value.messages.findIndex(msg => msg.id === message.id)
|
||||
if (messageIndex > 0) {
|
||||
const userMessage = conv.value.messages[messageIndex - 1]
|
||||
if (userMessage && userMessage.role === 'sent') {
|
||||
// 删除当前AI回复
|
||||
conv.value.messages = conv.value.messages.slice(0, messageIndex)
|
||||
// 重新生成回答
|
||||
appendAiMessage("", null)
|
||||
const cur_res_id = conv.value.messages[conv.value.messages.length - 1].id
|
||||
isStreaming.value = true
|
||||
fetchChatResponse(userMessage.text, cur_res_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@ -950,6 +970,9 @@ const selectModel = (provider, name) => {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
text-align: justify;
|
||||
position: relative;
|
||||
|
||||
|
||||
}
|
||||
|
||||
p.message-text {
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
<!-- <span class="item btn" @click="dislikeThisResponse(msg)"><DislikeOutlined /></span> -->
|
||||
<span class="item"><BulbOutlined /> {{ msg.meta.server_model_name }}</span>
|
||||
<span class="item btn" @click="copyText(msg.text)"><CopyOutlined /></span>
|
||||
<span class="item btn" @click="regenerateMessage(msg)"><ReloadOutlined /></span>
|
||||
<span
|
||||
class="item btn"
|
||||
@click="openSubGraph(msg)"
|
||||
@ -112,15 +113,20 @@ import {
|
||||
DeploymentUnitOutlined,
|
||||
BulbOutlined,
|
||||
FileOutlined,
|
||||
ClockCircleOutlined
|
||||
ClockCircleOutlined,
|
||||
ReloadOutlined,
|
||||
} from '@ant-design/icons-vue'
|
||||
import GraphContainer from './GraphContainer.vue' // 导入 GraphContainer 组件
|
||||
|
||||
|
||||
const emit = defineEmits(['regenerateMessage']);
|
||||
const props = defineProps({
|
||||
message: Object,
|
||||
conv: Object,
|
||||
})
|
||||
|
||||
const msg = ref(props.message)
|
||||
const conv = ref(props.conv)
|
||||
|
||||
// 使用 useClipboard 实现复制功能
|
||||
const { copy, isSupported } = useClipboard()
|
||||
@ -210,6 +216,11 @@ const formatDate = (timestamp) => {
|
||||
const getPercent = (value) => {
|
||||
return parseFloat((value * 100).toFixed(2))
|
||||
}
|
||||
|
||||
// 添加重新生成方法
|
||||
const regenerateMessage = (message) => {
|
||||
emit('regenerateMessage', message)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user