📄 Source: test_api.php
<?php
header('Content-Type: application/json');
$query = "Do I have any emails from Chess.com?";
// Simulate what chat_handler.php does
$ollamaUrl = 'http://127.0.0.1:11434/api/generate';
$data = [
'model' => 'llama3.2:3b',
'prompt' => "User asks: $query. Answer briefly.",
'stream' => false,
'options' => ['num_predict' => 100]
];
$ch = curl_init($ollamaUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP: $httpCode\n";
$result = json_decode($response, true);
echo "Response: " . ($result['response'] ?? 'no response') . "\n";
?>
← Back