scelebi/shopify-ai-asistan
GELİNLİK21 AI Asistan Motoru
Bu paket Shopify chat arayüzünün bağlanacağı Hugging Face Space backend motorudur.
Dosyalar
app.py: FastAPI API katmanıchatbot_engine.py: Hibrit cevap motoru (pipeline orchestrator)intent_router.py: 0 token intent eşleştirmesession_store.py: Oturum sayacı + exact cache (SQLite, TTL 24 saat)test_sqlite_faz5.py: FAZ 5 SQLite oturum testlerisemantic_search.py: FAQ semantic arama (FAISS + fastembed, Jaccard fallback)build_index.py: FAQ vektör indeksi (data/faq/vector_index.faiss, model:multilingual-e5-small)llm_fallback.py: HF Inference API + RAG fallback (ilk 10 mesaj, dusuk token)test_llm_faz4.py: FAZ 4 RAG+LLM testlerihybrid_test.py: Yerel pipeline testidata/faq/*.json: 7 dilli ürün dışı FAQ cevaplarıdata/products/*.csv: 7 dilli ürün kataloğudata/faq/variant_formula.json: renk + beden + duvak fiyat formülüstatic/test.html: UTF-8 test arayüzüDockerfile: Hugging Face Docker Space çalıştırma ayarı
API
POST /api/chat
{
"message": "G21-149A Ivory 42 beden Cathedral Veil fiyatı nedir?",
"language": "tr"
}Cevap:
{
"reply": "...",
"language": "tr",
"source": "formula"
}Test
Yerel:
python hybrid_test.py
uvicorn app:app --host 0.0.0.0 --port 7860Space açıldıktan sonra tarayıcıda ana sayfayı açıp test edebilirsiniz.
Sağlık kontrolü:
/health
Hugging Face Space Secrets (FAZ 4 — LLM)
Space ayarlarından Settings → Secrets bölümüne ekleyin:
LLM sadece ilk 10 mesajda ve diger katmanlar yetmediginde devreye girer. Cogu cevap 0 token kalir.
Pipeline:
exact_cache → intent → csv → faq → semantic_faq → llm_rag → rag → llm → fallbackSQLite Oturum (FAZ 5)
Mesaj sayaci ve exact cache data/sessions.db dosyasinda kalici tutulur (TTL 24 saat). Space restart sonrasi 10 mesaj kurali bozulmaz.
HF Space'te kalicilik icin Settings → Persistent storage acin (/data mount). Secret gerekmez; opsiyonel SESSION_DB_PATH=/data/sessions.db yazilabilir.
Test:
python test_sqlite_faz5.pyShopify + WhatsApp (FAZ 6)
shopify-huggingface-baglanti-kodu.txt: Shopify fetch API + session_id + WhatsApp butonuwhatsapp_policy.py: WhatsApp URL sabitleri- 11+ mesajda cevapta
https://wa.me/905334619373linki +whatsapp_urlJSON alani
CORS varsayilan: gelinlik21.com.tr, www.gelinlik21.com.tr, gelinlik21.myshopify.com Ek domain icin env: CORS_ORIGINS=https://ornek.com veya CORS_ORIGINS=*
iframe embed: ../shopify-ai-whatsapp-arayuz/shopify-whatsapp-embed-kodu.txt
Test:
python test_faz6.pySon Test Paketi (FAZ 7 — Production Ready)
python test_faz7.py # yerel 7 test
python test_faz7.py --live # canli HF 7 test + /health
python test_faz7.py --all # ikisi birdenKapsam: adres, urun fiyati, iade, karsilama, 11. mesaj WA, Turkce encoding, 7 dil.
