|
|
@@ -1,3 +1,5 @@
|
|
|
+import chart from "@/store/modules/chart"
|
|
|
+
|
|
|
const api_key = 'app-NRQwVZmqF8a1yuhzgB96Ndj1'
|
|
|
const url = 'http://192.168.2.24/v1'
|
|
|
export default {
|
|
|
@@ -13,21 +15,59 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- async getResult(){
|
|
|
- if(!this.notice_file.guid){
|
|
|
- this.$message.warning('请先上传审查意见书')
|
|
|
- return
|
|
|
+ async sendMessage(message,operation=1,question){
|
|
|
+ if(!question){
|
|
|
+ switch(operation){
|
|
|
+ case 1:
|
|
|
+ question = ''
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ question = ''
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ question = '请分析并给出修改意见'
|
|
|
+ break
|
|
|
+ case 4:
|
|
|
+ question = '生成修改方案'
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ question = '我接受这些修改,请获取答辩点'
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ question = '请生成答复意见'
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- this.cancelRun()
|
|
|
+ // 添加对话记录
|
|
|
+ var params = {
|
|
|
+ confessionSessionId:this.currentConversation.id,
|
|
|
+ question:question,
|
|
|
+ operation:operation,
|
|
|
+ answer:''
|
|
|
+ }
|
|
|
+ let chatRecord = await this.addChatRecord(params)
|
|
|
+ this.messageList.push(chatRecord)
|
|
|
+ this.sendMessage1(message,chatRecord,operation)
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ async addChatRecord(params){
|
|
|
+ var chatRecord = {}
|
|
|
+ await this.$api.saveChatRecord(params).then(response=>{
|
|
|
+ if(response.code == 200){
|
|
|
+ let id = response.data
|
|
|
+ chatRecord = {
|
|
|
+ id:id,
|
|
|
+ ...params
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return chatRecord
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
- this.controller = new AbortController();
|
|
|
+ async sendMessage1(lastMessage,message,operation=1){
|
|
|
let patent_fileUrls = {}
|
|
|
- // if(this.patent_fileUrls && this.patent_fileUrls.length){
|
|
|
- // this.patent_fileUrls.forEach(item=>{
|
|
|
- // patent_fileUrls[item.name] = item.guid
|
|
|
- // })
|
|
|
- // }
|
|
|
if(this.relevant_file.contrast_file && this.relevant_file.contrast_file.length){
|
|
|
this.relevant_file.contrast_file.forEach(item=>{
|
|
|
if(item.file && item.file.guid){
|
|
|
@@ -35,67 +75,84 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- // var params = {
|
|
|
- // inputs:{
|
|
|
- // fileUrl:'http://192.168.2.24:8803/fileManager/downloadFile?fileId='+this.notice_file.guid,
|
|
|
- // patent_fileUrls:JSON.stringify(patent_fileUrls),
|
|
|
- // patent_files:[],
|
|
|
- // changeClaim:this.changeClaim.changeClaim + '',
|
|
|
- // claim:this.changeClaim.claim,
|
|
|
- // near_index:this.changeClaim.near_index,
|
|
|
- // main_claim_reason:JSON.stringify(this.main_claim_reason)
|
|
|
- // },
|
|
|
- // query:'OA答辩',
|
|
|
- // response_mode:'streaming',
|
|
|
- // user:this.userinfo.id
|
|
|
- // }
|
|
|
- // this.loading = true
|
|
|
- // this.loading_text = ''
|
|
|
- // var loading_text = ''
|
|
|
- // this.result = null
|
|
|
- // const response = await fetch('https://ai.xsip.cn/v1/chat-messages', {
|
|
|
- // method: 'POST',
|
|
|
- // headers: {
|
|
|
- // 'Content-Type': 'application/json',
|
|
|
- // // 'Accept': 'text/event-stream',
|
|
|
- // 'Authorization': `Bearer ${api_key}`,
|
|
|
- // },
|
|
|
- // body:JSON.stringify(params),
|
|
|
- // signal: this.controller.signal
|
|
|
- // });
|
|
|
- var params = {
|
|
|
- confessionSessionId:this.currentConversation.id,
|
|
|
- patentFileUrls:JSON.stringify(patent_fileUrls),
|
|
|
- appFileGuid:this.relevant_file.app_file.guid,
|
|
|
- modifyFileGuid:this.relevant_file.modify_file.guid,
|
|
|
+ let inputs = {
|
|
|
+ fileUrl:'http://192.168.2.24:8803/fileManager/downloadFile?fileId='+this.notice_file.guid,
|
|
|
+ patent_fileUrls:JSON.stringify(patent_fileUrls),
|
|
|
+ app_file_guid:this.relevant_file.app_file.guid,
|
|
|
+ modify_file_guid:this.relevant_file.modify_file.guid,
|
|
|
changeClaim:this.changeClaim.changeClaim + '',
|
|
|
claim:this.changeClaim.claim,
|
|
|
- nearIndex:this.changeClaim.near_index,
|
|
|
- mainClaimReason:JSON.stringify(this.main_claim_reason)
|
|
|
+ near_index:this.changeClaim.near_index,
|
|
|
+ main_claim_reason:JSON.stringify(this.main_claim_reason),
|
|
|
+ claimChangeSuggestion:this.changeClaim.claimChangeSuggestion,
|
|
|
+ operation:operation+'',
|
|
|
+ query:this.difyQuery
|
|
|
}
|
|
|
+ // if(lastMessage){
|
|
|
+ // switch(operation){
|
|
|
+ // case 4:
|
|
|
+ // inputs.claimChangeSuggestion = lastMessage.answer
|
|
|
+ // break;
|
|
|
+ // case 5:
|
|
|
+ // inputs.claim = lastMessage.answer
|
|
|
+ // break;
|
|
|
+ // case 6:
|
|
|
+ // inputs.main_claim_reason = JSON.stringify(lastMessage.answer)
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ var params = {
|
|
|
+ inputs:inputs,
|
|
|
+ query:this.difyQuery || 'OA答辩',
|
|
|
+ conversation_id:this.currentConversation.conversationId,
|
|
|
+ response_mode:'streaming',
|
|
|
+ user:this.userinfo.id
|
|
|
+ }
|
|
|
+ this.difyQuery = ''
|
|
|
+ this.$set(message,'loading',true)
|
|
|
this.loading = true
|
|
|
- this.loading_text = ''
|
|
|
- var loading_text = ''
|
|
|
this.result = null
|
|
|
- const response = await fetch('/api/xiaoshi/dify/sendOADefense', {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- 'Accept': 'text/event-stream',
|
|
|
- },
|
|
|
- body:JSON.stringify(params),
|
|
|
- signal: this.controller.signal
|
|
|
- });
|
|
|
+ const response = await fetch('https://ai.xsip.cn/v1/chat-messages', {
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json',
|
|
|
+ // 'Accept': 'text/event-stream',
|
|
|
+ 'Authorization': `Bearer app-UTUV4s0TkGMBqHBEF3oqAbVp`,
|
|
|
+ },
|
|
|
+ body:JSON.stringify(params)
|
|
|
+ });
|
|
|
+
|
|
|
if (!response.ok) throw new Error('AI API 调用失败');
|
|
|
const reader = response.body.getReader();
|
|
|
const decoder = new TextDecoder('utf-8');
|
|
|
let noFinishMessage = ''
|
|
|
+ message.answer = ''
|
|
|
while (true) {
|
|
|
const { done, value } = await reader.read();
|
|
|
if (done){
|
|
|
this.loading = false
|
|
|
- if(this.hasFiles){
|
|
|
- this.saveAllFiles(this.hasFiles)
|
|
|
+ if(message.loading){
|
|
|
+ this.$set(message,'loading',false)
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
+ let params = {
|
|
|
+ ...message
|
|
|
+ }
|
|
|
+ if(typeof (params.answer) != "string"){
|
|
|
+ params.answer = JSON.stringify(params.answer)
|
|
|
+ }else{
|
|
|
+ params.answer = params.answer.replace('undefined','')
|
|
|
+ }
|
|
|
+ this.addChatRecord(params)
|
|
|
+ if(params.operation == 3){
|
|
|
+ this.changeClaim.claimChangeSuggestion = params.answer
|
|
|
+ this.updateContent()
|
|
|
+ }
|
|
|
+ if(params.operation == 4){
|
|
|
+ this.changeClaim.claim = params.answer
|
|
|
+ this.updateContent()
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -110,45 +167,62 @@ export default {
|
|
|
try {
|
|
|
const json = JSON.parse(jsonStr);
|
|
|
if(json.event == 'message'){
|
|
|
+ if(!this.currentConversation.conversationId){
|
|
|
+ this.currentConversation.conversationId = json.conversation_id
|
|
|
+ this.saveConversationId(json.conversation_id)
|
|
|
+ }
|
|
|
+ if(message.loading){
|
|
|
+ this.$set(message,'loading',false)
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
let answer = json.answer
|
|
|
try{
|
|
|
let answer_json = JSON.parse(answer)
|
|
|
- if(answer_json.code == 1001){//缺少专利文件
|
|
|
- this.result = answer_json
|
|
|
- this.$refs.errorTip.open(answer_json)
|
|
|
- }else if(answer_json.code == 200){
|
|
|
- this.queryConfessionSession(false,false,true)
|
|
|
- }else if(answer_json.code == 1003){//中间过程
|
|
|
- this.loading_text = answer_json.data
|
|
|
- loading_text = answer_json.data
|
|
|
- }else if(answer_json.code == 1002){//请求超时
|
|
|
- this.result = answer_json
|
|
|
- }else if(answer_json.code == 201){//修改后的权利要求输出
|
|
|
- this.result = answer_json
|
|
|
- this.$set(this.changeClaim,'claim',answer_json.data)
|
|
|
- if(this.app_file && this.app_file.guid){
|
|
|
- this.handleOptionClick(this.app_file,2)
|
|
|
+ if(operation != 6){
|
|
|
+ this.$set(message,'answer',answer_json)
|
|
|
+ }
|
|
|
+
|
|
|
+ if(operation == 1){
|
|
|
+ if(answer_json.code == 1001){//缺少专利文件
|
|
|
+ this.$refs.errorTip.open(answer_json)
|
|
|
+ }else if(answer_json.code == 203){//文件输出
|
|
|
+ this.app_file = answer_json.data.app_file || {}
|
|
|
+ this.modify_file = answer_json.data.modify_file || {}
|
|
|
+ this.contrast_file = answer_json.data.contrast_file || []
|
|
|
+ this.relevant_file = {
|
|
|
+ app_file:this.app_file,
|
|
|
+ modify_file:this.modify_file,
|
|
|
+ contrast_file:this.contrast_file
|
|
|
+ }
|
|
|
+ this.updateContent()
|
|
|
+ this.sendMessage(null,2)
|
|
|
}
|
|
|
- }else if(answer_json.code == 202){//区别技术特征
|
|
|
- this.result = answer_json
|
|
|
- this.$set(this,'main_claim_reason',answer_json.data)
|
|
|
- }else if(answer_json.code == 203){//文件输出
|
|
|
- this.hasFiles = answer_json.data
|
|
|
- this.app_file = answer_json.data.app_file || {}
|
|
|
- this.modify_file = answer_json.data.modify_file || {}
|
|
|
- this.contrast_file = answer_json.data.contrast_file || []
|
|
|
+ }else if(operation == 2){
|
|
|
+ this.changeClaim.near_index = answer_json.nearIndex
|
|
|
+ this.changeClaim.nearNo = answer_json.nearNo
|
|
|
+ this.changeClaim.changeClaim = answer_json.changeClaim
|
|
|
+ this.changeClaim.novelty_innovative = answer_json.novelty_innovative
|
|
|
+ this.updateContent()
|
|
|
+ }else if(operation == 5){
|
|
|
+ this.main_claim_reason = answer_json
|
|
|
+ this.updateContent()
|
|
|
+ }else if(operation == 6){
|
|
|
+ this.updateContent(operation,answer_json)
|
|
|
}
|
|
|
+
|
|
|
}catch(e){
|
|
|
- if(loading_text!=''){
|
|
|
- loading_text = ''
|
|
|
- this.loading_text = ''
|
|
|
- }
|
|
|
- this.result += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
|
|
|
+ message.answer += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
|
|
|
}
|
|
|
|
|
|
}else if(json.event == 'message_replace'){
|
|
|
- this.result = json.answer
|
|
|
+ this.$set(message,'answer',json.answer)
|
|
|
+ if(message.loading){
|
|
|
+ this.$set(message,'loading',false)
|
|
|
+ }
|
|
|
}else if(json.event == 'message_end'){
|
|
|
+ if(message.loading){
|
|
|
+ this.$set(message,'loading',false)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
@@ -160,44 +234,54 @@ export default {
|
|
|
try{
|
|
|
const json = JSON.parse(noFinishMessage);
|
|
|
if(json.event == 'message'){
|
|
|
+ if(message.loading){
|
|
|
+ this.$set(message,'loading',false)
|
|
|
+ }
|
|
|
let answer = json.answer
|
|
|
try{
|
|
|
let answer_json = JSON.parse(answer)
|
|
|
- if(answer_json.code == 1001){//缺少专利文件
|
|
|
- this.result = answer_json
|
|
|
- this.$refs.errorTip.open(answer_json)
|
|
|
- }else if(answer_json.code == 1002){//请求超时
|
|
|
- this.result = answer_json
|
|
|
- }else if(answer_json.code == 200){
|
|
|
- this.queryConfessionSession(false,false,true)
|
|
|
- }else if(answer_json.code == 1003){//中间过程
|
|
|
- this.loading_text = answer_json.data
|
|
|
- loading_text = answer_json.data
|
|
|
- }else if(answer_json.code == 201){//修改后的权利要求输出
|
|
|
- this.result = answer_json
|
|
|
- this.$set(this.changeClaim,'claim',answer_json.data)
|
|
|
- if(this.app_file && this.app_file.guid){
|
|
|
- this.handleOptionClick(this.app_file,2)
|
|
|
+ if(operation != 6){
|
|
|
+ this.$set(message,'answer',answer_json)
|
|
|
+ }
|
|
|
+ if(operation == 1){
|
|
|
+ if(answer_json.code == 1001){//缺少专利文件
|
|
|
+ this.$refs.errorTip.open(answer_json)
|
|
|
+ }else if(answer_json.code == 203){//文件输出
|
|
|
+ this.app_file = answer_json.data.app_file || {}
|
|
|
+ this.modify_file = answer_json.data.modify_file || {}
|
|
|
+ this.contrast_file = answer_json.data.contrast_file || []
|
|
|
+ this.relevant_file = {
|
|
|
+ app_file:this.app_file,
|
|
|
+ modify_file:this.modify_file,
|
|
|
+ contrast_file:this.contrast_file
|
|
|
+ }
|
|
|
+ this.updateContent()
|
|
|
+ this.sendMessage(null,2)
|
|
|
}
|
|
|
- }else if(answer_json.code == 202){//区别技术特征
|
|
|
- this.result = answer_json
|
|
|
- this.$set(this,'main_claim_reason',answer_json.data)
|
|
|
- }else if(answer_json.code == 203){//文件输出
|
|
|
- this.hasFiles = answer_json.data
|
|
|
- this.app_file = answer_json.data.app_file || {}
|
|
|
- this.modify_file = answer_json.data.modify_file || {}
|
|
|
- this.contrast_file = answer_json.data.contrast_file || []
|
|
|
+ }else if(operation == 2){
|
|
|
+ this.changeClaim.near_index = answer_json.nearIndex
|
|
|
+ this.changeClaim.nearNo = answer_json.nearNo
|
|
|
+ this.changeClaim.changeClaim = answer_json.changeClaim
|
|
|
+ this.changeClaim.novelty_innovative = answer_json.novelty_innovative
|
|
|
+ this.updateContent()
|
|
|
+ }else if(operation == 5){
|
|
|
+ this.main_claim_reason = answer_json
|
|
|
+ this.updateContent()
|
|
|
+ }else if(operation == 6){
|
|
|
+ this.updateContent(operation,answer_json)
|
|
|
}
|
|
|
}catch(e){
|
|
|
- if(loading_text!=''){
|
|
|
- loading_text = ''
|
|
|
- this.loading_text = ''
|
|
|
- }
|
|
|
- this.result += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
|
|
|
+ message.answer += answer.replace(/\n|\\n|\\\n|\\\\n/g,'<br>');
|
|
|
}
|
|
|
}else if(json.event == 'message_replace'){
|
|
|
- this.result = json.answer
|
|
|
+ this.$set(message,'answer',json.answer)
|
|
|
+ if(message.loading){
|
|
|
+ this.$set(message,'loading',false)
|
|
|
+ }
|
|
|
}else if(json.event == 'message_end'){
|
|
|
+ if(message.loading){
|
|
|
+ this.$set(message,'loading',false)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
catch(e){
|
|
|
@@ -213,40 +297,40 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- //保存文件
|
|
|
- async saveAllFiles(files){
|
|
|
- await this.getConversionDetails()
|
|
|
- let content = this.currentConversation.content
|
|
|
+ //更新会话的content
|
|
|
+ async updateContent(operation,data){
|
|
|
+ let content = {
|
|
|
+ query:{
|
|
|
+ relevant_file:this.relevant_file,
|
|
|
+ claimChange:this.changeClaim,
|
|
|
+ main_claim_reason:this.main_claim_reason
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(operation == 6){
|
|
|
+ content.data = data
|
|
|
+ }
|
|
|
var params = {
|
|
|
confessionSessionId:this.currentConversation.id,
|
|
|
+ content:JSON.stringify(content)
|
|
|
}
|
|
|
- if(!content){
|
|
|
- params.content = JSON.stringify(
|
|
|
- {
|
|
|
- relevant_file:files
|
|
|
- }
|
|
|
- )
|
|
|
- }else{
|
|
|
- try{
|
|
|
- let data1 = JSON.parse(content)
|
|
|
- if(data1.data && data1.data.code == 1001){
|
|
|
- data1.data = {}
|
|
|
- }
|
|
|
- data1.relevant_file = files
|
|
|
- params.content = JSON.stringify(data1)
|
|
|
-
|
|
|
- }catch(e){
|
|
|
- params.content = JSON.stringify(
|
|
|
- {
|
|
|
- relevant_file:files
|
|
|
- }
|
|
|
- )
|
|
|
+ this.$api.updateConfessionSession(params).then(response=>{
|
|
|
+ if(response.code == 200){
|
|
|
+ this.queryConfessionSession(true)
|
|
|
}
|
|
|
+ }).catch(error=>{
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //更新会话的dify会话id
|
|
|
+ saveConversationId(id){
|
|
|
+ var params = {
|
|
|
+ confessionSessionId:this.currentConversation.id,
|
|
|
+ conversationId:id
|
|
|
}
|
|
|
this.$api.updateConfessionSession(params).then(response=>{
|
|
|
if(response.code == 200){
|
|
|
- this.queryConfessionSession(true)
|
|
|
- this.hasFiles = null
|
|
|
+ // this.queryConfessionSession(true)
|
|
|
+ this.currentConversation.conversationId = id
|
|
|
}
|
|
|
}).catch(error=>{
|
|
|
|