Merge branch 'main' of http://18.167.251.121:10003/aidlab/FiDA_Front
This commit is contained in:
@@ -29,7 +29,7 @@ export const createProject = (data: CreateProjectParamsType): Promise<any> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目信息
|
* 获取项目信息和会话历史
|
||||||
* @param data 获取项目信息参数
|
* @param data 获取项目信息参数
|
||||||
* @param data.id 项目id
|
* @param data.id 项目id
|
||||||
* @returns 获取项目信息
|
* @returns 获取项目信息
|
||||||
|
|||||||
@@ -1,2 +1,9 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export const uploadImage = (data: FormData) => {
|
||||||
|
return request({
|
||||||
|
url: '/api/file/upload',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const versionTree = (data) => {
|
|||||||
* @param data 获取节点缩略信息的参数
|
* @param data 获取节点缩略信息的参数
|
||||||
* @param data.projectId 项目id
|
* @param data.projectId 项目id
|
||||||
* @param data.id 节点id
|
* @param data.id 节点id
|
||||||
* @returns 获取节点缩略信息
|
* @returns 回溯该节点之前的会话列表
|
||||||
*/
|
*/
|
||||||
export const getNodeAncestors = (data) => {
|
export const getNodeAncestors = (data) => {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
import Input from '../../components/Input.vue'
|
import Input from '../../components/Input.vue'
|
||||||
import { fetchAgentReply } from '@/api/agent'
|
import { fetchAgentReply } from '@/api/agent'
|
||||||
import type { AgentParamsType } from '@/api/agent'
|
import type { AgentParamsType } from '@/api/agent'
|
||||||
import { useUserInfoStore, useProjectStore } from '@/stores'
|
import { useUserInfoStore, useProjectStore, } from '@/stores'
|
||||||
import { useAgentStore } from '@/stores/agent'
|
import { useAgentStore } from '@/stores/agent'
|
||||||
|
|
||||||
const userStore = useUserInfoStore()
|
const userStore = useUserInfoStore()
|
||||||
@@ -67,8 +67,6 @@
|
|||||||
watch(
|
watch(
|
||||||
sketchList,
|
sketchList,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
console.log('添加图片链接--------')
|
|
||||||
|
|
||||||
emits('update:sketchList', newVal)
|
emits('update:sketchList', newVal)
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
@@ -120,7 +118,7 @@
|
|||||||
},
|
},
|
||||||
skipUserMessage = false
|
skipUserMessage = false
|
||||||
) => {
|
) => {
|
||||||
console.log('Message sent:', message)
|
// console.log('Message sent:', message)
|
||||||
isPaused.value = false
|
isPaused.value = false
|
||||||
isGenerating.value = true
|
isGenerating.value = true
|
||||||
params.message = message.text
|
params.message = message.text
|
||||||
@@ -213,7 +211,7 @@
|
|||||||
while (flag) {
|
while (flag) {
|
||||||
const { done, value } = await reader.read()
|
const { done, value } = await reader.read()
|
||||||
if (done) {
|
if (done) {
|
||||||
console.log('传输结束 end---', contentBody)
|
// console.log('传输结束 end---', contentBody)
|
||||||
aiMessage.streaming = false
|
aiMessage.streaming = false
|
||||||
aiMessage.loading = false
|
aiMessage.loading = false
|
||||||
isGenerating.value = false
|
isGenerating.value = false
|
||||||
@@ -254,6 +252,7 @@
|
|||||||
// console.log('dataLInes', dataLines)
|
// console.log('dataLInes', dataLines)
|
||||||
if (isNodeIdEvent) {
|
if (isNodeIdEvent) {
|
||||||
params.versionID = dataLines[0]
|
params.versionID = dataLines[0]
|
||||||
|
projectStore.setProject({nodeId:dataLines[0]})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataLines.length === 0) continue
|
if (dataLines.length === 0) continue
|
||||||
@@ -361,8 +360,47 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setChatInfo = (data) => {
|
||||||
|
// messageList.value = list
|
||||||
|
const { ancestors, current } = data
|
||||||
|
const imgList = []
|
||||||
|
const ancestorsList = []
|
||||||
|
if (ancestors) {
|
||||||
|
ancestors.forEach((item) => {
|
||||||
|
const list = item.dialogue.map((el, index) => {
|
||||||
|
if (el.image_url) {
|
||||||
|
imgList.push(el.image_url)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...el,
|
||||||
|
text: el.content,
|
||||||
|
isUser: el.role === 'user',
|
||||||
|
id: index + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ancestorsList.push(...list)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const currentList = current.dialogue.map((item, index) => {
|
||||||
|
if (item.image_url) {
|
||||||
|
imgList.push(item.image_url)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
text: item.content,
|
||||||
|
isUser: item.role === 'user',
|
||||||
|
id: index + 1 + ancestorsList.length
|
||||||
|
}
|
||||||
|
})
|
||||||
|
messageList.value = [...ancestorsList, ...currentList]
|
||||||
|
params.versionID = current.id
|
||||||
|
sketchList.value = imgList
|
||||||
|
// console.log('messagelist:', messageList.value)
|
||||||
|
// debugger
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
inputRef
|
setChatInfo
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -221,5 +221,8 @@
|
|||||||
ul {
|
ul {
|
||||||
list-style-position: inside;
|
list-style-position: inside;
|
||||||
}
|
}
|
||||||
|
code {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const projectStore = useProjectStore()
|
|||||||
let oldProjectId:any = ''
|
let oldProjectId:any = ''
|
||||||
watch(()=>props.versionTreeData?.drawer, (newVal, oldVal) => {
|
watch(()=>props.versionTreeData?.drawer, (newVal, oldVal) => {
|
||||||
console.log(newVal,oldProjectId,projectStore.state.id)
|
console.log(newVal,oldProjectId,projectStore.state.id)
|
||||||
if(newVal && oldProjectId !== projectStore.state.id && projectStore.state.id){
|
if(newVal || (oldProjectId !== projectStore.state.id && projectStore.state.id)){
|
||||||
getVersionTree()
|
getVersionTree()
|
||||||
oldProjectId = JSON.parse(JSON.stringify(projectStore.state.id))
|
oldProjectId = JSON.parse(JSON.stringify(projectStore.state.id))
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,7 @@ const getVersionTree = ()=>{
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
if(!res)return
|
if(!res)return
|
||||||
setVersionsList([res])
|
setVersionsList([res])
|
||||||
|
treeKey.value++
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ const initialize = ()=>{
|
|||||||
|
|
||||||
const setSelectItem = (item)=>{
|
const setSelectItem = (item)=>{
|
||||||
if(!item.versionId)return
|
if(!item.versionId)return
|
||||||
console.log(item)
|
|
||||||
projectStore.setProject({nodeId: item.id})
|
projectStore.setProject({nodeId: item.id})
|
||||||
emit('update:selectItem', {...item})
|
emit('update:selectItem', {...item})
|
||||||
emit('selectNode')
|
emit('selectNode')
|
||||||
@@ -97,10 +96,6 @@ watch(()=>treeStateTime.value,(newVal,oldVal)=>{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(()=>props.selectItem,(newVal,oldVal)=>{
|
|
||||||
// scrollToActive()
|
|
||||||
},{immediate: true})
|
|
||||||
|
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
initialize()
|
initialize()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ defineExpose({push})
|
|||||||
</template> -->
|
</template> -->
|
||||||
</VueFlow>
|
</VueFlow>
|
||||||
<div class="btnBox">
|
<div class="btnBox">
|
||||||
<div class="item" v-if="selectItem.url" @click="versionRestore">
|
<div class="item" :class="{'active':!selectItem.url}" @click="versionRestore">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<SvgIcon name="versionRestore" size="12" />
|
<SvgIcon name="versionRestore" size="12" />
|
||||||
</div>
|
</div>
|
||||||
@@ -225,6 +225,11 @@ defineExpose({push})
|
|||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
pointer-events: none;
|
||||||
|
&.active{
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
&:hover{
|
&:hover{
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const props = defineProps<{
|
|||||||
<!-- <div>{{ props.data.id }}</div> -->
|
<!-- <div>{{ props.data.id }}</div> -->
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<!-- {{ props.data.url }} -->
|
<!-- {{ props.data.url }} -->
|
||||||
<img :src="props.data?.url" />
|
<img v-if="props.data?.url" :src="props.data?.url" />
|
||||||
<div class="mask"></div>
|
<div class="mask"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
ref="VersionTreeIndexRef"
|
ref="VersionTreeIndexRef"
|
||||||
v-model:versionTreeData="versionTreeData"
|
v-model:versionTreeData="versionTreeData"
|
||||||
@restore="handleRestore"
|
@restore="handleRestore"
|
||||||
|
@selectNode="handleSelectNode"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -24,13 +25,14 @@
|
|||||||
import VersionTreeIndex from './components/versionTree/index.vue'
|
import VersionTreeIndex from './components/versionTree/index.vue'
|
||||||
import { useProjectStore } from '@/stores'
|
import { useProjectStore } from '@/stores'
|
||||||
import { getProjectInfo } from '@/api/agent'
|
import { getProjectInfo } from '@/api/agent'
|
||||||
|
import { clearNodeChat, getNodeAncestors } from '@/api/versitonTree'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const projectStore = useProjectStore()
|
||||||
|
|
||||||
const agentTitle = ref('Retro Sofa Sketch')
|
const agentTitle = ref('Retro Sofa Sketch')
|
||||||
const previewType = ref<'sketch' | 'report'>('sketch')
|
const previewType = ref<'sketch' | 'report'>('sketch')
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
const VersionTreeIndexRef = ref()
|
const VersionTreeIndexRef = ref()
|
||||||
const agentRef = ref()
|
const agentRef = ref()
|
||||||
const sketchList = ref([])
|
const sketchList = ref([])
|
||||||
@@ -45,39 +47,48 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
const handleRestore = () => {
|
const handleRestore = () => {
|
||||||
console.log('-----------', agentRef.value.inputRef.addReportTag)
|
// agentRef.value?.inputRef?.addReportTag('Restore')
|
||||||
|
clearNodeChat({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
|
||||||
|
(res) => {}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const handleSelectNode = () => {
|
||||||
|
console.log('handleSelectNode')
|
||||||
|
getNodeAncestors({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
|
||||||
|
(res) => {
|
||||||
|
console.log('res', res)
|
||||||
|
agentRef.value.setChatInfo(res)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
agentRef.value?.inputRef?.addReportTag('Restore')
|
const handleGetProjectInfoAndHistory = () => {
|
||||||
|
getProjectInfo({ id: route.params.id }).then((res) => {
|
||||||
|
if(res?.conversation)agentRef.value.setChatInfo(res.conversation)
|
||||||
|
let data = res?.project || res
|
||||||
|
if(data?.latestNodeId)data.nodeId = data.latestNodeId
|
||||||
|
projectStore.setProject({
|
||||||
|
...data,
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const proJectId = computed(() => route.params.id)
|
const proJectId = computed(() => route.params.id)
|
||||||
const projectStore = useProjectStore()
|
|
||||||
watch(
|
watch(
|
||||||
() => proJectId.value,
|
() => proJectId.value,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
|
projectStore.clearProject()
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
projectStore.clearProject()
|
handleGetProjectInfoAndHistory()
|
||||||
projectStore.setId(newVal)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
watch(
|
|
||||||
() => projectStore.state.id,
|
|
||||||
(newVal, oldVal) => {
|
|
||||||
if (newVal) {
|
|
||||||
getProjectInfo({ id: newVal }).then((res) => {
|
|
||||||
projectStore.setProject(res.project)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (projectStore.state.id) {
|
projectStore.clearProject()
|
||||||
getProjectInfo({ id: projectStore.state.id }).then((res) => {
|
if (proJectId.value) {
|
||||||
projectStore.setProject(res.project)
|
handleGetProjectInfoAndHistory()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -188,6 +188,7 @@
|
|||||||
import restoreCloseIcon from '@/assets/images/tag-close.png'
|
import restoreCloseIcon from '@/assets/images/tag-close.png'
|
||||||
import { createProject } from '@/api/agent'
|
import { createProject } from '@/api/agent'
|
||||||
import { getStyleImage } from './style'
|
import { getStyleImage } from './style'
|
||||||
|
import { uploadImage } from '@/api/upload'
|
||||||
// import Tag from './Tag.vue'
|
// import Tag from './Tag.vue'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -221,18 +222,26 @@
|
|||||||
// 处理文件选择
|
// 处理文件选择
|
||||||
const handleFileChange = (event: Event) => {
|
const handleFileChange = (event: Event) => {
|
||||||
const input = event.target as HTMLInputElement
|
const input = event.target as HTMLInputElement
|
||||||
|
|
||||||
if (input.files) {
|
if (input.files) {
|
||||||
Array.from(input.files).forEach((file) => {
|
Array.from(input.files).forEach((file) => {
|
||||||
// 只处理图片文件
|
// 只处理图片文件
|
||||||
if (file.type.startsWith('image/')) {
|
if (file.type.startsWith('image/')) {
|
||||||
const reader = new FileReader()
|
const formData = new FormData()
|
||||||
reader.onload = (e) => {
|
formData.append('file', file)
|
||||||
uploadedImages.value.push({
|
uploadImage(formData).then((res) => {
|
||||||
url: e.target?.result as string,
|
console.log(res)
|
||||||
name: file.name
|
|
||||||
})
|
const reader = new FileReader()
|
||||||
}
|
reader.onload = (e) => {
|
||||||
reader.readAsDataURL(file)
|
uploadedImages.value.push({
|
||||||
|
url: e.target?.result as string,
|
||||||
|
name: file.name,
|
||||||
|
path: res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -293,7 +302,6 @@
|
|||||||
imgClose.src = closeIcon as unknown as string
|
imgClose.src = closeIcon as unknown as string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
textSpan.innerText = tagText
|
textSpan.innerText = tagText
|
||||||
|
|
||||||
imgClose.addEventListener('click', (ev) => {
|
imgClose.addEventListener('click', (ev) => {
|
||||||
@@ -467,19 +475,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSendAgent = async () => {
|
const handleSendAgent = async () => {
|
||||||
console.log('发送信息--------')
|
|
||||||
|
|
||||||
if (props.generating) {
|
if (props.generating) {
|
||||||
emits('pause')
|
emits('pause')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!inputValue.value.trim()) return
|
if (!inputValue.value.trim()) return
|
||||||
console.log('222222')
|
const imageUrlList = uploadedImages.value.map((item) => item.path)
|
||||||
|
|
||||||
const payload = { text: inputValue.value.trim(), images: uploadedImages.value }
|
const payload = { text: inputValue.value.trim(), images: imageUrlList }
|
||||||
console.log('准备发送 send 事件', payload)
|
|
||||||
emits('send', payload)
|
emits('send', payload)
|
||||||
console.log('send 事件已发送')
|
|
||||||
|
|
||||||
// 发送后清空输入框
|
// 发送后清空输入框
|
||||||
if (editorRef.value) {
|
if (editorRef.value) {
|
||||||
@@ -573,7 +577,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
// console.log('Create project with:', params)
|
// console.log('Create project with:', params)
|
||||||
router.push('/home/agent', { query: params })
|
router.push(`/home/agent/${projectres}`, { query: params })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴露方法给父组件
|
// 暴露方法给父组件
|
||||||
@@ -1056,15 +1060,14 @@
|
|||||||
height: 1rem;
|
height: 1rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
&.restore{
|
&.restore {
|
||||||
width: 0.5rem;
|
width: 0.5rem;
|
||||||
height: 0.5rem;
|
height: 0.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.restore-icon{
|
.restore-icon {
|
||||||
width: 1.2rem;
|
width: 1.2rem;
|
||||||
height: 1.2rem;
|
height: 1.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user