Răsfoiți Sursa

#5406 AI Agents revamp: mail send tool.

Aleksandr Trofimov 5 luni în urmă
părinte
comite
108da6aba5
2 a modificat fișierele cu 54 adăugiri și 1 ștergeri
  1. 51 0
      inc/classes/BxDolAIToolEmailSend.php
  2. 3 1
      install/sql/system.sql

+ 51 - 0
inc/classes/BxDolAIToolEmailSend.php

@@ -0,0 +1,51 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+use NeuronAI\Tools\PropertyType;
+use NeuronAI\Tools\ToolProperty;;
+
+class BxDolAIToolEmailSend extends BxDolAITool
+{
+    public function __construct()
+    {
+        parent::__construct(
+            'email_send',
+            'Use this tool to send e-mail.',
+        );
+    }
+
+    protected function properties(): array
+    {
+        return [
+            new ToolProperty(
+                name: 'email',
+                type: PropertyType::STRING,
+                description: 'Recipient email, one or several comma separated emails.',
+                required: true
+            ),
+            new ToolProperty(
+                name: 'subject',
+                type: PropertyType::STRING,
+                description: 'Mail subject.',
+                required: true
+            ),
+            new ToolProperty(
+                name: 'body',
+                type: PropertyType::STRING,
+                description: 'Mail body.',
+                required: true
+            ),
+        ];
+    }
+
+    public function __invoke(string $email, string $subject, string $body): bool
+    {
+        return sendMail($email, $subject, $body);
+    }
+}

+ 3 - 1
install/sql/system.sql

@@ -7332,7 +7332,9 @@ INSERT INTO `sys_agents_tools` (`type`, `title`, `docs`, `params`, `params_user`
 ('comments_get', 'Comments get', 'This tool allows agents to get comments for specific content by module name and content id.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsGet', ''),
 ('comments_add', 'Comments add', 'This tool allows agents to post comments for specific content.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsAdd', ''),
 ('comments_update', 'Comments update', 'This tool allows agents to edit comments.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsUpdate', ''),
-('comments_delete', 'Comments delete', 'This tool allows agents to delete comments.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsDelete', '');
+('comments_delete', 'Comments delete', 'This tool allows agents to delete comments.', '{}', NULL, 0, 0, 1, 'BxDolAIToolCmtsDelete', ''),
+
+('email_send', 'E-mail send', 'This tool allows agents to send e-mails.', '{}', NULL, 0, 0, 1, 'BxDolAIToolEmailSend', '');
 
 CREATE TABLE IF NOT EXISTS `sys_agents_chat_history` (
   `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,