1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Text.php
См. документацию.
1<?php
2declare(strict_types=1);
3
4namespace Bitrix\Landing\Copilot\Connector\AI;
5
6use Bitrix\Main;
7use Bitrix\Landing;
8use Bitrix\AI;
9use Bitrix\AI\Payload;
10use Bitrix\AI\Tuning;
11
12class Text extends BaseConnector
13{
14 protected const PROMPT_CODE = 'zero_prompt';
15 protected const CATEGORY = 'text';
16 protected const CONTEXT_ID = 'landing_site_copilot_text';
17
18 public function request(Prompt $prompt): Main\Result
19 {
20 $result = new Main\Result();
21
22 if (!$this->canRequest())
23 {
24 $result->addError(
25 new Main\Error(
26 'Ai is not available now', 'AI_UNAVAILABLE'
27 )
28 );
29
30 return $result;
31 }
32
33 $this->setTemperature($prompt->getTemperature());
34
35 $promptCode = $prompt->getCode();
36 $payload = new Payload\Prompt($promptCode);
37 $payload->setPromptCategory(static::PROMPT_CATEGORY);
38 $payload->setMarkers($prompt->getMarkers());
39
40 $this->engine->setPayload($payload);
41 $this->engine->setParameters($this->getParams());
42 $this->engine->setUserParameters($this->getUserParams());
43 $this->engine->setHistoryState(true);
44
45 $this->engine
46 ->onSuccess(function (AI\Result $aiResult, ?string $hash = null) use (&$result){
47 if ($hash)
48 {
49 $result->setData(['hash' => $hash]);
50 }
51 else
52 {
53 $result->setData(['result' => $aiResult->getPrettifiedData()]);
54 }
55 })
56 ->onError(function (Main\Error $error) use (&$result)
57 {
58 $result->addError(new Main\Error(
59 $error->getMessage(), $error->getCode()
60 ));
61 })
62 ->completionsInQueue()
63 ;
64
65 return $result;
66 }
67
68 protected function getEngineCode(): ?string
69 {
70 $manager = new Tuning\Manager();
71
73 }
74
75 private function getParams(): array
76 {
77 return [
78 'max_tokens' => self::MAX_TOKENS,
79 ];
80 }
81
82 private function getUserParams(): array
83 {
84 return [
85 'promptCategory' => '',
86 'temperature' => $this->temperature,
87 ];
88 }
89}
$hash
Определения ajax_redirector.php:8
const TUNING_CODE_SITE_TEXT_PROVIDER
Определения ai.php:29
setTemperature(float $temperature)
Определения BaseConnector.php:63
request(Prompt $prompt)
Определения Text.php:18
Определения result.php:20
Определения error.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
Определения ai.php:3
Определения agent.php:3
Определения base32.php:2
$manager
Определения office365push.php:39
$error
Определения subscription_card_product.php:20