BxDolAIToolContentGet.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. use NeuronAI\Tools\PropertyType;
  10. use NeuronAI\Tools\Tool;
  11. use NeuronAI\Tools\ToolProperty;
  12. class BxDolAIToolContentGet extends Tool
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct(
  17. 'get_content_info',
  18. 'Retrieve content info for a given module and content id.',
  19. );
  20. }
  21. protected function properties(): array
  22. {
  23. return [
  24. new ToolProperty(
  25. name: 'module',
  26. type: PropertyType::STRING,
  27. description: 'The module name to retrieve content info from. Use "system" for site accounts. ',
  28. required: true
  29. ),
  30. new ToolProperty(
  31. name: 'content_id',
  32. type: PropertyType::INTEGER,
  33. description: 'The ID of the content item to retrieve info for.',
  34. required: true
  35. )
  36. ];
  37. }
  38. public function __invoke(string $module, int $content_id): string
  39. {
  40. $a = bx_srv('system', 'get_info', [$module, $content_id], 'TemplServiceContent');
  41. if (!$a)
  42. return "Error: content item was not found";
  43. return json_encode($a);
  44. }
  45. }