|
@@ -5,8 +5,7 @@ import avator from '@/public/icon/32.png'
|
|
|
import moment from 'moment'
|
|
|
import {
|
|
|
getFormKey,
|
|
|
- buildObjPrompt,
|
|
|
- getFileSummaryPrompt,
|
|
|
+ hepl,
|
|
|
formatMessage,
|
|
|
sendMessage
|
|
|
} from '../utils/ai-service.js'
|
|
@@ -22,7 +21,6 @@ export function useMsg(scrollbar?: any) {
|
|
|
const sendLoading = ref(false)
|
|
|
const pageInfo = ref<any>({})
|
|
|
const type = ref('')
|
|
|
- const formMap = ref([])
|
|
|
// 获取父组件提供的 Hook 实例
|
|
|
const { useStore } = inject('indexedDBHook') as any
|
|
|
|
|
@@ -145,6 +143,7 @@ export function useMsg(scrollbar?: any) {
|
|
|
return res
|
|
|
}
|
|
|
const res = await fetchDataAndProcess(msg, obj)
|
|
|
+ type.value = ''
|
|
|
sendLoading.value = false
|
|
|
if (res.status === 'ok') {
|
|
|
await new Promise((res: any) =>
|
|
@@ -167,20 +166,20 @@ export function useMsg(scrollbar?: any) {
|
|
|
res()
|
|
|
}, 2000)
|
|
|
)
|
|
|
- // const res = await hepl({
|
|
|
- // input_data: input,
|
|
|
- // body: pageInfo.content.mainContent
|
|
|
- // })
|
|
|
- const res: any = await new Promise((resolve, reject) => {
|
|
|
- setTimeout(() => {
|
|
|
- resolve({
|
|
|
- data:
|
|
|
- pageInfo.title === '智能招采'
|
|
|
- ? mockData[indexTemp.value]
|
|
|
- : mockData2[indexTemp.value]
|
|
|
- })
|
|
|
- }, 1000)
|
|
|
+ const res = await hepl({
|
|
|
+ input_data: input,
|
|
|
+ body: pageInfo.content.mainContent
|
|
|
})
|
|
|
+ // const res: any = await new Promise((resolve, reject) => {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // resolve({
|
|
|
+ // data:
|
|
|
+ // pageInfo.title === '智能招采'
|
|
|
+ // ? mockData[indexTemp.value]
|
|
|
+ // : mockData2[indexTemp.value]
|
|
|
+ // })
|
|
|
+ // }, 1000)
|
|
|
+ // })
|
|
|
if (!res.data.tag || res.data.tag === 'undefined') {
|
|
|
ElMessage({
|
|
|
message: '未找到标签,请重试',
|
|
@@ -206,6 +205,8 @@ export function useMsg(scrollbar?: any) {
|
|
|
if (status === 'error') {
|
|
|
obj.content = data
|
|
|
resolve({ data, status })
|
|
|
+ console.log(222);
|
|
|
+
|
|
|
}
|
|
|
if (res.data.next === '是') {
|
|
|
const arr = str.split(',')
|
|
@@ -215,23 +216,6 @@ export function useMsg(scrollbar?: any) {
|
|
|
const res = await fetchDataAndProcess(str, obj)
|
|
|
resolve(res)
|
|
|
} else resolve({ status: 'ok' })
|
|
|
- // else {
|
|
|
- // await new Promise((resolve, reject) => {
|
|
|
- // setTimeout(() => {
|
|
|
- // resolve(1)
|
|
|
- // }, 2000)
|
|
|
- // })
|
|
|
- // obj.content = `请选择表单`
|
|
|
- // ElMessage({
|
|
|
- // message: '请选择表单',
|
|
|
- // type: 'success',
|
|
|
- // duration: 4 * 1000,
|
|
|
- // grouping: true
|
|
|
- // })
|
|
|
- // chrome.runtime.sendMessage({
|
|
|
- // type: 'FROM_SIDE_PANEL_TO_GET_PAGE_FORM'
|
|
|
- // })
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
)
|
|
@@ -296,8 +280,6 @@ export function useMsg(scrollbar?: any) {
|
|
|
}
|
|
|
scrollbar.value?.setScrollTop(99999)
|
|
|
}
|
|
|
- console.log(obj.rawContent);
|
|
|
-
|
|
|
//添加到存储历史
|
|
|
useStore(msgUuid.value).add({ ...obj })
|
|
|
// 处理最终内容
|
|
@@ -305,20 +287,6 @@ export function useMsg(scrollbar?: any) {
|
|
|
nextTick(() => {
|
|
|
scrollbar.value?.setScrollTop(99999)
|
|
|
})
|
|
|
- if (type.value === '2') {
|
|
|
- const arr = JSON.parse(obj.rawContent.split('json')[1].split('```')[0])
|
|
|
- const newArr = arr.map(obj => {
|
|
|
- return `| ${[
|
|
|
- `“findBy”: \` "label",`,
|
|
|
- `"findByValue" \` “${obj.findByValue}”,`,
|
|
|
- `"数据来源字段" \` “${obj.excelColumn}”,`,
|
|
|
- `"表单项" \` “${obj.item}"`
|
|
|
- ].join(' ')} |`;
|
|
|
- }).join('\n');
|
|
|
- obj.content = formatMessage('```json' + JSON.stringify(newArr) + '```')
|
|
|
- console.log(formatMessage('```json' + JSON.stringify(newArr) + '```'));
|
|
|
-
|
|
|
- }
|
|
|
return obj.rawContent
|
|
|
}
|
|
|
|
|
@@ -367,7 +335,6 @@ export function useMsg(scrollbar?: any) {
|
|
|
indexTemp,
|
|
|
taklToHtml,
|
|
|
sendLoading,
|
|
|
- formMap,
|
|
|
type,
|
|
|
fetchRes,
|
|
|
streamRes,
|