Browse Source

添加ai对话框

xiaoguang_li 1 month ago
parent
commit
1d33f34c3f
1 changed files with 6 additions and 2 deletions
  1. 6 2
      desktop/core/src/desktop/templates/assist.mako

+ 6 - 2
desktop/core/src/desktop/templates/assist.mako

@@ -2798,7 +2798,7 @@ from desktop.views import _ko
         <!-- 输入区域 -->
         <div class="input-area">
             <textarea rows="1" class="user-input clearable" placeholder="请输入你的问题..."
-                      data-bind=" textInput: query, event: { keydown: ask, input: autoResize} "></textarea>
+                      data-bind="clearable: query, textInput: query, event: { keydown: ask, input: autoResize} "></textarea>
         <!--    <button class="send-btn" data-bind="click: answer">发送</button>-->
         </div>
       </div>
@@ -2814,12 +2814,13 @@ from desktop.views import _ko
 
         self.activeType = ko.observable();
         self.availableTypes = ko.observableArray(window.IS_EMBEDDED ? ['Impala'] : ['Hive', 'Impala', 'Pig']);
-        self.query = ko.observable().extend({ rateLimit: 100 });
+        self.query = ko.observable().extend({ rateLimit: 1 });
         self.messages = ko.observableArray([]);
 
         self.query.subscribe(function (newValue, oldValue) {
             let inputTextArea = $('.user-input')[0]
             if (inputTextArea) {
+                console.log(new Date() + "  old:" + oldValue +" -> new:" +newValue )
                 self.autoResize(null, { target: inputTextArea } );
             }
         });
@@ -2877,13 +2878,16 @@ from desktop.views import _ko
       };
 
       ChatPanel.prototype.answer = function (data, event) {
+        console.log(new Date() +"  start answer")
         let self = this;
         let cleanQuery = self.query().trim();
         if (cleanQuery === '') {
+            console.log(new Date() +"  end answer query: "+ cleanQuery )
             return
         }
         self.query('');
         event.target.value = '';
+        console.log(new Date() +"  end answer query: "+ cleanQuery )
 
         self.messages.push({type:'user', content: cleanQuery});
         self.messages.push({type:'ai', content: '感谢提问!我已经收到你的消息:' + cleanQuery});