BxDolAIToolContentGet.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\ToolProperty;
  11. class BxDolAIToolContentGet extends BxDolAITool
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct(
  16. 'content_get',
  17. 'Retrieve content info for a given module and content id, including author info and URL. If needed, prepend base URL to links: ' . BX_DOL_URL_ROOT,
  18. );
  19. }
  20. protected function properties(): array
  21. {
  22. return [
  23. new ToolProperty(
  24. name: 'module',
  25. type: PropertyType::STRING,
  26. description: 'The module name to retrieve content info from. Use "system" for site accounts. ',
  27. required: true
  28. ),
  29. new ToolProperty(
  30. name: 'content_id',
  31. type: PropertyType::INTEGER,
  32. description: 'The ID of the content item to retrieve info for.',
  33. required: true
  34. )
  35. ];
  36. }
  37. public function __invoke(string $module, int $content_id): array
  38. {
  39. $a = bx_srv('system', 'get_info', [$module, $content_id], 'TemplServiceContent');
  40. if (!$a)
  41. return ["error" => "Content item was not found"];
  42. return $a;
  43. }
  44. }