Browse Source

助手chatsessionid修复

master
xueyinfei 2 weeks ago
parent
commit
6aff1559a7
  1. 2
      vue-fastapi-frontend/src/store/modules/user.js
  2. 1
      vue-fastapi-frontend/src/utils/request.js
  3. 12
      vue-fastapi-frontend/src/views/aichat/aichat.vue
  4. 13
      vue-fastapi-frontend/src/views/aichat/index.vue
  5. 2
      vue-fastapi-frontend/src/views/login.vue

2
vue-fastapi-frontend/src/store/modules/user.js

@ -86,6 +86,8 @@ const useUserStore = defineStore(
removeToken() removeToken()
cache.local.remove('username') cache.local.remove('username')
cache.local.remove('password') cache.local.remove('password')
cache.local.remove('chatSessionId')
cache.local.remove('waitingTotal')
resolve() resolve()
}).catch(error => { }).catch(error => {
reject(error) reject(error)

1
vue-fastapi-frontend/src/utils/request.js

@ -169,6 +169,7 @@ service.interceptors.request.use(config => {
} }
} }
} }
config.timeout = 180000
return config return config
}, error => { }, error => {
console.log(error) console.log(error)

12
vue-fastapi-frontend/src/views/aichat/aichat.vue

@ -324,7 +324,7 @@ const upload = reactive({
headers: { Authorization: "Bearer " + getToken() }, headers: { Authorization: "Bearer " + getToken() },
// //
url: import.meta.env.VITE_APP_BASE_API + "/aichat/upload", url: import.meta.env.VITE_APP_BASE_API + "/aichat/upload",
data: {"sessionId":Cookies.get("chatSessionId")} data: {"sessionId":cache.local.get("chatSessionId")}
}); });
const isDisabledChart = computed( const isDisabledChart = computed(
() => !(inputValue.value.trim()) () => !(inputValue.value.trim())
@ -345,7 +345,7 @@ function confirmReturn(item,index){
chatList.value.splice(index); chatList.value.splice(index);
let reqData = { let reqData = {
"user_id": cache.local.get("username"), "user_id": cache.local.get("username"),
"session_id": Cookies.get("chatSessionId"), "session_id": cache.local.get("chatSessionId"),
"checkpointer": item.checkpointer "checkpointer": item.checkpointer
} }
sendChatMessage(reqData) sendChatMessage(reqData)
@ -532,7 +532,7 @@ function processAuth(data){
updateChatProcessData(updateData).then(res=>{ updateChatProcessData(updateData).then(res=>{
let reqData = { let reqData = {
"user_id": cache.local.get("username"), "user_id": cache.local.get("username"),
"session_id": Cookies.get("chatSessionId"), "session_id": cache.local.get("chatSessionId"),
"checkpointer": data.checkpointer, "checkpointer": data.checkpointer,
"action": data.action, "action": data.action,
"resume": true, "resume": true,
@ -559,7 +559,7 @@ async function sendChatHandle(event) {
"type": "question", "type": "question",
"content": inputValue.value.trim(), "content": inputValue.value.trim(),
"time": formatDate(new Date()), "time": formatDate(new Date()),
"sessionId": Cookies.get("chatSessionId"), "sessionId": cache.local.get("chatSessionId"),
"sessionName": chatList.value.length > 0 ? chatList.value[0].content.substring(0, 20) : inputValue.value.trim().substring(0, 20), "sessionName": chatList.value.length > 0 ? chatList.value[0].content.substring(0, 20) : inputValue.value.trim().substring(0, 20),
"file": currentFiles.value "file": currentFiles.value
} }
@ -576,7 +576,7 @@ async function sendChatHandle(event) {
"query": inputValue.value.trim(), "query": inputValue.value.trim(),
"user_id": cache.local.get("username"), "user_id": cache.local.get("username"),
"robot": currentMachine.value.length > 0 ? currentMachine.value[0] : "", "robot": currentMachine.value.length > 0 ? currentMachine.value[0] : "",
"session_id": Cookies.get("chatSessionId"), "session_id": cache.local.get("chatSessionId"),
"doc": currentFiles.value "doc": currentFiles.value
} }
if (chatList.value.length > 0){ if (chatList.value.length > 0){
@ -644,7 +644,7 @@ function sendChatMessage(data){
if (autoRequest){ if (autoRequest){
let reqData = { let reqData = {
"user_id": cache.local.get("username"), "user_id": cache.local.get("username"),
"session_id": Cookies.get("chatSessionId"), "session_id": cache.local.get("chatSessionId"),
"checkpointer": answer.checkpointer, "checkpointer": answer.checkpointer,
"action":"", "action":"",
"resume": true, "resume": true,

13
vue-fastapi-frontend/src/views/aichat/index.vue

@ -84,6 +84,7 @@ import AiChat from './aichat.vue'
import AutoTooltip from './auto-tooltip.vue' import AutoTooltip from './auto-tooltip.vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { listChatHistory, getChatList, DeleteChatSession } from "@/api/aichat/aichat"; import { listChatHistory, getChatList, DeleteChatSession } from "@/api/aichat/aichat";
import cache from "../../plugins/cache.js";
const route = useRoute() const route = useRoute()
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const { const {
@ -97,7 +98,7 @@ const AiChatRef = ref()
const chatLogeData = ref([]) const chatLogeData = ref([])
const show = ref(false) const show = ref(false)
const currentRecordList = ref([]) const currentRecordList = ref([])
const sessionId = ref(Cookies.get("chatSessionId")) // Id 'new' const sessionId = ref(cache.local.get("chatSessionId")) // Id 'new'
const mouseId = ref('') const mouseId = ref('')
const paginationConfig = reactive({ const paginationConfig = reactive({
@ -133,7 +134,7 @@ function showChatHistory(){
function newChat() { function newChat() {
currentRecordList.value = [] currentRecordList.value = []
sessionId.value = uuidv4() sessionId.value = uuidv4()
Cookies.set("chatSessionId",sessionId.value) cache.local.set("chatSessionId",sessionId.value)
} }
function handleScroll(event) { function handleScroll(event) {
@ -153,7 +154,7 @@ function clickListHandle(item){
paginationConfig.current_page = 1 paginationConfig.current_page = 1
currentRecordList.value = [] currentRecordList.value = []
sessionId.value = item.sessionId sessionId.value = item.sessionId
Cookies.set("chatSessionId",sessionId.value) cache.local.set("chatSessionId",sessionId.value)
getChatRecord({sessionId: item.sessionId, pageNum: paginationConfig.current_page, pageSize: paginationConfig.page_size}) getChatRecord({sessionId: item.sessionId, pageNum: paginationConfig.current_page, pageSize: paginationConfig.page_size})
show.value = false show.value = false
} }
@ -186,11 +187,11 @@ function getChatRecord(data){
watch(() => props.chatDataList, value => currentRecordList.value = JSON.parse(JSON.stringify(value))) watch(() => props.chatDataList, value => currentRecordList.value = JSON.parse(JSON.stringify(value)))
onMounted( onMounted(
()=>{ ()=>{
if (Cookies.get("chatSessionId")){ if (cache.local.get("chatSessionId")){
// //
getChatRecord({sessionId: Cookies.get("chatSessionId"), pageNum: paginationConfig.current_page, pageSize: paginationConfig.page_size}) getChatRecord({sessionId: cache.local.get("chatSessionId"), pageNum: paginationConfig.current_page, pageSize: paginationConfig.page_size})
}else { }else {
Cookies.set("chatSessionId",uuidv4()) cache.local.set("chatSessionId",uuidv4())
} }
} }
) )

2
vue-fastapi-frontend/src/views/login.vue

@ -129,7 +129,7 @@ function handleLogin() {
}, {}); }, {});
cache.local.set("username",loginForm.value.username) cache.local.set("username",loginForm.value.username)
cache.local.set("password",md5(loginForm.value.password)) cache.local.set("password",md5(loginForm.value.password))
Cookies.set("chatSessionId", 'new') cache.local.remove("chatSessionId")
router.push({ path: redirect.value || "/", query: otherQueryParams }); router.push({ path: redirect.value || "/", query: otherQueryParams });
}).catch(() => { }).catch(() => {
loading.value = false; loading.value = false;

Loading…
Cancel
Save