26 lines
1.1 KiB
PHP
26 lines
1.1 KiB
PHP
<?php
|
|
// Safe DeepSeek hook - preserves php://input for other endpoints
|
|
$_raw_body = file_get_contents("php://input");
|
|
$_jin = @json_decode($_raw_body, true);
|
|
$_mdl = $_jin["model"] ?? $_GET["model"] ?? "";
|
|
|
|
// ONLY intercept deepseek-web models, pass through everything else
|
|
if (in_array($_mdl, ["deepseek-web","deepseek-web-think","deepseek-web-search"])) {
|
|
$msg = $_jin["message"] ?? "";
|
|
$ch = curl_init("http://127.0.0.1/api/wevia-webchat-direct.php");
|
|
curl_setopt_array($ch, [CURLOPT_POST=>true, CURLOPT_RETURNTRANSFER=>true, CURLOPT_TIMEOUT=>15,
|
|
CURLOPT_HTTPHEADER=>["Content-Type: application/json"],
|
|
CURLOPT_POSTFIELDS=>json_encode(["service"=>"deepseek","message"=>$msg])]);
|
|
$r = curl_exec($ch); curl_close($ch);
|
|
$d = json_decode($r, true);
|
|
if (!empty($d["content"])) {
|
|
header("Content-Type: application/json");
|
|
echo $r;
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// CRITICAL: Re-inject the raw body so the next script can read it
|
|
// This is needed because php://input can only be read once
|
|
$GLOBALS['_wevia_raw_body'] = $_raw_body;
|