惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
J
Java Code Geeks
A
About on SuperTechFans
F
Fortinet All Blogs
B
Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
博客园_首页
博客园 - 叶小钗
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
云风的 BLOG
云风的 BLOG

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Pharma-Assist 2.0: A Sovereign Local AI Agent Network for...
mamigabi · 2026-05-18 · via DEV Community

🦅 Pharma-Assist 2.0: A Sovereign Local AI Agent Network for Real-Time Pharmacy Audit

🏷️ Category Credentials

  • Challenge Track: Build With Gemma 4
  • Submission Tags: #gemmachallenge, #ai, #opensource, #python, #privacy

🏛️ 1. The Real-World B2B Pain Point

In the pharmaceutical and logistics industries, administrative staff spend up to 70% of their working hours manually reconciling invoices, checking delivery sheets (albaranes), and calculating trade margins.

This causes three critical operational bottlenecks:

  1. The Margin Drain: Surcharges, cooperative rebate discrepancies, and minor billing errors from major distributors (e.g., Cofares, Hefame, Alliance) go unnoticed, draining thousands of euros annually.
  2. Legal Liability: Invoices containing sensitive patient data, sanitary cards, and proprietary pricing metrics are routinely uploaded to public SaaS clouds (like public ChatGPT wrappers) for quick parsing, resulting in catastrophic GDPR compliance breaches.
  3. API Tolls: Processing high-volume transactions via cloud-based LLM APIs results in heavy monthly recurring subscription fees.

🚀 2. Our Sovereign Solution: The Local AI Bunker

Pharma-Assist 2.0 is a fully open-source, self-contained Local AI Bunker running entirely on-premises inside the company's LAN network. Powered by local Gemma / Qwen model architectures via Ollama, it automates high-volume document auditing with zero cloud dependencies, zero API costs, and absolute data privacy.

🌟 Core Tech Features:

  • 100% Secure Local Isolation: Financial audit, OCR parsing, and regular expression evaluations are processed entirely within the local GPU/VRAM memory.
  • Dynamic Margin Audit Engine: Automatically cross-references distributor unit costs, discounts, and retail pricing, flagging any item falling below the mandatory 12% commercial margin.
  • Glassmorphic Control Dashboard: An elite B2B web interface that acts as the command center, featuring model conmuting, real-time latency indicators, and an interactive "Fire Drill" simulation module.

🏗️ 3. System Architecture & Flow

graph TD
    LAN[Red Local de Oficina - LAN] -->|HTTPS| Proxy[Nginx Reverse Proxy]
    Proxy -->|REST API| Dashboard[Glassmorphic HTML5/JS Dashboard]
    Proxy -->|REST API| Facilix[Facilix Orchestrator Server: Port 3002]
    Facilix -->|JSON Payload| Ollama[Ollama Core Engine: Port 11434]
    Ollama -->|GPU Infece| Models[Local Qwen2.5-Coder / Gemma 2B]
    Facilix -->|Write Report| DB[error_reports.json Database]

Enter fullscreen mode Exit fullscreen mode


⚙️ 4. Technical Implementation & Code Highlights

The brain of the system is the Local Invoice Auditor (agents/pharmacy_invoice_auditor.py), which executes high-speed mathematical auditing combined with local LLM semantic evaluation.

Here is how the core mathematical and compliance auditing logic is constructed:

# --- LÓGICA DE CONCILIACIÓN DE MÁRGENES (12% MÍNIMO) ---
net_cost = cost * (1.0 - (disc / 100.0))
if retail > 0:
    margin = ((retail - net_cost) / retail) * 100
else:
    margin = 0

if margin < 12.0:
    loss = (net_cost - (retail * 0.88)) # Projected financial loss
    if loss > 0:
        total_loss += loss
    errors.append(f"ALERTA_MARGEN: Margen comercial del {margin:.2f}% (Mínimo requerido: 12%).")

Enter fullscreen mode Exit fullscreen mode

🧠 Semantic Error Parsing via Local Qwen:

For advanced textual anomalies, the auditor queries our offline Qwen/Gemma instance:

def call_local_qwen(prompt_text):
    payload = {
        "model": "qwen2.5-coder:7b",
        "prompt": f"{SYSTEM_RULES}\nAnaliza la siguiente transacción:\n{prompt_text}",
        "stream": False,
        "format": "json"
    }
    r = requests.post("http://localhost:11434/api/generate", json=payload, timeout=8)
    return json.loads(r.json().get("response", "{}"))

Enter fullscreen mode Exit fullscreen mode


🖥️ 5. The Glassmorphic Interface & "Fire Drill" Simulator

To present this to corporate decision-makers (such as CEOs and Operations Managers of large Logistics and Real Estate firms), we built a stunning web-based dashboard:

  • Model Selector Card: Switch on the fly with a single click between Local Qwen (high-speed local processing), Hybrid Gemini (optimized processing), and Cloud Claude (external fallback).
  • The Live "Fire Drill" (Simulacro de Fuego Real): Allows users to select 5 real Madrid-based leads from a dropdown menu, loading their specific corporate profiles (e.g., TIBA Group, Walter Haus). Users can click the dotted drag-and-drop zone to run a mock document audit, trigger a live scanning animation, and render dynamic metrics (e.g., "$8,900 in financial risk protected" or "340 administrative minutes saved").

🏆 6. Why Gemma & Local Models Make B2B AI High-Ticket Viable

Deploying large cloud models for high-volume invoice and catalog sorting is a financial black hole. By running Gemma / Qwen locally, businesses can:

  1. Amortize Hardware Instantly: The cost of a dedicated local workstation (NVIDIA RTX 4090) is fully amortized within the first two months.
  2. Sovereign Compliance: Medical prescriptions and proprietary catalog prices remain strictly local, completely immune to internet outages, data leaks, or foreign server hacks.

📂 7. Repository & Installation

The complete open-source repository is available under the MIT License.

💻 Quick Start:

  1. Clone the Repo & Install Dependencies:

    git clone https://github.com/yourusername/pharma-assist-2.0.git
    cd pharma-assist-2.0
    pip install requests
    
  2. Run the Background Service:

    python facilix_service.py
    
  3. Run a Test Audit:

    python agents/pharmacy_invoice_auditor.py
    
  4. Open the Console: Double-click antigravity_core_dashboard.html in your browser to start conmuting models and running live document simulations on port 3002!


Created by Antigravity — Powering local, private, and high-performance AI bunkers for enterprise elite.