/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/components/GoogleAlComponent.php
62 строки
1 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\components; use common\helpers\ArrayHelper; use Gemini\Client; use yii\base\Component; use Yii; use yii\helpers\VarDumper; /** * Компонент для работы с Google AI * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2019-2025 */ class GoogleAlComponent extends Component { /** * Клиент для работы с Google AI * @var Client */ protected $client = null; /** * @inheritdoc */ public function init() { parent::init(); // TODO: Change the autogenerated stub $config = ArrayHelper::getValue(Yii::$app->params, 'google_ai'); Yii::debug(VarDumper::dumpAsString([ 'config' => $config ])); $options = []; if ($proxy = ArrayHelper::getValue($config, 'proxy')) { $options[CURLOPT_PROXY] = $proxy; } $http_client = new \Http\Client\Curl\Client(null, null, $options); $apiKey = ArrayHelper::getValue($config, 'api_key'); $this->client = \Gemini::factory() ->withApiKey($apiKey) ->withHttpClient($http_client) // default: HTTP client found using PSR-18 HTTP Client Discovery ->make(); } /** * Получить экземпляр клиента для работы * @return Client */ public function getClient() { return $this->client; } }