Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
20.00% |
1 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
GeminiClient | |
20.00% |
1 / 5 |
|
50.00% |
1 / 2 |
4.05 | |
0.00% |
0 / 1 |
setClient | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
chat | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Mbvb1223\ChatAiMulticlient\Clients; |
6 | |
7 | use GeminiAPI\Client; |
8 | use GeminiAPI\Resources\ModelName; |
9 | use GeminiAPI\Resources\Parts\TextPart; |
10 | |
11 | class GeminiClient extends BaseClient |
12 | { |
13 | protected string $model = ModelName::GEMINI_1_5_FLASH; |
14 | private Client $client; |
15 | |
16 | public function setClient(string $apiKey): void |
17 | { |
18 | $this->client = new Client($apiKey); |
19 | } |
20 | |
21 | public function chat(string $text, string $model = null, array $options = []): string |
22 | { |
23 | $response = $this->client |
24 | ->generativeModel($model ?? $this->getModel()) |
25 | ->generateContent(new TextPart($text)); |
26 | |
27 | return $response->text(); |
28 | } |
29 | } |