1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
BaseConnector.php
См. документацию.
1
<?php
2
declare(strict_types=1);
3
4
namespace
Bitrix\Landing\Copilot\Connector\AI
;
5
6
use Bitrix\AI\Context;
7
use Bitrix\AI\Engine;
8
use
Bitrix\Main
;
9
use
Bitrix\Main\Loader
;
10
use
Bitrix\Main\LoaderException
;
11
12
abstract
class
BaseConnector
implements
IConnector
13
{
14
protected
const
CATEGORY
=
'text'
;
15
16
protected
const
CONTEXT_ID
=
'landing_site_copilot'
;
17
protected
const
DEFAULT_TEMPERATURE
= 0.7;
18
protected
const
MAX_TOKENS
= 16383;
19
20
protected
const
PROMPT_CODE
=
'zero_prompt'
;
21
protected
const
PROMPT_CATEGORY
=
''
;
22
23
protected
bool
$active
=
true
;
24
protected
?
Engine
$engine
;
25
protected
float
$temperature
= self::DEFAULT_TEMPERATURE;
26
30
public
function
__construct
()
31
{
32
if
(!Loader::includeModule(
'ai'
))
33
{
34
$this->active =
false
;
35
}
36
else
37
{
38
$engineCode = static::getEngineCode();
39
if
($engineCode)
40
{
41
$this->active =
true
;
42
$this->engine = Engine::getByCode(
43
$engineCode,
44
new
Context
(
'landing'
, static::CONTEXT_ID),
45
static::CATEGORY
46
);
47
}
48
}
49
}
50
54
abstract
public
function
request
(
Prompt
$prompt):
Main
\
Result
;
55
56
abstract
protected
function
getEngineCode
(): ?string;
57
58
protected
function
canRequest
(): bool
59
{
60
return
$this->active && isset($this->engine);
61
}
62
63
public
function
setTemperature
(
float
$temperature
): self
64
{
65
$this->temperature =
$temperature
;
66
67
return
$this;
68
}
69
}
Bitrix\Landing\Copilot\Connector\AI\BaseConnector
Определения
BaseConnector.php:13
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\__construct
__construct()
Определения
BaseConnector.php:30
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\MAX_TOKENS
const MAX_TOKENS
Определения
BaseConnector.php:18
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\CONTEXT_ID
const CONTEXT_ID
Определения
BaseConnector.php:16
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\$engine
Engine $engine
Определения
BaseConnector.php:24
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\PROMPT_CATEGORY
const PROMPT_CATEGORY
Определения
BaseConnector.php:21
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\getEngineCode
getEngineCode()
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\$active
bool $active
Определения
BaseConnector.php:23
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\setTemperature
setTemperature(float $temperature)
Определения
BaseConnector.php:63
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\CATEGORY
const CATEGORY
Определения
BaseConnector.php:14
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\DEFAULT_TEMPERATURE
const DEFAULT_TEMPERATURE
Определения
BaseConnector.php:17
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\canRequest
canRequest()
Определения
BaseConnector.php:58
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\PROMPT_CODE
const PROMPT_CODE
Определения
BaseConnector.php:20
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\request
request(Prompt $prompt)
Bitrix\Landing\Copilot\Connector\AI\BaseConnector\$temperature
float $temperature
Определения
BaseConnector.php:25
Bitrix\Landing\Copilot\Connector\AI\Prompt
Определения
Prompt.php:7
Bitrix\Main\DB\Result
Определения
result.php:20
Bitrix\Main\LoaderException
Определения
loader.php:659
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Landing\Copilot\Connector\AI\IConnector
Определения
IConnector.php:9
Bitrix\Landing\Copilot\Connector\AI
Определения
BaseConnector.php:4
Bitrix\Main\Context
Определения
culture.php:9
Bitrix\Main\Engine
Определения
action.php:3
Bitrix\Main
bitrix
modules
landing
lib
Copilot
Connector
AI
BaseConnector.php
Создано системой
1.14.0