BxBaseStudioAgentsLogs.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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-start':
  36. case 'workflow-end':
  37. $mixedValue = '❇️ ' . $mixedValue . ' ❇️';
  38. break;
  39. case 'error':
  40. $mixedValue = '❗️ ' . $mixedValue;
  41. break;
  42. case 'tool-calling':
  43. case 'tool-called':
  44. $mixedValue = '🛠️ ' . $mixedValue;
  45. break;
  46. default:
  47. if (preg_match('/^message-/', $mixedValue)) {
  48. $mixedValue = '💬 ' . $mixedValue;
  49. } elseif (preg_match('/^rag-/', $mixedValue)) {
  50. $mixedValue = '🔍 ' . $mixedValue;
  51. }
  52. elseif (preg_match('/^inference-/', $mixedValue)) {
  53. $mixedValue = '⚛️ ' . $mixedValue;
  54. }
  55. break;
  56. }
  57. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  58. }
  59. protected function _getCellContext ($mixedValue, $sKey, $aField, $aRow)
  60. {
  61. $sPopupString = '<div style="width: 100vw; max-width: 800px;"><textarea class="bx-def-font-inputs bx-form-input-textarea">' . $mixedValue . '</textarea></div>';
  62. $mixedValue = BxTemplFunctions::getInstance()->getStringWithLimitedLength($mixedValue, 55, true, true, $sPopupString);
  63. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  64. }
  65. protected function _getCellCreatedAt ($mixedValue, $sKey, $aField, $aRow)
  66. {
  67. return parent::_getCellDefault ($mixedValue, $sKey, $aField, $aRow);
  68. }
  69. }
  70. /** @} */