""" QModel v6 — Islamic RAG API =========================== Specialized Quran & Hadith system with dual LLM backend support. Modular architecture — see app/ package for implementation: app/config.py – Config (env vars) app/llm.py – LLM providers (Ollama, HuggingFace) app/cache.py – TTL-LRU async cache app/arabic_nlp.py – Arabic normalisation & stemming app/search.py – Hybrid FAISS + BM25 search, text search app/analysis.py – Intent detection, analytics, counting app/prompts.py – Prompt engineering app/models.py – Pydantic schemas app/state.py – AppState, lifespan, RAG pipeline app/routers/ – FastAPI routers (quran, hadith, chat, ops) """ from __future__ import annotations import logging from dotenv import load_dotenv from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware load_dotenv() logging.basicConfig( level=logging.INFO, format="%(asctime)s | %(levelname)-8s | %(name)s | %(message)s", ) from app.config import cfg from app.state import lifespan from app.routers import chat, hadith, ops, quran # ═══════════════════════════════════════════════════════════════════════ # FASTAPI APP # ═══════════════════════════════════════════════════════════════════════ app = FastAPI( title="QModel v6 — Islamic RAG API", description=( "Specialized Quran & Hadith system with dual LLM backend.\n\n" "**Capabilities:**\n" "- OpenAI-compatible chat completions\n" "- Streaming support\n" "- Islamic knowledge RAG pipeline" ), version="6.0.0", lifespan=lifespan, ) app.add_middleware( CORSMiddleware, allow_origins=cfg.ALLOWED_ORIGINS.split(","), allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Register routers app.include_router(ops.router) app.include_router(chat.router) app.include_router(quran.router) app.include_router(hadith.router) if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000)