You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
722 B
23 lines
722 B
<?php |
|
$start = microtime(true); |
|
$ch = curl_init('http://10.100.1.26:11434/api/chat'); |
|
$body = json_encode([ |
|
'model' => 'qwen2.5:7b', |
|
'messages' => [['role' => 'user', 'content' => 'Jawab singkat: halo']], |
|
'stream' => false, |
|
]); |
|
curl_setopt_array($ch, [ |
|
CURLOPT_POST => true, |
|
CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
|
CURLOPT_POSTFIELDS => $body, |
|
CURLOPT_RETURNTRANSFER => true, |
|
CURLOPT_TIMEOUT => 180, |
|
]); |
|
$resp = curl_exec($ch); |
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
$err = curl_error($ch); |
|
curl_close($ch); |
|
$elapsed = round(microtime(true) - $start, 2); |
|
echo "code=$code time={$elapsed}s\n"; |
|
if ($err) echo "err=$err\n"; |
|
echo substr((string) $resp, 0, 300)."\n";
|
|
|