where('id', 1)->where('prescription_id', 7556)->find(); $context = $cipher->decrypt($batch['context_cipher'], 'context'); $types = $hosts = $missing = []; $sendable = []; foreach ($context['files'] as $file) { $type = (string) ($file['type'] ?? 'unknown'); $types[$type] = ($types[$type] ?? 0) + 1; $host = (string) (parse_url((string) ($file['url'] ?? ''), PHP_URL_HOST) ?: '(none)'); $hosts[$host] = ($hosts[$host] ?? 0) + 1; if ($file['status'] !== 'restricted' && !empty($file['url'])) { $sendable[] = $file; } } $normalization = []; foreach (array_chunk($sendable, 3) as $files) { $wire = array_map(static fn (array $f): array => ['type' => $f['type'], 'url' => $f['url'], 'transfer_method' => 'remote_url'], $files); $value = (new ReflectionMethod(\app\common\service\DifyChatService::class, 'normalizeFiles'))->invoke(null, $wire, 3); $normalization[] = ['input' => count($wire), 'kept' => count($value['kept']), 'over_limit' => count($value['dropped'])]; } foreach ($context['missing'] ?? [] as $item) { $code = (string) ($item['code'] ?? 'unknown'); $missing[$code] = ($missing[$code] ?? 0) + 1; } echo json_encode(['source_shape_only' => [ 'attachment_types' => $types, 'attachment_hosts' => $hosts, 'missing_codes' => $missing, 'attachment_batch_normalization' => $normalization, 'max_files' => config('prescription_ai.max_files'), 'timeout' => config('prescription_ai.timeout'), ]], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), PHP_EOL;