<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: IshqDehlvi</title>
    <description>The latest articles on DEV Community by IshqDehlvi (@ishqdehlvi).</description>
    <link>https://dev.to/ishqdehlvi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F829868%2Fe46f72f5-5eec-40c9-859e-18ec968b86c2.jpeg</url>
      <title>DEV Community: IshqDehlvi</title>
      <link>https://dev.to/ishqdehlvi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ishqdehlvi"/>
    <language>en</language>
    <item>
      <title>The architecture of persistent AI memory: Beyond simple vector search</title>
      <dc:creator>IshqDehlvi</dc:creator>
      <pubDate>Wed, 25 Mar 2026 18:22:22 +0000</pubDate>
      <link>https://dev.to/ishqdehlvi/the-architecture-of-persistent-ai-memory-beyond-simple-vector-search-35hb</link>
      <guid>https://dev.to/ishqdehlvi/the-architecture-of-persistent-ai-memory-beyond-simple-vector-search-35hb</guid>
      <description>&lt;p&gt;Most RAG implementations are lazy. Developers just throw embeddings into a vector database and hope for the best. That is not how you build a production-grade AI agent with long-term memory.&lt;/p&gt;

&lt;p&gt;The standard approach of &lt;strong&gt;100% semantic similarity is fundamentally flawed&lt;/strong&gt;. It lacks the human element of situational awareness and chronological priority.&lt;/p&gt;

&lt;p&gt;If a user mentioned their favorite coffee once three years ago, but just told the AI about a critical life event ten minutes ago, a basic vector search treats them with equal weight — if the "coffee" embedding happens to be a closer match to the current query.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Built Instead
&lt;/h2&gt;

&lt;p&gt;I solved this in the &lt;a href="https://wtmf.ai" rel="noopener noreferrer"&gt;https://wtmf.ai&lt;/a&gt; codebase by implementing a &lt;strong&gt;Hybrid Scoring Algorithm&lt;/strong&gt; in our memory-context utility.&lt;/p&gt;

&lt;p&gt;We moved away from a singular focus on cosine similarity and engineered a &lt;strong&gt;multi-dimensional ranking system&lt;/strong&gt; that weighs context like a biological brain would.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Scoring Model Breakdown
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Semantic Similarity (70%)
&lt;/h3&gt;

&lt;p&gt;We use &lt;code&gt;OpenAI text-embedding-3-small&lt;/code&gt; and &lt;code&gt;pgvector&lt;/code&gt; to handle the heavy lifting of conceptual matching.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1536 dimensions of context provide the foundation
&lt;/li&gt;
&lt;li&gt;But they are no longer the final word
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Recency Decay (15%)
&lt;/h3&gt;

&lt;p&gt;We implemented a &lt;strong&gt;time-decay function directly in the SQL query&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calculates the epoch difference between now and the memory's creation date
&lt;/li&gt;
&lt;li&gt;Exponentially boosts anything from the last 30 days
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensures that the AI stays &lt;strong&gt;"in the moment"&lt;/strong&gt; and doesn't hallucinate context from months-old conversations.&lt;/p&gt;




&lt;h3&gt;
  
  
  Explicit Importance (15%)
&lt;/h3&gt;

&lt;p&gt;Not all sentences are created equal.&lt;/p&gt;

&lt;p&gt;During memory extraction, we assign an &lt;strong&gt;importance score&lt;/strong&gt; based on the critical nature of the information.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User’s name or medical allergy → High importance
&lt;/li&gt;
&lt;li&gt;Casual comment about the weather → Low importance
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensures &lt;strong&gt;high-impact data resurfaces&lt;/strong&gt;, regardless of semantic proximity or age.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Outcome
&lt;/h2&gt;

&lt;p&gt;The result is a memory recall system where the AI doesn't just &lt;strong&gt;retrieve&lt;/strong&gt; data — it &lt;strong&gt;prioritizes&lt;/strong&gt; it.&lt;/p&gt;

&lt;p&gt;It understands that human context is a mix of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What you said
&lt;/li&gt;
&lt;li&gt;When you said it
&lt;/li&gt;
&lt;li&gt;How much it actually matters
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;p&gt;This is the difference between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A chatbot that reads a database
&lt;/li&gt;
&lt;li&gt;And an agent that actually remembers you
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Stop building basic RAG. Start engineering memory.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>architecture</category>
      <category>rag</category>
    </item>
    <item>
      <title>Architecting a Real-Time Crisis Intervention Layer for AI Chats</title>
      <dc:creator>IshqDehlvi</dc:creator>
      <pubDate>Tue, 24 Mar 2026 11:55:34 +0000</pubDate>
      <link>https://dev.to/ishqdehlvi/architecting-a-real-time-crisis-intervention-layer-for-ai-chats-4pjd</link>
      <guid>https://dev.to/ishqdehlvi/architecting-a-real-time-crisis-intervention-layer-for-ai-chats-4pjd</guid>
      <description>&lt;p&gt;I believe that as AI developers, our responsibility extends beyond just shipping features. We are building systems that interact with humans in their most vulnerable moments.&lt;/p&gt;

