| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <template>
- <div class="dialog-item-container">
- <DialogQuestion v-if="item_type === 'q'" :question="questionInfo" @select="handleSelectChat" />
- <DialogAnswer
- v-if="item_type === 'a'"
- :answer="answerInfo"
- @stop="handleStopChat"
- @retry="handleRetryChat"
- @select="handleSelectChat"
- />
- </div>
- </template>
- <script setup>
- import { ref, computed } from 'vue';
- import DialogQuestion from './dialog-item/DialogQuestion.vue';
- import DialogAnswer from './dialog-item/DialogAnswer.vue';
- const props = defineProps({
- dialog: Object
- });
- const emit = defineEmits(['stop', 'retry', 'select']);
- /**
- * 当前这一项的类别,有两个值
- * q 提问
- * a 智能体的回答
- */
- const item_type = computed(() => {
- const item = props.dialog;
- return item.client_custom_item_type;
- });
- /**
- * 客户端提问数据
- */
- const questionInfo = computed(() => {
- return {
- content: props.dialog.question
- };
- });
- /**
- * 智能体回答的答案
- */
- const answerInfo = computed(() => {
- const chat_info = props.dialog;
- const obj = {};
- // 智能体回答的内容
- if (chat_info.answer) {
- obj.content = chat_info.answer;
- }
- /**
- * 状态值信息
- * 0 加载中
- * 1 正在对话
- * 2 已结束
- */
- obj.client_custom_chat_status = chat_info.client_custom_chat_status;
- return obj;
- });
- /**
- * 停止答案的生成
- */
- const handleStopChat = () => {
- emit('stop');
- };
- const handleRetryChat = () => {
- emit('retry');
- };
- const handleSelectChat = () => {
- emit('select');
- };
- </script>
- <style lang="css" scoped>
- .dialog-item-container {
- margin-top: 10px;
- margin-bottom: 10px;
- }
- </style>
|