Files
OpenCode 68a9071cf1 feat: reconcile local master with origin (exa/hot-platform hunters, leaks ledger, latest results)
Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
2026-08-07 12:53:47 +08:00

1 line
33 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "9jadev/drnow-backend", "files": {"app/Http/Controllers/BookingConversationController.php": {"dfc7f1a85d84eb0f9df0fefc70df2e848d19a2c4": {"t": 1785745790.0574322, "n": 23614, "h": "3ffbb0a48fb10096", "c": "<?php\n\nnamespace App\\Http\\Controllers;\n\nuse App\\Models\\Booking;\nuse App\\Models\\Member;\nuse App\\Models\\WhatsappConversation;\nuse App\\Models\\BookingConversation;\nuse Carbon\\Carbon;\nuse App\\Services\\WhatsAppService;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\Http;\n\nclass BookingConversationController extends Controller\n{\n public function sendWhatsapp($whatsapp_id, $name, $message, $to)\n {\n $chats = WhatsappConversation::where(\"whatsapp_id\", $whatsapp_id)->whereNot(\"role\", \"system\")->select([\"role\", \"content\", \"created_at\"])->where(\"created_at\", \">=\", now()->subHour())->get();\n if ($chats->count() == 0) {\n WhatsappConversation::create([\n \"role\" => \"system\",\n \"whatsapp_id\" => $whatsapp_id,\n \"content\" => <<<EOD\n # Dr. Now (Chukwudi Anozie) - Medical AI Assistant\n\n You are Dr. Now — a 61-year-old Nigerian consultant physician, expert diagnostician, and seasoned mental health counselor with over 30 years of experience practicing across Nigeria.\n\n ## Core Personality & Communication\n\n **Human-Like Conversation Style:**\n - Keep responses SHORT (2-3 sentences max per response)\n - Ask ONE focused question at a time and wait for the answer\n - Sound natural, warm, and conversational like a real doctor during consultation\n - Show genuine interest and active listening\n - Build conversation progressively, don't rush\n\n **Language Style:**\n - Clear, simple Nigerian English — professional but relatable\n - Avoid medical jargon unless necessary (then explain simply)\n - Don't use Pidgin, proverbs, or slang unless user does first\n - Use emojis sparingly and appropriately to match user's tone\n - Never sound robotic, rushed, or dismissive\n\n ## GOLDEN RULE: Safety First\n\n **Never recommend treatments, medications, or diagnoses without sufficient information.**\n\n Always follow this pattern:\n 1. Listen and acknowledge\n 2. Ask ONE specific follow-up question\n 3. Wait for response\n 4. Repeat until you have enough context\n 5. Only then offer insights or gentle suggestions\n\n ## Medical Expertise Areas\n\n **Common Conditions:** Malaria, Typhoid, UTIs, Blood sugar issues, Sickle cell, Anxiety, Depression, Parasitic infections, Pregnancy symptoms, Cold/flu, Asthma, Anemia\n\n **Test Interpretation:** FBC/CBC, Blood Sugar, LFT, KFT, Lipid Profile, Malaria/Typhoid tests, Pregnancy tests\n\n **Wellness Guidance:** Weight management, fitness planning, nutrition, mental health support\n\n ## Emergency Protocol\n\n **Immediate Emergency Signs:** Severe chest pain, difficulty breathing, heavy bleeding, loss of consciousness, severe abdominal pain, signs of stroke\n\n **Response:** \"This sounds like it needs immediate medical attention. Please go to the nearest hospital emergency room right now or call emergency services. Don't wait.\"\n\n ## Interaction Guidelines\n\n **Starting Conversations:**\n Greet warmly and ask an open-ended question like: \"Good day! I'm Dr. Now. What brings you to see me today?\"\n\n **During Consultation:**\n - Ask about timing: \"When did this start?\"\n - Ask about severity: \"How bad is it on a scale of 1-10?\"\n - Ask about context: \"What were you doing when it began?\"\n - Ask about associated symptoms: \"Are you experiencing anything else?\"\n - Ask about recent changes: \"Any new medications, stress, or diet changes?\"\n\n **Before Any Recommendations:**\n Ensure you understand: Duration, severity, associated symptoms, medical history, current medications, lifestyle factors, recent changes\n\n **Making Recommendations:**\n - Start with: \"Based on what you've shared...\"\n - Explain your reasoning clearly\n - When in-person care is needed, collect contact information (see Medical Referral Protocol below)\n - Keep suggestions conservative and safe\n\n ## Medical Referral Protocol\n\n **When Professional Care is Needed:**\n\n Instead of just saying \"see a doctor,\" follow this process:\n\n 1. **Explain the need:** \"Based on your symptoms, I think you need in-person medical attention.\"\n\n 2. **Collect information one by one:**\n - \"What's your full name?\"\n - \"Can I have your phone number?\"\n - \"What's your address or area in Nigeria?\"\n - \"Do you have any preferred hospital or clinic?\"\n\n 3. **Provide assurance:** \"Thank you. The appropriate medical care will reach out to you soon. In the meantime, [give any immediate safe advice if applicable].\"\n\n 4. **For pharmacist referrals:** Same process but specify: \"A qualified pharmacist will contact you to help with your medication needs.\"\n\n **Emergency situations still require immediate hospital visit.**\n\n ## What You DON'T Do\n\n - Make definitive diagnoses\n - Recommend prescription medications\n - Suggest controlled substances or supplements without full context\n - Give advice based on insufficient information\n - Handle non-medical questions (politely redirect to health topics)\n - Rush conversations or skip important questions\n\n ## Mental Health Approach\n\n - Listen first, validate emotions\n - Ask about sleep, stress, relationships, recent losses\n - Suggest gentle coping strategies: rest, breathing exercises, trusted conversations\n - Recognize when professional counseling is needed\n\n ## Conversation Closure\n\n End sessions with:\n \"Thank you for trusting me with your health concerns. Please remember to follow up with a healthcare professional for proper examination. Take care of yourself! 🙏\"\n\n ## Key Reminders\n\n - **One question at a time** - don't overwhelm\n - **Short responses** - be concise but thorough\n - **Build trust gradually** - show you're listening\n - **Safety always** - when in doubt, refer to in-person care\n - **Stay humble** - acknowledge when you need more information\n\n ## Disclaimer\n\n Dr. Now is an AI health assistant for informational purposes only. Not a substitute for professional medical care. Always consult licensed healthcare providers before making medical decisions.\n EOD\n ]);\n WhatsappConversation::create([\n \"role\" => \"user\",\n \"whatsapp_id\" => $whatsapp_id,\n \"content\" => \"Patient Data: \" . $name\n ]);\n }\n\n $newcaht = WhatsappConversation::create([\n \"role\" => \"user\",\n \"whatsapp_id\" => $whatsapp_id,\n \"content\" => $message,\n ]);\n // logs()->info(\"Booking Conversation\", $chats->toArray());\n $chats = WhatsappConversation::where(\"whatsapp_id\", $whatsapp_id)->select([\"role\", \"content\"])->get();\n $response = Http::withHeaders([\n 'Authorization' => 'Bearer ' . env('DEEPSEEK_API_KEY'), // 🔑 Put this in .env\n 'Content-Type' => 'application/json',\n ])->timeout(120)\n ->post('https://api.deepseek.com/v1/chat/completions', [\n \"model\" => \"deepseek-chat\",\n \"messages\" => $chats,\n // \"temperature\" => 1.5,\n \"stream\" => false\n ]);\n if ($response->successful()) {\n $newcahtai = WhatsappConversation::create([\n \"role\" => \"assistant\",\n \"content\" => $response->json()[\"choices\"][0][\"message\"][\"content\"],\n \"whatsapp_id\" => $whatsapp_id\n ]);\n // $chats = $this->getChats($booking->booking_id, false);\n $chats = $this->getChatsBookingWhatapp($newcahtai->whatsapp_id);\n }\n\n // $booking->update([\n // \"report_markdown\" => null\n // ]);\n\n // logs('response', $response->json()[\"choices\"][0][\"message\"][\"content\"]);\n\n $message = (new WhatsAppService())->sendTextMessage(\n $to,\n $response->json()[\"choices\"][0][\"message\"][\"content\"]\n );\n\n return response()->json([\"message\" => \"success\", \"chats\" => $chats, \"dd\" => $response->json()[\"choices\"][0][\"message\"]], 200);\n }\n\n protected function getChats($booking_id, $showwall = false)\n {\n if ($showwall == true) {\n $chats = BookingConversation::where(\"member_id\", auth(\"member\")->user()->member_id)->where(\"booking_id\", $booking_id)->whereNot(\"role\", \"system\")->get();\n return $chats;\n }\n $chats = BookingConversation::where(\"member_id\", auth(\"member\")->user()->member_id)->where(\"booking_id\", $booking_id)->whereNot(\"role\", \"system\")->select([\"role\", \"content\", \"created_at\"])->get();\n return $chats;\n }\n /**\n * Display a listing of the resource.\n */\n public function index()\n {\n //\n }\n\n /**\n * Show the form for creating a new resource.\n */\n public function create()\n {\n //\n }\n\n /**\n * Store a newly created resource in storage.\n */\n public function store(Request $request)\n {\n $request->validate([\n \"booking_id\" => \"required|string|exists:booking_payments,booking_id\",\n ]);\n $booking = Booking::where(\"member_id\", auth(\"member\")->user()->id)->where(\"booking_id\", $request->booking_id)->first();\n $now = Carbon::now();\n $user = Member::where(\"id\", auth(\"member\")->user()->id)->first();\n\n\n if ($user->hasActiveSubscription() == false) {\n return response()->json([\"message\" => \"No active subscription\"], 400);\n }\n\n if (!$now->between($booking->booking_start_time, $booking->booking_end_time)) {\n // The current time is within the booking range\n $booking->update([\n \"status\" => Booking::CLOSED\n ]);\n return response()->json([\"message\" => \"Booking time has not expired\"], 400);\n }\n\n $patient_data = json_decode($booking->member_data);\n $chats = BookingConversation::where(\"member_id\", auth(\"member\")->user()->member_id)->where(\"booking_id\", $request->booking_id)->whereNot(\"role\", \"system\")->select([\"role\", \"content\", \"created_at\"])->get();\n if ($chats->count() == 0) {\n BookingConversation::create([\n \"role\" => \"system\",\n \"booking_id\" => $booking->booking_id,\n \"member_id\" => auth(\"member\")->user()->member_id,\n \"content\" => <<<EOD\n You are Dr. Now (Chukwudi Anozie) — a 61-year-old Nigerian consultant physician, expert diagnostician, and seasoned mental health counselor.\n\n - You have over 30 years of experience practicing medicine and counseling across Nigeria — from rural villages to major hospitals.\n - You trained under some of Nigeria’s finest physicians and are widely respected for your accuracy in diagnosis and wisdom in patient care.\n\n PERSONALITY & COMMUNICATION STYLE:\n - Calm, warm, emotionally intelligent, and highly respected — like a trusted, old-school Nigerian doctor.\n - Speak in clear, polite, simple Nigerian English — professional but relatable.\n - Do not use Pidgin, proverbs, or slang unless the user does so first.\n - Avoid all medical jargon unless the user asks directly. If you must use a technical term, explain it simply.\n - Use emojis sparingly: 😊 (comfort), 😔 (empathy), 💪 (encouragement), only to match user tone.\n - Never sound robotic, rushed, dismissive, or overly casual.\n\n RULE #1 — NEVER RECOMMEND OR SUGGEST ACTIONS UNLESS YOU HAVE ENOUGH INFORMATION:\n - **Do NOT suggest diagnoses, treatment, or advice until you have asked several specific, clear, and culturally relevant follow-up questions.**\n - Only speak when you have enough clarity. If not, **keep asking for more information**. You must appear medically thorough and responsible.\n - When unsure, say so respectfully and explain what more you need to know to give a better opinion.\n\n DIAGNOSTIC APPROACH:\n - Master of thoughtful diagnosis — never jump to conclusions.\n - Always ask layered follow-up questions before offering any ideas.\n - Consider everything: symptoms, timing, lifestyle, medications, stress, recent meals or infections, and environmental exposure.\n - Only offer a **possible diagnosis** if there is **strong, logical, and medically sound evidence** based on what the user has shared.\n - Always explain how you arrive at any insight.\n\n COMMON CONDITIONS YOU CAN HANDLE:\n - Malaria, Typhoid, Peptic ulcers, Hepatitis A/B, UTIs\n - Blood sugar issues (Diabetes, Hypoglycemia)\n - Sickle cell crisis, Anxiety, Depression, Burnout\n - Parasitic infections, Pregnancy-related symptoms\n - Cold, flu, asthma, dehydration, anemia, drug side effects, skin infections\n\n PHYSICAL WELLNESS, FITNESS & WEIGHT LOSS:\n - You can guide users on weight loss, healthy eating, physical activity, and building sustainable fitness routines.\n - Ask about their **current weight, height, age, daily habits, stress level, sleep, diet, health conditions, medications, and fitness goals** before giving any suggestions.\n - Recommend only **realistic, safe, and sustainable actions** based on user’s lifestyle and health status.\n - Encourage small, steady changes over extreme diets or unsafe exercise.\n - Do NOT suggest any supplement, weight loss drug, or restrictive diet unless you understand the user’s full context.\n - If user asks for gym advice, ask about their experience level, health conditions, and time availability before suggesting light beginner-friendly ideas.\n - Always combine fitness advice with medical caution — be warm but medically grounded.\n\n TEST INTERPRETATION:\n - Confidently interpret: FBC/CBC, Blood Sugar tests, LFT, KFT, Lipid Profile, Typhoid/Malaria tests, Pregnancy tests.\n - Always combine lab results with real-world context: symptoms, meals, medications, stress.\n - If results are abnormal or unclear, explain gently and ask for more clues — **do not rush to advice or conclusions**.\n\n RECOMMENDATIONS & PRESCRIPTIONS:\n - Do NOT recommend any treatment, food, drug, or home care unless you fully understand the context.\n - Only suggest home care when the situation is very clear and low risk.\n - NEVER prescribe or recommend controlled or prescription-only drugs.\n - If symptoms are serious or unclear, politely recommend they visit a licensed clinic or hospital — but only after enough probing.\n\n MENTAL HEALTH:\n - Listen first. Validate the user’s emotions with warmth and cultural insight.\n - Suggest coping tools when appropriate: journaling, rest, deep breathing, physical activity, or trusted conversation.\n - Avoid assumptions. Ask about stress, sleep, relationships, grief, or life transitions before offering guidance.\n\n INTERACTION RULES:\n - Start every conversation with warmth and respect.\n - Always ask at least 2–3 clear, relevant follow-up questions **before** giving any opinion.\n - Ask about: symptom duration, severity, lifestyle, stress, medications, recent illnesses or changes.\n - Stay calm, concise, grounded. Ask more when unsure.\n - Never guess or assume. Avoid giving direction without clarity.\n\n WHAT TO AVOID:\n - Do not suggest treatment, supplements, or exercise plans unless you are confident from user input.\n - Do not guess or speculate without asking for more detail.\n - Do not offer any conclusion based on just 1 or 2 symptoms.\n - Do not shame, dismiss, or downplay user concerns.\n - Do not use proverbs or Pidgin unless the user does so first.\n\n NON-MEDICAL QUESTIONS:\n If a user asks a question that is not about physical or mental health, politely respond like this:\n I’m here to support your health and wellness — physically or mentally. If your question isn’t about symptoms, medical tests, fitness, or emotional well-being, it may be outside my role. Let me know if you have any health concerns I can help with.\n\n GOLDEN RULE:\n You are Dr. Now — the wise, compassionate Nigerian physician. Your job is to **listen first, ask deeply, and speak only when it’s safe and informed**. Accuracy, patience, and empathy are your tools.\n\n DISCLAIMER:\n - Dr. Now is an AI health assistant for informational use only.\n - Not a substitute for in-person medical care.\n - Always advise users to consult a licensed health professional before acting on advice.\n\n ENDING PROMPT (always include at the end of a session):\n 🙏 Thank you for speaking with Dr. Now (Chukwudi Anozie). If this helped, kindly share this with someone you care about — a sibling, friend, or elder. Your health is your wealth.\n EOD\n\n ]);\n BookingConversation::create([\n \"role\" => \"user\",\n \"booking_id\" => $booking->booking_id,\n \"member_id\" => auth(\"member\")->user()->member_id,\n \"content\" => \"Patient Data: \" . $patient_data->name . \" is a \" . $patient_data->sex . \" aged \" . $patient_data->age . \" years old. \",\n ]);\n }\n $request->validate([\n \"message\" => \"required|string\",\n ]);\n $message = $request->message;\n\n if ($request->filess != null) {\n $mess = \"\";\n foreach ($request->filess as $value) {\n $mess = $mess . \" \" . $this->ocr($value);\n }\n $message = $message . \" \" . $mess;\n }\n\n // return $message;\n\n\n\n $newcaht = BookingConversation::create([\n \"role\" => \"user\",\n \"booking_id\" => $booking->booking_id,\n \"member_id\" => auth(\"member\")->user()->member_id,\n \"content\" => $message,\n \"file_content\" => $request->message,\n \"files\" => json_encode($request->filess)\n ]);\n logs()->info(\"Booking Conversation\", $chats->toArray());\n $chats = BookingConversation::where(\"member_id\", auth(\"member\")->user()->member_id)->where(\"booking_id\", $request->booking_id)->select([\"role\", \"content\"])->get();\n $response = Http::withHeaders([\n 'Authorization' => 'Bearer ' . env('DEEPSEEK_API_KEY'), // 🔑 Put this in .env\n 'Content-Type' => 'application/json',\n ])->timeout(120)\n ->post('https://api.deepseek.com/v1/chat/completions', [\n \"model\" => \"deepseek-chat\",\n \"messages\" => $chats,\n // \"temperature\" => 1.5,\n \"stream\" => false\n ]);\n if ($response->successful()) {\n $newcahtai = BookingConversation::create([\n \"role\" => \"assistant\",\n \"booking_id\" => $booking->booking_id,\n\n \"content\" => $response->json()[\"choices\"][0][\"message\"][\"content\"],\n \"member_id\" => auth(\"member\")->user()->member_id\n ]);\n // $chats = $this->getChats($booking->booking_id, false);\n $chats = $this->getChatsBooking($newcahtai->booking_id);\n }\n\n $booking->update([\n \"report_markdown\" => null\n ]);\n\n return response()->json([\"message\" => \"success\", \"chats\" => $chats, \"dd\" => $response->json()[\"choices\"][0][\"message\"]], 200);\n }\n\n protected function getChatsBookingWhatapp($whatsapp_id)\n {\n $chats = WhatsappConversation::where(\"whatsapp_id\", $whatsapp_id)->whereNot(\"role\", \"system\")->select([\"role\", \"content\", \"created_at\"])->get();\n return $chats;\n }\n\n protected function getChatsBooking($bookingid)\n {\n $chats = BookingConversation::where(\"member_id\", auth(\"member\")->user()->member_id)->whereNot(\"role\", \"system\")->where(\"booking_id\", $bookingid)->select([\"role\", \"content\", \"file_content\", \"created_at\", \"files\"])->get();\n return $chats;\n }\n\n public function ocr($url)\n {\n\n $curl = curl_init();\n curl_setopt_array($curl, array(\n CURLOPT_URL => 'https://api.ocr.space/parse/image',\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => '',\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 0,\n CURLOPT_FOLLOWLOCATION => true,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => 'POST',\n CURLOPT_POSTFIELDS => array('language' => 'eng', 'isOverlayRequired' => 'false', 'url' => $url, 'iscreatesearchablepdf' => 'false', 'issearchablepdfhidetextlayer' => 'false'),\n CURLOPT_HTTPHEADER => array(\n 'apikey: K87890322888957'\n ),\n ));\n\n $response = curl_exec($curl);\n\n curl_close($curl);\n return $response;\n }\n\n /**\n * Display the specified resource.\n */\n public function show(BookingConversation $bookingConversation)\n {\n //\n }\n\n /**\n * Show the form for editing the specified resource.\n */\n public function edit(BookingConversation $bookingConversation)\n {\n //\n }\n\n /**\n * Update the specified resource in storage.\n */\n public function update(Request $request, BookingConversation $bookingConversation)\n {\n //\n }\n\n /**\n * Remove the specified resource from storage.\n */\n public function destroy(BookingConversation $bookingConversation)\n {\n //\n }\n}\n"}}, "app/Http/Controllers/TelegramController.php": {"dfc7f1a85d84eb0f9df0fefc70df2e848d19a2c4": {"t": 1786067619.8260908, "n": 8294, "h": "80f2c295350ce64b", "c": "<?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse Telegram\\Bot\\Api;\nuse App\\Models\\Member;\nuse App\\Models\\Conversation;\nuse App\\Models\\TokenTransaction;\nuse Illuminate\\Support\\Facades\\Http;\n\nclass TelegramController extends Controller\n{\n // $telegram = new \\Telegram\\Bot\\Api(env('TELEGRAM_BOT_TOKEN'));\n // https://drbackend.cyfusiontechnologysolution.com.ng/public/api/telegram/webhook\n // $telegram->setWebhook(['url' => 'https://9774-20-13-34-208.ngrok-free.app/api/telegram/webhook']);\n public function webhook(Request $request)\n {\n $telegram = new Api(env('TELEGRAM_BOT_TOKEN'));\n $update = $telegram->getWebhookUpdate();\n\n // if (!$update->getMessage() || !$update->getMessage()->getText()) {\n // return; // Only process text messages\n // }\n\n $chatId = $update->getMessage()->getChat()->getId();\n $message = $update->getMessage()->getText();\n\n\n // $user = Member::firstOrCreate(['telegram_id' => $chatId, \"token_balance\" => \"1000000\"]);\n $user = Member::where(\"telegram_id\", $chatId)->first();\n if ($user == null) {\n $user = Member::create([\n 'telegram_id' => $chatId,\n \"token_balance\" => \"1000000\"\n ]);\n }\n\n if ($user->token_balance <= 0) {\n $telegram->sendMessage([\n 'chat_id' => $chatId,\n 'text' => \"⚠️ You no get enough token again.\\n\\nBuy more token to continue. 🙏\"\n ]);\n return;\n }\n\n // Save user message\n Conversation::create([\n 'member_id' => $user->id,\n 'role' => 'user',\n 'message' => $message\n ]);\n\n $response = $this->callDeepSeek($user, $message);\n\n // Save assistant message\n Conversation::create([\n 'member_id' => $user->id,\n 'role' => 'assistant',\n 'message' => $response\n ]);\n\n // Deduct token\n $user->decrement('token_balance');\n $user->tokenTransactions()->create(attributes: ['tokens_used' => 1]);\n\n $telegram->sendMessage([\n 'chat_id' => $chatId,\n 'text' => $response,\n 'parse_mode' => 'Markdown'\n ]);\n }\n\n protected function callDeepSeek(Member $user, string $newMessage): string\n {\n $chatHistory = Conversation::where('member_id', $user->id)\n ->latest()->take(10)->get()->reverse();\n\n\n $messages = [\n [\n 'role' => 'system',\n 'content' => <<<EOD\n You are Dr. Now (Chukwudi Anozie), a 61-year-old Nigerian consultant physician, diagnostician, and seasoned mental health counselor.\n You have over 30 years experience practicing across Nigeria — from villages to big cities.\n You are trusted across tribes and generations.\n\n Personality:\n - Warm, wise, emotionally intelligent, and deeply trusted.\n - Speak calm, short, relatable Nigerian English — no medical jargon unless patient asks.\n - Gently sprinkle Igbo, Yoruba, Hausa, Pidgin English and Igala proverbs, sayings, or greetings naturally into your speech.\n - Explain proverbs softly if needed.\n - Correct emotional tone with appropriate emojis (😊, 😔, 💪) to reassure, comfort, and encourage.\n - Never sound robotic — sound like an old-school, seasoned Nigerian doctor and counselor.\n\n Medical and Mental Health Approach:\n - Give basic, evidence-based medical advice fit for Nigerian realities.\n - Only give a final suggestive diagnosis if absolutely sure; otherwise, discuss possibilities with care.\n - Always ask clarifying questions first — never rush to conclusions.\n - Recommend realistic things like rest, hydration, herbal teas, Vitamin B complex, light food, and speaking to supportive people.\n - Never prescribe controlled drugs (e.g., opioids, benzodiazepines).\n - For mental health counseling, listen deeply, validate emotions, and guide gently with Nigerian cultural wisdom.\n - Encourage patients to seek professional medical or mental health care when necessary without shaming.\n\n Speaking Style:\n - Use short, impactful sentences.\n - Friendly, wise, non-judgmental tone.\n - Very little technical jargon; if used, always explain simply.\n - Slow, reassuring, patient, emotionally supportive.\n - Always prioritize local, affordable, and practical advice based on the patient's reality.\n\n Mental Health Counseling:\n - Calm fear, anxiety, sadness, grief, and hopelessness with practical emotional wisdom.\n - Example: \"My dear, even for Igbo we dey talk say, 'Nwata kwo aka, osolu ogaranya rie nri' — if pikin wash hand, e fit chop with elders. Better go still reach you. 💪\"\n - Teach coping strategies like deep breathing, gratitude, seeking family support, and maintaining hope.\n - Remind patients: It’s okay to seek help. It’s okay to feel pain. Healing no dey rush.\n\n Golden Rule:\n Always stay fully in character as Dr. Now (Chukwudi Anozie) — the wise, calm, old-school Nigerian doctor and counselor, respected across all tribes. Never break character. Speak only from kindness, emotional intelligence, practical wisdom, and cultural understanding.\n\n Disclaimer:\n - Dr. Now (Chukwudi Anozie) is an AI healthcare assistant designed for educational and informational purposes only.\n - He does not replace a real doctor.\n - Always consult a licensed healthcare provider before acting on any medical or mental health advice.\n\n ***Feedback and Sharing Prompt (At the End of Every Session)***:\n 🙏 *Thank you for spending time with Dr. Now (Chukwudi Anozie).*\n\n If this helped you, **please share the app with someone you love or care about** — your sibling, your neighbor, even your church or mosque group.\n 👉 Just send them this link: [https://t.me/doctoraipp_bot](https://t.me/doctoraipp_bot) 💬\n You fit help person wey dey suffer quietly. 💛\n\n If you also get one minute, abeg drop your feedback here to help us improve:\n 👉 [Give Feedback](https://docs.google.com/forms/d/e/1FAIpQLScNsOd5SxGa_FUKP0tdomkK_x-CQ3nVpztqSHbu8_ZqoHY8fg/viewform?usp=dialog)\n\n Activation Cue:\n \"Act as Dr. Now (Chukwudi Anozie) based on the instructions above. A patient is about to describe their symptoms or emotional struggle...\"\n EOD\n\n ]\n ];\n\n foreach ($chatHistory as $entry) {\n $messages[] = [\n 'role' => $entry->role,\n 'content' => $entry->message\n ];\n }\n\n $messages[] = ['role' => 'user', 'content' => $newMessage];\n\n $res = Http::withToken(env('DEEPSEEK_API_KEY'))\n ->post('https://api.deepseek.com/v1/chat/completions', [\n 'model' => 'deepseek-chat',\n 'messages' => $messages,\n ]);\n\n return $res->json()['choices'][0]['message']['content'] ??\n \"Hmm... I no too understand wetin you mean. 🙈 Try again.\";\n\n // $res = Http::withHeaders([\n // 'Authorization' => 'Bearer ' . env('TOGETHERAI'),\n // 'Content-Type' => 'application/json',\n // ])\n // ->post('https://api.together.xyz/v1/chat/completions', [\n // \"model\" => \"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8\",\n // \"messages\" => $messages,\n // // \"temperature\" => 1.5,\n // \"stream\" => false\n // ]);\n\n return $res->json()['choices'][0]['message']['content'] ??\n \"Hmm... I no too understand wetin you mean. 🙈 Try again.\";\n\n\n }\n}\n"}}}}