@@ -17,11 +17,15 @@ var rule = {
1717 let { publicUrl} = this ;
1818 // log('publicUrl:', publicUrl);
1919 let setIcon = urljoin ( publicUrl , './images/icon_cookie/设置.png' ) ;
20+ let chatIcon = urljoin ( publicUrl , './images/icon_cookie/chat.webp' ) ;
2021 action_data . forEach ( it => {
2122 if ( ! it . vod_pic ) {
2223 it . vod_pic = setIcon ;
2324 }
24- } )
25+ if ( it . vod_name === '连续对话' ) {
26+ it . vod_pic = chatIcon ;
27+ }
28+ } ) ;
2529 return action_data ;
2630 } ,
2731 类型 : '设置' ,
@@ -34,6 +38,22 @@ var rule = {
3438 more : {
3539 sourceTag : '设置,动作' ,
3640 actions : [
41+ {
42+ name : '连续对话' , action : JSON . stringify ( {
43+ actionId : '连续对话' ,
44+ id : 'talk' ,
45+ type : 'input' ,
46+ title : '连续对话' ,
47+ tip : '请输入消息' ,
48+ value : '' ,
49+ msg : '开始新的对话' ,
50+ button : 3 ,
51+ imageUrl : 'https://img2.baidu.com/it/u=1206278833,3265480730&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800' ,
52+ imageHeight : 200 ,
53+ imageType : 'card_pic_3' ,
54+ keep : true ,
55+ } )
56+ } ,
3757 { name : '查看夸克cookie' , action : '查看夸克cookie' } ,
3858 { name : '设置夸克cookie' , action : '设置夸克cookie' } ,
3959 { name : '夸克扫码' , action : '夸克扫码' } ,
@@ -210,6 +230,8 @@ var rule = {
210230 d . push ( getInput ( 'get_hide_adult' , '查看青少年模式' , images . settings ) ) ;
211231 d . push ( genMultiInput ( 'thread' , '设置播放代理线程数' , '默认为1,可自行配置成其他值如:10' , images . settings ) ) ;
212232 d . push ( getInput ( 'get_thread' , '查看播放代理线程数' , images . settings ) ) ;
233+ d . push ( genMultiInput ( 'spark_ai_authKey' , '设置讯飞AI鉴权' , '在这个页面的http鉴权信息:https://console.xfyun.cn/services/bm4' , images . settings ) ) ;
234+ d . push ( getInput ( 'get_spark_ai_authKey' , '查看讯飞AI鉴权' , images . settings ) ) ;
213235 break ;
214236 case 'test' :
215237 d . push ( {
@@ -281,26 +303,61 @@ var rule = {
281303
282304 if ( action === '连续对话' ) {
283305 let content = JSON . parse ( value ) ;
284- try {
285- a = b ;
286- } catch ( e ) {
287- console . error ( '测试出错捕获:' , e ) ;
306+ let prompt = content . talk . trim ( ) ;
307+ if ( ! prompt ) {
308+ return JSON . stringify ( {
309+ action : {
310+ actionId : '__keep__' ,
311+ } ,
312+ toast : '输入内容不可以为空哦~'
313+ } ) ;
314+ // return '输入内容不可以为空哦~'
288315 }
289- console . error ( '对象日志测试:' , 0 , '==== ' , content , ' ====' , true ) ;
290- if ( content . talk . indexOf ( 'http' ) > - 1 ) {
316+ // try {
317+ // a = b;
318+ // } catch (e) {
319+ // console.error('测试出错捕获:', e);
320+ // }
321+ // console.error('对象日志测试:', 0, '==== ', content, ' ====', true);
322+
323+ if ( prompt . startsWith ( 'http' ) ) {
291324 return JSON . stringify ( {
292325 action : {
293326 actionId : '__detail__' ,
294327 skey : 'push_agent' ,
295- ids : content . talk ,
328+ ids : prompt ,
296329 } ,
297330 toast : '你要去看视频了'
298331 } ) ;
299332 }
333+ let replyContent = prompt ;
334+ if ( ENV . get ( 'spark_ai_authKey' ) ) {
335+ if ( rule . askLock ) {
336+ return JSON . stringify ( {
337+ action : {
338+ actionId : '__keep__' ,
339+ msg : '请等待AI思考完成...' ,
340+ reset : false
341+ } ,
342+ toast : 'AI思考中,请稍候继续提问'
343+ } ) ;
344+ }
345+ const sparkAI = new SparkAI ( {
346+ authKey : ENV . get ( 'spark_ai_authKey' ) ,
347+ baseURL : 'https://spark-api-open.xf-yun.com' ,
348+ } ) ;
349+ rule . askLock = 1 ;
350+ try {
351+ replyContent = await sparkAI . ask ( prompt , { temperature : 1.0 } ) ;
352+ } catch ( error ) {
353+ replyContent = error . message ;
354+ }
355+ rule . askLock = 0 ;
356+ }
300357 return JSON . stringify ( {
301358 action : {
302359 actionId : '__keep__' ,
303- msg : '回音: ' + content . talk ,
360+ msg : '你: ' + prompt + '\n' + 'AI:' + replyContent ,
304361 reset : true
305362 } ,
306363 toast : '你有新的消息'
@@ -736,6 +793,7 @@ var rule = {
736793 'bili_cookie' ,
737794 'hide_adult' ,
738795 'thread' ,
796+ 'spark_ai_authKey' ,
739797 ] ;
740798 let get_cookie_sets = [
741799 'get_quark_cookie' ,
@@ -744,6 +802,7 @@ var rule = {
744802 'get_bili_cookie' ,
745803 'get_hide_adult' ,
746804 'get_thread' ,
805+ 'get_spark_ai_authKey' ,
747806 ] ;
748807 if ( cookie_sets . includes ( action ) && value ) {
749808 try {
0 commit comments