Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/bonboniskvira_vibenote.json
T

1 line
9.2 KiB
JSON

{"repo": "bonboniskvira/vibenote", "files": {"app/Services/DeepSeekService.php": {"7618acf0764e718a54e8a8b5d3a54c4310aff888": {"t": 1785746145.3240097, "n": 4390, "h": "3dac1f01dd32a664", "c": "<?php\n\nnamespace App\\Services;\n\nuse Illuminate\\Support\\Facades\\Http;\nuse Illuminate\\Support\\Facades\\Log;\n\nclass DeepSeekService\n{\n private string $apiKey;\n\n private string $apiUrl = 'https://api.deepseek.com/v1/chat/completions';\n\n public function __construct()\n {\n $this->apiKey = config('services.deepseek.api_key', '');\n }\n\n public function extractNoteData(string $rawText): array\n {\n if (empty($this->apiKey)) {\n return $this->fallbackExtract($rawText);\n }\n\n $prompt = <<<PROMPT\nYou are a note-processing assistant. Extract structured data from the following raw voice note.\n\nReturn ONLY valid JSON with these fields:\n- \"note\": A clean, formatted version of the note. Make it scannable and ADHD-friendly: use bullet points, short sentences, bold key info.\n- \"event_title\": If there's an event, meeting, appointment, or reminder mentioned, extract its title. Otherwise null.\n- \"event_date\": If an event date/time is mentioned, return it as ISO 8601 datetime string (e.g. \"2026-04-28T15:00:00\"). Otherwise null.\n- \"has_event\": boolean, true if an event/reminder is detected.\n\nRaw note: \"\"\"{$rawText}\"\"\"\nPROMPT;\n\n try {\n $response = Http::withHeaders([\n 'Authorization' => \"Bearer {$this->apiKey}\",\n 'Content-Type' => 'application/json',\n ])->post($this->apiUrl, [\n 'model' => 'deepseek-chat',\n 'messages' => [\n [\n 'role' => 'system',\n 'content' => 'You extract structured JSON from voice notes. Return ONLY valid JSON, no markdown, no explanation.',\n ],\n [\n 'role' => 'user',\n 'content' => $prompt,\n ],\n ],\n 'temperature' => 0.1,\n 'max_tokens' => 512,\n ]);\n\n if ($response->successful()) {\n $content = $response->json('choices.0.message.content');\n $content = trim($content);\n $content = preg_replace('/^```(?:json)?\\s*|\\s*```$/', '', $content);\n\n $data = json_decode($content, true);\n if (json_last_error() !== JSON_ERROR_NONE) {\n Log::warning('DeepSeek returned invalid JSON', [\n 'raw' => $content,\n 'error' => json_last_error_msg(),\n ]);\n return $this->fallbackExtract($rawText);\n }\n\n return $data;\n }\n\n Log::warning('DeepSeek API error', [\n 'status' => $response->status(),\n 'body' => $response->body(),\n ]);\n } catch (\\Exception $e) {\n Log::error('DeepSeek API exception', ['message' => $e->getMessage()]);\n }\n\n return $this->fallbackExtract($rawText);\n }\n\n private function fallbackExtract(string $rawText): array\n {\n $eventDate = null;\n $hasEvent = false;\n\n if (preg_match('/\\b(\\d{1,2})[\\/\\-](\\d{1,2})(?:[\\/\\-](\\d{2,4}))?\\s*(?:at\\s*)?(\\d{1,2}):?(\\d{2})\\s*(am|pm)?\\b/i', $rawText, $matches)) {\n $hasEvent = true;\n }\n\n if (preg_match('/(?:tomorrow|next\\s+\\w+|monday|tuesday|wednesday|thursday|friday|saturday|sunday)/i', $rawText)) {\n $hasEvent = true;\n }\n\n $cleaned = preg_replace('/^(remind me to|reminder|note|i need to|don\\'t forget to)\\s+/i', '', $rawText);\n $cleaned = ucfirst(trim($cleaned));\n\n return [\n 'note' => $cleaned,\n 'event_title' => $hasEvent ? $this->extractTitle($rawText) : null,\n 'event_date' => $eventDate,\n 'has_event' => $hasEvent,\n ];\n }\n\n private function extractTitle(string $rawText): ?string\n {\n $patterns = [\n '/remind me (?:to|about)\\s+(.+?)(?:\\s+(?:tomorrow|next|at|on|in|this|the))/i',\n '/reminder\\s+(?:for|about)?\\s*(.+?)(?:\\s+(?:tomorrow|next|at|on|in))/i',\n '/(?:meeting|appointment|call|event)\\s+(?:with|for|about)?\\s*(.+?)(?:\\s+(?:tomorrow|next|at|on|in))/i',\n ];\n\n foreach ($patterns as $pattern) {\n if (preg_match($pattern, $rawText, $m)) {\n return trim($m[1]);\n }\n }\n\n return 'Reminder';\n }\n}\n"}, "584b6b2ea46f6324a85ac847178c8ad9a81ad616": {"t": 1785760155.5798645, "n": 4390, "h": "3dac1f01dd32a664", "c": "<?php\n\nnamespace App\\Services;\n\nuse Illuminate\\Support\\Facades\\Http;\nuse Illuminate\\Support\\Facades\\Log;\n\nclass DeepSeekService\n{\n private string $apiKey;\n\n private string $apiUrl = 'https://api.deepseek.com/v1/chat/completions';\n\n public function __construct()\n {\n $this->apiKey = config('services.deepseek.api_key', '');\n }\n\n public function extractNoteData(string $rawText): array\n {\n if (empty($this->apiKey)) {\n return $this->fallbackExtract($rawText);\n }\n\n $prompt = <<<PROMPT\nYou are a note-processing assistant. Extract structured data from the following raw voice note.\n\nReturn ONLY valid JSON with these fields:\n- \"note\": A clean, formatted version of the note. Make it scannable and ADHD-friendly: use bullet points, short sentences, bold key info.\n- \"event_title\": If there's an event, meeting, appointment, or reminder mentioned, extract its title. Otherwise null.\n- \"event_date\": If an event date/time is mentioned, return it as ISO 8601 datetime string (e.g. \"2026-04-28T15:00:00\"). Otherwise null.\n- \"has_event\": boolean, true if an event/reminder is detected.\n\nRaw note: \"\"\"{$rawText}\"\"\"\nPROMPT;\n\n try {\n $response = Http::withHeaders([\n 'Authorization' => \"Bearer {$this->apiKey}\",\n 'Content-Type' => 'application/json',\n ])->post($this->apiUrl, [\n 'model' => 'deepseek-chat',\n 'messages' => [\n [\n 'role' => 'system',\n 'content' => 'You extract structured JSON from voice notes. Return ONLY valid JSON, no markdown, no explanation.',\n ],\n [\n 'role' => 'user',\n 'content' => $prompt,\n ],\n ],\n 'temperature' => 0.1,\n 'max_tokens' => 512,\n ]);\n\n if ($response->successful()) {\n $content = $response->json('choices.0.message.content');\n $content = trim($content);\n $content = preg_replace('/^```(?:json)?\\s*|\\s*```$/', '', $content);\n\n $data = json_decode($content, true);\n if (json_last_error() !== JSON_ERROR_NONE) {\n Log::warning('DeepSeek returned invalid JSON', [\n 'raw' => $content,\n 'error' => json_last_error_msg(),\n ]);\n return $this->fallbackExtract($rawText);\n }\n\n return $data;\n }\n\n Log::warning('DeepSeek API error', [\n 'status' => $response->status(),\n 'body' => $response->body(),\n ]);\n } catch (\\Exception $e) {\n Log::error('DeepSeek API exception', ['message' => $e->getMessage()]);\n }\n\n return $this->fallbackExtract($rawText);\n }\n\n private function fallbackExtract(string $rawText): array\n {\n $eventDate = null;\n $hasEvent = false;\n\n if (preg_match('/\\b(\\d{1,2})[\\/\\-](\\d{1,2})(?:[\\/\\-](\\d{2,4}))?\\s*(?:at\\s*)?(\\d{1,2}):?(\\d{2})\\s*(am|pm)?\\b/i', $rawText, $matches)) {\n $hasEvent = true;\n }\n\n if (preg_match('/(?:tomorrow|next\\s+\\w+|monday|tuesday|wednesday|thursday|friday|saturday|sunday)/i', $rawText)) {\n $hasEvent = true;\n }\n\n $cleaned = preg_replace('/^(remind me to|reminder|note|i need to|don\\'t forget to)\\s+/i', '', $rawText);\n $cleaned = ucfirst(trim($cleaned));\n\n return [\n 'note' => $cleaned,\n 'event_title' => $hasEvent ? $this->extractTitle($rawText) : null,\n 'event_date' => $eventDate,\n 'has_event' => $hasEvent,\n ];\n }\n\n private function extractTitle(string $rawText): ?string\n {\n $patterns = [\n '/remind me (?:to|about)\\s+(.+?)(?:\\s+(?:tomorrow|next|at|on|in|this|the))/i',\n '/reminder\\s+(?:for|about)?\\s*(.+?)(?:\\s+(?:tomorrow|next|at|on|in))/i',\n '/(?:meeting|appointment|call|event)\\s+(?:with|for|about)?\\s*(.+?)(?:\\s+(?:tomorrow|next|at|on|in))/i',\n ];\n\n foreach ($patterns as $pattern) {\n if (preg_match($pattern, $rawText, $m)) {\n return trim($m[1]);\n }\n }\n\n return 'Reminder';\n }\n}\n"}}}}