agents.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. require_once('./inc/header.inc.php');
  10. require_once(BX_DIRECTORY_PATH_INC . "utils.inc.php");
  11. bx_import('BxDolLanguages');
  12. $sTool = bx_process_input(bx_get('t'));
  13. /**
  14. * Work with Providers
  15. */
  16. if(($iProviderId = bx_get('p')) !== false) {
  17. $iProviderId = bx_process_input($iProviderId, BX_DATA_INT);
  18. if(!$iProviderId)
  19. exit;
  20. $oProvider = BxDolAIProvider::getObjectInstance($iProviderId);
  21. if(!$oProvider)
  22. exit;
  23. if(($sAction = bx_get('a')) !== false) {
  24. $sAction = 'processAction' . bx_gen_method_name(bx_process_input($sAction));
  25. if(method_exists($oProvider, $sAction))
  26. $oProvider->$sAction();
  27. }
  28. else {
  29. $mixedResponce = $oProvider->call('products/7433953116300.json', ['fields' => 'id,title,handle,body_html,tags,variants'], 'get');
  30. print_r($mixedResponce);
  31. }
  32. }
  33. /**
  34. * Work with Assistants
  35. */
  36. if($sTool == 'asst' && ($iId = bx_get('id')) !== false) {
  37. $oAssistant = BxDolAIAssistant::getObjectInstance((int)$iId);
  38. if(($sAction = bx_get('a')) !== false) {
  39. $sAction = 'processAction' . bx_gen_method_name(bx_process_input($sAction));
  40. if(method_exists($oAssistant, $sAction))
  41. $oAssistant->$sAction();
  42. }
  43. }
  44. /** @} */