Просмотр исходного кода

#5406 AI Agents revamp: agents manual run

Aleksandr Trofimov 6 месяцев назад
Родитель
Сommit
c9eb013e06

+ 0 - 1
inc/classes/BxDolAIVectorStoreFactory.php

@@ -30,7 +30,6 @@ class BxDolAIVectorStoreFactory extends BxDolFactory
             'topk' => $a['topk'],
         ]);
         
-        // TODO: fix params
         switch($a['type']) {
             case 'file':
                 $o = new NeuronAI\RAG\VectorStore\FileVectorStore(

+ 3 - 0
studio/template/agents_manual_response.html

@@ -0,0 +1,3 @@
+<div class="text-left">
+    __response__
+</div>

+ 30 - 0
studio/template/scripts/BxBaseStudioAgentsAgents.php

@@ -27,6 +27,29 @@ class BxBaseStudioAgentsAgents extends BxDolStudioAgentsAgents
         return 'oBxDolStudioPageAgents';
     }
 
+    public function performActionManual()
+    {
+        $iId = $this->_getId();        
+        $aAgent = BxDolAiQuery::getAgentObject($iId);
+        if (!$aAgent) {
+            echoJson(['msg' => _t('_sys_txt_error_occured')]);
+            return;
+        }
+
+        $oAi = BxDolAI::getInstance();
+        $sResponse = $oAi->callAgent('manual', $aAgent);
+
+        $oParsedown = new Parsedown();
+        $oParsedown->setSafeMode(true);
+        $sMessageHtml = $oParsedown->text($sResponse);
+
+        $oTemplate = BxDolStudioTemplate::getInstance();
+        $sHtml = $oTemplate->parseHtmlByName('agents_manual_response.html', [
+            'response' => $sMessageHtml
+        ]);
+        echoJson(['msg' => $sHtml]);
+    }
+
     public function performActionAdd()
     {
         $sAction = 'add';
@@ -537,6 +560,13 @@ class BxBaseStudioAgentsAgents extends BxDolStudioAgentsAgents
             'btn_add' => $oForm->genInputButton($aInputButton)
         ]);
     }
+
+    protected function _getActionManual ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
+    {
+        if ($aRow['trigger'] != 'manual' && $aRow['trigger'] != 'scheduler')
+            return '';
+        return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
+    }
 }
 
 /** @} */