prompts->render('vision_analyze'); $response = $this->ollama->generateWithImage($this->model, $prompt, $imagePath); return [ 'manufacturer' => $this->extractField($response, 'MANUFACTURER'), 'modelName' => $this->extractField($response, 'MODEL_NAME'), 'modelNumber' => $this->extractField($response, 'MODEL_NUMBER'), 'serial' => $this->extractField($response, 'SERIAL'), ]; } private function extractField(string $response, string $field): string { if (!preg_match('/^'.$field.':\s*(.*)$/m', $response, $matches)) { return ''; } $value = trim($matches[1]); // Strip any embedded field label the model mistakenly included (e.g. "SERIAL: PNV09SJZ") $value = preg_replace('/\s+[A-Z_]+:.*$/i', '', $value) ?? $value; return trim($value); } }