26 lines
617 B
PHP
Executable File
26 lines
617 B
PHP
Executable File
|
|
<?php
|
|
header('Content-Type: text/event-stream');
|
|
header('Cache-Control: no-cache');
|
|
header('Connection: keep-alive');
|
|
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
$prompt = $data['prompt'] ?? 'Analyse ce document...';
|
|
|
|
$ch = curl_init('http://localhost:11434/api/generate');
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
|
|
"model" => "llama3.2",
|
|
"prompt" => $prompt,
|
|
"stream" => true
|
|
]));
|
|
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $data) {
|
|
echo "data: " . $data . "\n\n";
|
|
ob_flush();
|
|
flush();
|
|
return strlen($data);
|
|
});
|
|
curl_exec($ch);
|
|
curl_close($ch);
|
|
?>
|
|
|