1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Image.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 Image extends BaseConnector
13{
14 protected const CATEGORY = 'image';
15 protected const CONTEXT_ID = 'landing_site_copilot_image';
16
17 public function request(Prompt $prompt): Main\Result
18 {
19 $result = new Main\Result();
20
21 if (!$this->canRequest())
22 {
23 $result->addError(
24 new Main\Error(
25 'Ai is not available now', 'AI_UNAVAILABLE'
26 )
27 );
28
29 return $result;
30 }
31
32 $this->setTemperature($prompt->getTemperature());
33
34 $payload = new Payload\StyledPicture($prompt->getCode());
35 $payload->setMarkers($prompt->getMarkers());
36
37 $this->engine->setPayload($payload);
38 $this->engine->setHistoryState(true);
39
40 $this->engine
41 ->onSuccess(function (AI\Result $aiResult, ?string $hash = null) use (&$result) {
42 if ($hash)
43 {
44 $result->setData(['hash' => $hash]);
45 }
46 else
47 {
48 $result->setData(['result' => $aiResult->getPrettifiedData()]);
49 }
50 })
51 ->onError(function (Main\Error $error) use (&$result) {
52 $result->addError(new Main\Error(
53 $error->getMessage(), $error->getCode()
54 ));
55 })
56 ->completionsInQueue()
57 ;
58
59 return $result;
60 }
61
62 protected function getEngineCode(): ?string
63 {
64 $manager = new Tuning\Manager();
65
67 }
68}
$hash
Определения ajax_redirector.php:8
const TUNING_CODE_SITE_IMAGE_PROVIDER
Определения ai.php:28
setTemperature(float $temperature)
Определения BaseConnector.php:63
request(Prompt $prompt)
Определения Image.php:17
Определения result.php:20
Определения error.php:15
$result
Определения get_property_values.php:14
Определения ai.php:3
Определения agent.php:3
$manager
Определения office365push.php:39
$error
Определения subscription_card_product.php:20