BxBaseStudioAgentsLogs.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioAgentsLogs extends BxDolStudioAgentsGrid
  11. {
  12. public function __construct ($aOptions, $oTemplate = false)
  13. {
  14. parent::__construct ($aOptions, $oTemplate);
  15. $this->addMarkers($this->_aBrowseParams);
  16. }
  17. protected function _getCellLevel ($mixedValue, $sKey, $aField, $aRow)
  18. {
  19. switch ($mixedValue) {
  20. case 'info':
  21. $mixedValue = '<span title="Info">ℹ️</span>';
  22. break;
  23. case 'error':
  24. $mixedValue = '<span title="Error">❗️</span>';
  25. break;
  26. default:
  27. $mixedValue = '<span title="' . bx_html_attribute($mixedValue) . '">⚠️</span>';
  28. break;
  29. }
  30. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  31. }
  32. protected function _getCellMessage ($mixedValue, $sKey, $aField, $aRow)
  33. {
  34. switch ($mixedValue) {
  35. case 'workflow-end':
  36. $mixedValue = '⏹️ ' . $mixedValue;
  37. break;
  38. case 'workflow-start':
  39. $mixedValue = '▶️ ' . $mixedValue;
  40. break;
  41. case 'error':
  42. $mixedValue = '❗️ ' . $mixedValue;
  43. break;
  44. case 'tool-calling':
  45. case 'tool-called':
  46. $mixedValue = '🛠️ ' . $mixedValue;
  47. break;
  48. default:
  49. if (preg_match('/^message-/', $mixedValue)) {
  50. $mixedValue = '💬 ' . $mixedValue;
  51. } elseif (preg_match('/^rag-/', $mixedValue)) {
  52. $mixedValue = '🔍 ' . $mixedValue;
  53. }
  54. elseif (preg_match('/^inference-/', $mixedValue)) {
  55. $mixedValue = '⚛️ ' . $mixedValue;
  56. }
  57. break;
  58. }
  59. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  60. }
  61. protected function _getCellContext ($mixedValue, $sKey, $aField, $aRow)
  62. {
  63. $sPopupString = '<div style="width: 100vw; max-width: 800px;"><textarea class="bx-def-font-inputs bx-form-input-textarea">' . $mixedValue . '</textarea></div>';
  64. $mixedValue = BxTemplFunctions::getInstance()->getStringWithLimitedLength($mixedValue, 55, true, true, $sPopupString);
  65. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  66. }
  67. protected function _getCellCreatedAt ($mixedValue, $sKey, $aField, $aRow)
  68. {
  69. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  70. }
  71. }
  72. /** @} */