@@ -35,64 +35,31 @@ Component({
3535 const appBaseInfo = wx . getAppBaseInfo ( ) ;
3636 const fileId = res . fileID ;
3737 this . triggerEvent ( "changeChild" , { tempId : this . data . fileData . tempId , status : "parsing" } ) ;
38-
3938 console . log ( "当前版本" , appBaseInfo . SDKVersion ) ;
40- // 3.8.1 及以上版本走sdk 内置方法
41- if ( compareVersions ( appBaseInfo . SDKVersion , "3.8.1" ) < 0 ) {
42- const { token } = await cloudInstance . extend . AI . bot . tokenManager . getToken ( ) ;
43- commonRequest ( {
44- url : `https://${
45- cloudInstance . env || cloudInstance . extend . AI . bot . context . env
46- } .api.tcloudbasegateway.com/v1/aibot/bots/${ botId } /files`,
47- data : {
48- fileList : [
49- {
50- fileName : rawFileName || tempFileName ,
51- fileId,
52- type : rawType ,
53- } ,
54- ] ,
55- } ,
56- header : {
57- Authorization : `Bearer ${ token } ` ,
58- } ,
59- method : "POST" ,
60- success : ( res ) => {
61- console . log ( "old resolve agent file res" , res ) ;
62- this . triggerEvent ( "changeChild" , { tempId : this . data . fileData . tempId , fileId, status : "parsed" } ) ;
63- } ,
64- fail : ( e ) => {
65- console . log ( "resolve agent file e" , e ) ;
66- this . triggerEvent ( "changeChild" , { tempId : this . data . fileData . tempId , fileId, status : "parseFailed" } ) ;
67- } ,
68- } ) ;
69- } else {
70- const ai = cloudInstance . extend . AI ;
71- ai . request ( {
72- path : `bots/${ botId } /files` , // 填写 "v1/aibot/" 后面的内容
73- data : {
74- fileList : [
75- {
76- fileName : rawFileName || tempFileName ,
77- fileId,
78- type : rawType ,
79- } ,
80- ] ,
81- } , // any
82- method : "POST" ,
83- timeout : 30000 ,
84- success : ( res ) => {
85- console . log ( "resolve agent file res" , res ) ;
86- this . triggerEvent ( "changeChild" , { tempId : this . data . fileData . tempId , fileId, status : "parsed" } ) ;
87- } ,
88- fail : ( e ) => {
89- console . log ( "e" , e ) ;
90- this . triggerEvent ( "changeChild" , { tempId : this . data . fileData . tempId , fileId, status : "parseFailed" } ) ;
91- } ,
92- complete : ( ) => { } ,
93- header : { } ,
94- } ) ;
95- }
39+ commonRequest ( {
40+ path : `bots/${ botId } /files` ,
41+ data : {
42+ fileList : [
43+ {
44+ fileName : rawFileName || tempFileName ,
45+ fileId,
46+ type : rawType ,
47+ } ,
48+ ] ,
49+ } , // any
50+ method : "POST" ,
51+ timeout : 60000 ,
52+ success : ( res ) => {
53+ console . log ( "resolve agent file res" , res ) ;
54+ this . triggerEvent ( "changeChild" , { tempId : this . data . fileData . tempId , fileId, status : "parsed" } ) ;
55+ } ,
56+ fail : ( e ) => {
57+ console . log ( "e" , e ) ;
58+ this . triggerEvent ( "changeChild" , { tempId : this . data . fileData . tempId , fileId, status : "parseFailed" } ) ;
59+ } ,
60+ complete : ( ) => { } ,
61+ header : { } ,
62+ } )
9663 } ,
9764 fail : ( err ) => {
9865 console . error ( "上传失败:" , err ) ;
0 commit comments