-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathdebug_gemini.php
More file actions
38 lines (29 loc) · 1.09 KB
/
debug_gemini.php
File metadata and controls
38 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
use App\Services\AiAdvisorService;
use App\Models\Mahasiswa;
use Illuminate\Support\Facades\Config;
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
try {
echo "Checking configuration...\n";
$apiKey = config('services.gemini.api_key');
if (empty($apiKey)) {
echo "WARNING: GEMINI_API_KEY is empty in config. Test will likely fail.\n";
} else {
echo "GEMINI_API_KEY is set (length: " . strlen($apiKey) . ")\n";
}
echo "Resolving AiAdvisorService...\n";
$service = app(AiAdvisorService::class);
echo "Finding student...\n";
$mahasiswa = Mahasiswa::with('user')->first();
if (!$mahasiswa) die("No student found.\n");
echo "Testing connection to Gemini (gemini-2.5-flash-lite)...\n";
$result = $service->chat($mahasiswa, "Halo, tes koneksi. Jawab singkat satu kata: 'Berhasil'.");
echo "Result:\n";
print_r($result);
} catch (\Throwable $e) {
echo "ERROR:\n";
echo $e->getMessage() . "\n";
}