&lt;p&gt;I recently implemented a critical safety module for my platform, WTMF (&lt;a href="https://wtmf.ai/" rel="noopener noreferrer"&gt;https://wtmf.ai/&lt;/a&gt;), that detects and intervenes during crises, specifically focusing on self-harm and suicidal ideation. &lt;/p&gt;

&lt;p&gt;In this post, I will break down the multi-layer architecture I built to handle these sensitive situations with zero latency and high empathy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Strategy: Detect, Flag, and Re-Steer
&lt;/h2&gt;

&lt;p&gt;A standard AI response might not be sufficient when a user expresses distress. My solution involves three core layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identification: High-speed pattern matching for distress signals.&lt;/li&gt;
&lt;li&gt;Behavioral Transformation: Dynamic modification of the LLM's system prompt on the fly.&lt;/li&gt;
&lt;li&gt;Administrative Visibility: Persistent database flagging for human review.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. High-Precision Crisis Detection
&lt;/h2&gt;

&lt;p&gt;I avoided complex asynchronous NLP models for the initial detection to ensure zero latency. Instead, I used a battle-tested regular expression approach that flags the session immediately.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;selfHarmRegex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\b(&lt;/span&gt;&lt;span class="sr"&gt;suicide|kill myself|end my life|want to die|self harm|cut myself|overdose|jump off|hang myself|hurt myself|no reason to live|slit|slit my wrists|knife&lt;/span&gt;&lt;span class="se"&gt;)\b&lt;/span&gt;&lt;span class="sr"&gt;/i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isSelfHarm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;selfHarmRegex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Dynamic LLM Re-Steering
&lt;/h2&gt;

&lt;p&gt;The most impactful part of this module is how it changes the AI's behavior. When a distress signal is detected, I don't just block the message. I re-steer the AI.&lt;/p&gt;

&lt;p&gt;I dynamically inject a CRITICAL INSTRUCTION into the LLM's system prompt. This ensures that the response isn't just about the persona, but about human safety.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isSelfHarm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;systemPrompt&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="s2"&gt;CRITICAL INSTRUCTION: The user has expressed thoughts of self-harm or suicide. You MUST be extremely supportive, empathetic, and gently encourage them to seek professional help or connect with loved ones. Do not give medical advice, but be a gentle, safe space for them.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This transforms the AI from a standard assistant into a supportive, empathetic listener that prioritizes life over logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Persistent Safety Flagging
&lt;/h2&gt;

&lt;p&gt;Finally, the session is flagged in the backend database. This allows administrators to prioritize these sessions for human intervention and support.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isSelfHarm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;updateData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isFlagged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;updateData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flagReason&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;self_harm&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chats&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;updateData&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building with AI is powerful, but building with safety is essential. I am committed to ensuring that WTMF doesn't just process data, but handles human emotions with the care they deserve.&lt;/p&gt;

&lt;p&gt;Check out WTMF: &lt;a href="https://wtmf.ai/" rel="noopener noreferrer"&gt;https://wtmf.ai/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What safety layers are you building into your AI projects? I would love to hear your thoughts in the comments.&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>node</category>
      <category>safety</category>
      <category>openai</category>
    </item>
    <item>
      <title>How HarGharPG Is Digitizing PG Management in India</title>
      <dc:creator>IshqDehlvi</dc:creator>
      <pubDate>Thu, 22 Jan 2026 08:40:17 +0000</pubDate>
      <link>https://dev.to/ishqdehlvi/how-hargharpg-is-digitizing-pg-management-in-india-14lb</link>
      <guid>https://dev.to/ishqdehlvi/how-hargharpg-is-digitizing-pg-management-in-india-14lb</guid>
      <description>&lt;p&gt;Managing a Paying Guest (PG) or co-living space in India involves juggling tenants, bed inventory, rent cycles, notices, mess menus, KYC documents, and more. Traditionally, many owners handle this with Excel sheets, paper registers, or scattered WhatsApp messages — which quickly becomes chaotic.&lt;/p&gt;

&lt;p&gt;In this post, I’m breaking down what &lt;a href="https://hargharpg.com/" rel="noopener noreferrer"&gt;HarGharPG&lt;/a&gt; is, what it does, and how it helps PG owners run their business more efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 What Is HarGharPG?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://hargharpg.com/" rel="noopener noreferrer"&gt;HarGharPG&lt;/a&gt; is a PG management software and web app designed specifically for Indian PG and co-living operators. It helps owners automate daily operations like tenant records, rent collection, occupancy tracking, invoicing, and communication — all from a unified dashboard.&lt;/p&gt;

&lt;p&gt;HarGharPG is positioned as one of India’s top PG management solutions, trusted by owners across multiple cities and properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠 Core Things HarGharPG Helps You Do
&lt;/h2&gt;

&lt;p&gt;✅ 1. Manage Rooms &amp;amp; Beds&lt;/p&gt;

&lt;p&gt;Set up floors, rooms, and beds with real-time occupancy tracking — critical for shared living spaces.&lt;/p&gt;

&lt;p&gt;✅ 2. Tenant Management&lt;/p&gt;

&lt;p&gt;Record tenant details, KYC documents, and allocation to specific beds. You can easily search and filter tenant profiles.&lt;/p&gt;

&lt;p&gt;✅ 3. Rent &amp;amp; Revenue Tracking&lt;/p&gt;

&lt;p&gt;Track monthly rent payments and dues, record paid amounts, and view overall revenue metrics. Automated reminders can be sent to tenants via WhatsApp or email.&lt;/p&gt;

&lt;p&gt;✅ 4. Billing &amp;amp; Invoices&lt;/p&gt;

&lt;p&gt;Generate professional, GST-compliant invoices for tenants and share them electronically.&lt;/p&gt;

&lt;p&gt;✅ 5. Multi-Language Support&lt;/p&gt;

&lt;p&gt;The platform supports major Indian regional languages so owners and tenants can use the system in their preferred language.&lt;/p&gt;

&lt;p&gt;✅ 6. Public PG Microsite&lt;/p&gt;

&lt;p&gt;Each property gets a tenant-facing site to view notices, mess menus, PG rules, and submit support requests — all under a custom subdomain.&lt;/p&gt;

&lt;p&gt;✅ 7. Central Dashboard &amp;amp; Analytics&lt;/p&gt;

&lt;p&gt;Visualize occupancy stats, rent collections, security deposits, and key performance metrics in one place.&lt;/p&gt;

&lt;p&gt;✅ 8. Multi-Property Management&lt;/p&gt;

&lt;p&gt;Manage multiple PGs from a single account with property-wise switching and centralized tenant tracking.&lt;/p&gt;

&lt;p&gt;✅ 9. Document Storage via Google Drive&lt;/p&gt;

&lt;p&gt;Store tenant KYC and important files securely using your own Google Drive account.&lt;/p&gt;

&lt;h2&gt;
  
  
  📈 Extra Capabilities
&lt;/h2&gt;

&lt;p&gt;HarGharPG also offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automated WhatsApp + email notices&lt;/li&gt;
&lt;li&gt;Mess menu scheduling&lt;/li&gt;
&lt;li&gt;Support ticketing for tenants&lt;/li&gt;
&lt;li&gt;Staff management and role-based access&lt;/li&gt;
&lt;li&gt;Guided onboarding wizard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All designed to reduce administrative effort and centralize operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  📊 What They Maintain Behind the Scenes
&lt;/h2&gt;

&lt;p&gt;From the product side, HarGharPG maintains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A bed-level inventory and occupancy tracking system&lt;/li&gt;
&lt;li&gt;Tenant CRM with document management&lt;/li&gt;
&lt;li&gt;Recurring rent tracking and reminders&lt;/li&gt;
&lt;li&gt;Invoice generation and financial reports&lt;/li&gt;
&lt;li&gt;Public tenant interactions (notices, menus, support)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Multi-property dashboard and analytics&lt;br&gt;
These capabilities help PG owners replace manual processes with a structured, data-driven workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Why This Matters
&lt;/h2&gt;

&lt;p&gt;HarGharPG is a great example of vertical SaaS — a tool tailored for a specific industry and geography. It’s built around the everyday realities of Indian PG businesses, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High tenant turnover&lt;/li&gt;
&lt;li&gt;Diverse languages&lt;/li&gt;
&lt;li&gt;Multiple rent channels (cash, UPI, bank, wallets)&lt;/li&gt;
&lt;li&gt;Frequent notices and menus&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By focusing on these niche operational needs, the platform adds real value beyond generic property management tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;If you’re building tools for SMB operations, especially in markets like India, &lt;a href="https://hargharpg.com/" rel="noopener noreferrer"&gt;HarGharPG&lt;/a&gt; is worth studying — not because it’s perfect, but because it shows how domain focus + automation + simple UX can transform a traditionally manual business.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
