BxDolAIToolChatGoalReached.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 BxDolAIToolChatGoalReached extends BxDolAITool
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct(
  16. 'chat_goal_reached',
  17. 'Call once when the session goal is reached (next step given, link sent). Do not print tool output to the visitor. Do not call again in the same session.',
  18. );
  19. }
  20. protected function properties(): array
  21. {
  22. return [
  23. new ToolProperty(
  24. name: 'summary',
  25. type: PropertyType::STRING,
  26. description: 'Short internal note: group type, size, readiness, which link was given.',
  27. required: false
  28. ),
  29. ];
  30. }
  31. public function __invoke(string $sSummary = ''): string
  32. {
  33. $b = BxDolAiChat::getInstance()->emitConversationClosed('goal', trim((string)$sSummary));
  34. return $b ? 'ok' : 'already_closed';
  35. }
  36. }