27 lines
1.5 KiB
PHP
27 lines
1.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
// Read-only provider parameters. Does not submit patient data or generate a report.
|
|
$serverRoot = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR;
|
|
chdir($serverRoot);
|
|
require $serverRoot . 'vendor/autoload.php';
|
|
$app = new \think\App($serverRoot);
|
|
$app->initialize();
|
|
$cfg = (array) config('prescription_ai');
|
|
$endpoint = (new ReflectionMethod(\app\common\service\DifyChatService::class, 'buildEndpoint'))->invoke(null, $cfg['base_url'], 'parameters');
|
|
$out = [];
|
|
foreach (['qwen', 'openai'] as $model) {
|
|
$curl = curl_init($endpoint);
|
|
curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_CONNECTTIMEOUT => 5,
|
|
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $cfg['models'][$model]['api_key']]]);
|
|
$body = curl_exec($curl);
|
|
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
|
$decoded = is_string($body) ? json_decode($body, true) : [];
|
|
$files = (array) ($decoded['file_upload'] ?? []);
|
|
$image = (array) ($files['image'] ?? []);
|
|
$out[$model] = ['http_code' => $status, 'curl_errno' => curl_errno($curl),
|
|
'files' => array_intersect_key($files, array_flip(['enabled', 'number_limits', 'allowed_file_types', 'allowed_file_extensions', 'allowed_file_upload_methods'])),
|
|
'image' => array_intersect_key($image, array_flip(['enabled', 'number_limits', 'transfer_methods']))];
|
|
curl_close($curl);
|
|
}
|
|
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), PHP_EOL;
|