-
@@ -100,8 +89,6 @@ import { ref, computed, nextTick } from 'vue'
import http from '@/io/request'
import { v4 as uuidv4 } from 'uuid'
import { useAiChat } from '@/stores/aichat'
-import VueDraggableResizable from 'vue-draggable-resizable/src/components/vue-draggable-resizable.vue'
-import 'vue-draggable-resizable/dist/VueDraggableResizable.css'
const props = defineProps({
top: {
type: String,
@@ -183,7 +170,7 @@ const changeOption = (index) => {
autoMessage()
}
const currentOption = computed(() => {
- if(optionIndex.value === null) return null
+ if (optionIndex.value === null) return null
return options[optionIndex.value] ?? null
})
@@ -193,11 +180,13 @@ const dataSources = computed(() => {
const prompt = ref('')
-const autoMessage = async ()=>{
-
- const message = replacePlaceholder(currentOption.value.value, truncateRichText(props.content, 4000))
+const autoMessage = async () => {
+ const message = replacePlaceholder(
+ currentOption.value.value,
+ truncateRichText(props.content, 4000)
+ )
- if(loading.value) return
+ if (loading.value) return
contentLoading.value = true
loading.value = true
try {
@@ -233,26 +222,24 @@ const autoMessage = async ()=>{
}
const errorMessage = error?.errmsg ?? '好像出错了,请稍后再试。'
contenText.value = errorMessage
- }finally{
+ } finally {
contentLoading.value = false
loading.value = false
}
}
-
-
function truncateRichText(richText, maxLength) {
// 去除标签
- const plainText = richText.replace(/<[^>]+>/g, '');
+ const plainText = richText.replace(/<[^>]+>/g, '')
// 截取最多 maxLength 个字符
- const truncatedText = plainText.substring(0, maxLength);
+ const truncatedText = plainText.substring(0, maxLength)
- return truncatedText;
+ return truncatedText
}
function replacePlaceholder(originalText, replacement) {
- return originalText.replace('{0}', replacement);
+ return originalText.replace('{0}', replacement)
}
const sendMessage = async () => {
@@ -290,8 +277,6 @@ const sendMessage = async () => {
const { responseText } = xhr
if (xhr.status == 200) {
const arr = parseEventMessages(responseText)
- const { conversation_id, message_id } = arr[0]
-
const msg = arr.reduce((acc, item) => {
return acc + item.text
}, '')
@@ -370,15 +355,26 @@ function scrollToBottomIfAtBottom() {
}
-