Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
settings.php
1<?php
2
4
6use Bitrix\AI;
8
9final class Settings
10{
11 private const SETTINGS_ITEM_MAIL_CODE = EventHandler::SETTINGS_ITEM_MAIL_CODE;
12 private const SETTINGS_ITEM_MAIL_CRM_CODE = EventHandler::SETTINGS_ITEM_MAIL_CRM_CODE;
13 public const MAIL_NEW_MESSAGE_CONTEXT_ID = 'mail_new_message';
14 public const MAIL_REPLY_MESSAGE_CONTEXT_ID = 'mail_reply_message';
15 public const MAIL_CRM_NEW_MESSAGE_CONTEXT_ID = 'crm_mail_new_message';
16 public const MAIL_CRM_REPLY_MESSAGE_CONTEXT_ID = 'crm_mail_reply_message';
17
18 public static function instance(): self
19 {
20 return new self();
21 }
22
24 {
25 if (!Loader::includeModule('ai')
26 || !$this->isAITurningManagerAvailable()
27 )
28 {
29 return false;
30 }
31
32 $manager = new AI\Tuning\Manager();
33 $item = $manager->getItem(self::SETTINGS_ITEM_MAIL_CODE);
34
35 return (bool)$item?->getValue();
36 }
37
39 {
40 if (!Loader::includeModule('ai')
41 || !Loader::includeModule('crm')
42 || !$this->isAITurningManagerAvailable()
43 )
44 {
45 return false;
46 }
47
48 $manager = new AI\Tuning\Manager();
49 $item = $manager->getItem(self::SETTINGS_ITEM_MAIL_CRM_CODE);
50
51 return (bool)$item?->getValue();
52 }
53
54 public function getMailCopilotParams(string $contextId, ?array $contextParams = null): array
55 {
57 {
58 return ['isCopilotEnabled' => false];
59 }
60
61 return $this->prepareMailCopilotParams(
63 $contextId,
64 'mail',
65 $contextParams,
66 );
67 }
68
69 public function getMailCrmCopilotParams(string $contextId, ?array $contextParams = null): array
70 {
72 {
73 return ['isCopilotEnabled' => false];
74 }
75
76 return $this->prepareMailCopilotParams(
78 $contextId,
79 'mail_crm',
80 $contextParams,
81 );
82 }
83
84 private function prepareMailCopilotParams(bool $isCopilotEnabled, string $contextId, string $category, ?array $contextParams = null): array
85 {
86 return [
87 'isCopilotEnabled' => $isCopilotEnabled,
88 'isCopilotTextEnabled' => $isCopilotEnabled,
89 'moduleId' => 'mail',
90 'contextId' => $contextId,
91 'category' => $category,
92 'invitationLineMode' => 'eachLine',
93 'contextParameters' => $contextParams ?? [],
94 ];
95 }
96
97 private function isAITurningManagerAvailable(): bool
98 {
99 return Loader::includeModule('ai') && class_exists('\Bitrix\AI\Tuning\Manager');
100 }
101}
getMailCopilotParams(string $contextId, ?array $contextParams=null)
Definition settings.php:54
getMailCrmCopilotParams(string $contextId, ?array $contextParams=null)
Definition settings.php:69