|
@@ -1,9 +1,9 @@
|
|
|
const api_key = 'app-NvKwdHvEK2UmJdmjTGDR0xu6'
|
|
|
-const url = 'https://ai.xsip.cn/v1'
|
|
|
+const url = 'http://192.168.2.24/v1'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- controller:null
|
|
|
+ controller:null,
|
|
|
}
|
|
|
},
|
|
|
computed:{
|
|
@@ -13,42 +13,63 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
async getResult(){
|
|
|
- if(!this.confession.guid){
|
|
|
+ if(!this.notice_file.guid){
|
|
|
this.$message.warning('请先上传审查意见书')
|
|
|
return
|
|
|
}
|
|
|
- this.loading = true
|
|
|
- this.result = null
|
|
|
+
|
|
|
+ this.cancelRun()
|
|
|
+
|
|
|
this.controller = new AbortController();
|
|
|
+ let patent_fileUrls = {}
|
|
|
+ if(this.patent_fileUrls && this.patent_fileUrls.length){
|
|
|
+ this.patent_fileUrls.forEach(item=>{
|
|
|
+ patent_fileUrls[item.name] = item.guid
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // var params = {
|
|
|
+ // inputs:{
|
|
|
+ // fileUrl:'http://192.168.2.24:8803/fileManager/downloadFile?fileId='+this.notice_file.guid,
|
|
|
+ // patent_fileUrls:JSON.stringify(patent_fileUrls)
|
|
|
+ // },
|
|
|
+ // query:'OA答辩',
|
|
|
+ // response_mode:'streaming',
|
|
|
+ // user:this.userinfo.id
|
|
|
+ // }
|
|
|
+ // this.loading = true
|
|
|
+ // 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 = {
|
|
|
- query:{
|
|
|
- fileUrl:this.confession.guid,
|
|
|
- patent_fileUrls:patent_fileUrls.map(item=>{
|
|
|
- return item.guid
|
|
|
- })
|
|
|
- },
|
|
|
- response_mode:'streaming',
|
|
|
- user:this.userinfo.id
|
|
|
+ confessionSessionId:this.currentConversation.id,
|
|
|
+ patentFileUrls:JSON.stringify(patent_fileUrls)
|
|
|
}
|
|
|
- const response = await fetch(url + '/chat-messages', {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- // 'Accept': 'text/event-stream',
|
|
|
- 'Authorization':'Bearer ' + api_key
|
|
|
- },
|
|
|
- data:JSON.stringify(params),
|
|
|
- signal: this.controller.signal
|
|
|
- });
|
|
|
+ this.loading = true
|
|
|
+ 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
|
|
|
+ });
|
|
|
if (!response.ok) throw new Error('AI API 调用失败');
|
|
|
- this.finish = false
|
|
|
const reader = response.body.getReader();
|
|
|
const decoder = new TextDecoder('utf-8');
|
|
|
let noFinishMessage = ''
|
|
|
while (true) {
|
|
|
const { done, value } = await reader.read();
|
|
|
if (done){
|
|
|
- this.finish = true
|
|
|
this.loading = false
|
|
|
break;
|
|
|
}
|
|
@@ -63,16 +84,21 @@ export default {
|
|
|
try {
|
|
|
const json = JSON.parse(jsonStr);
|
|
|
if(json.event == 'message'){
|
|
|
- this.result += json.answer;
|
|
|
- }else if(json.event == 'message_replace'){
|
|
|
- this.result = json.answer
|
|
|
- }else if(json.event == 'text_chunk'){
|
|
|
- if(json.data){
|
|
|
- this.result += json.data.text;
|
|
|
+ let answer = json.answer
|
|
|
+ try{
|
|
|
+ let answer_json = JSON.parse(answer)
|
|
|
+ if(answer_json.code == 1001){//缺少专利文件
|
|
|
+ this.$refs.errorTip.open(answer_json.data)
|
|
|
+ }else if(answer_json.code == 200){
|
|
|
+ this.queryConfessionSession(false,false,true)
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+ this.result += answer;
|
|
|
}
|
|
|
|
|
|
- }else if(json.event == 'workflow_finished'){
|
|
|
- this.queryConfessionSession(false,false,true)
|
|
|
+ }else if(json.event == 'message_replace'){
|
|
|
+ this.result = json.answer
|
|
|
+ }else if(json.event == 'message_end'){
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
@@ -84,15 +110,20 @@ export default {
|
|
|
try{
|
|
|
const json = JSON.parse(noFinishMessage);
|
|
|
if(json.event == 'message'){
|
|
|
- this.result += json.answer;
|
|
|
+ let answer = json.answer
|
|
|
+ try{
|
|
|
+ let answer_json = JSON.parse(answer)
|
|
|
+ if(answer_json.code == 1001){//缺少专利文件
|
|
|
+ this.$refs.errorTip.open(answer_json.data)
|
|
|
+ }else if(answer_json.code == 200){
|
|
|
+ this.queryConfessionSession(false,false,true)
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+ this.result += answer;
|
|
|
+ }
|
|
|
}else if(json.event == 'message_replace'){
|
|
|
this.result = json.answer
|
|
|
- }else if(json.event == 'text_chunk'){
|
|
|
- if(json.data){
|
|
|
- this.result += json.data.text;
|
|
|
- }
|
|
|
- }else if(json.event == 'workflow_finished'){
|
|
|
- this.queryConfessionSession(false,false,true)
|
|
|
+ }else if(json.event == 'message_end'){
|
|
|
}
|
|
|
}
|
|
|
catch(e){
|