{"repo": "alumnisteman/management-pasar", "files": {"app/Services/AIService.php": {"54b6cd05346589c78108870e4d7c54177b2e794f": {"t": 1786067617.6117659, "n": 1984, "h": "7e5d713876226895", "c": "apiKey = env('DEEPSEEK_API_KEY');\n }\n\n /**\n * Generate an intelligent summary based on market data.\n */\n public function generateSummary($data)\n {\n if (empty($this->apiKey)) {\n Log::warning('AI Service: DEEPSEEK_API_KEY is not configured.');\n return \"AI Service Offline: Please configure API Key.\";\n }\n\n $prompt = \"You are an AI Market Analyst for SVMS Enterprise. Based on the following data, provide a professional, concise summary of the market's health and any critical actions needed.\\n\\n\" . json_encode($data);\n\n try {\n $response = Http::withToken($this->apiKey)\n ->post(\"{$this->baseUrl}/chat/completions\", [\n 'model' => 'deepseek-chat',\n 'messages' => [\n ['role' => 'system', 'content' => 'You are a helpful assistant.'],\n ['role' => 'user', 'content' => $prompt],\n ],\n 'stream' => false\n ]);\n\n if ($response->successful()) {\n return $response->json('choices.0.message.content');\n }\n\n Log::error('AI Service Error: ' . $response->body());\n return \"AI Analysis temporarily unavailable (API Error).\";\n } catch (\\Exception $e) {\n Log::error('AI Service Exception: ' . $e->getMessage());\n return \"AI Analysis Offline (Connection Error).\";\n }\n }\n\n /**\n * Get system status for diagnostics.\n */\n public function getStatus()\n {\n if (empty($this->apiKey)) {\n return 'offline';\n }\n\n return 'online';\n }\n}\n"}}}}