CoolFace
Apppublic

scelebi/shopify-ai-asistan

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

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ştirme
  • —session_store.py: Oturum sayacı + exact cache (SQLite, TTL 24 saat)
  • —test_sqlite_faz5.py: FAZ 5 SQLite oturum testleri
  • —semantic_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 testleri
  • —hybrid_test.py: Yerel pipeline testi
  • —data/faq/*.json: 7 dilli ürün dışı FAQ cevapları
  • —data/products/*.csv: 7 dilli ürün kataloğu
  • —data/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

json
{
  "message": "G21-149A Ivory 42 beden Cathedral Veil fiyatı nedir?",
  "language": "tr"
}

Cevap:

json
{
  "reply": "...",
  "language": "tr",
  "source": "formula"
}

Test

Yerel:

bash
python hybrid_test.py
uvicorn app:app --host 0.0.0.0 --port 7860

Space 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:

SecretZorunluAçıklama
HF_API_TOKENEvet (LLM icin)Hugging Face read token
LLM_MODELHayirVarsayilan: HuggingFaceH4/zephyr-7b-beta

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 → fallback

SQLite Oturum (FAZ 5)

Mesaj sayaci ve exact cache data/sessions.db dosyasinda kalici tutulur (TTL 24 saat). Space restart sonrasi 10 mesaj kurali bozulmaz.

EnvVarsayilanAciklama
SESSION_DB_PATHdata/sessions.db veya /data/sessions.dbSQLite dosya yolu

HF Space'te kalicilik icin Settings → Persistent storage acin (/data mount). Secret gerekmez; opsiyonel SESSION_DB_PATH=/data/sessions.db yazilabilir.

Test:

bash
python test_sqlite_faz5.py

Shopify + WhatsApp (FAZ 6)

  • —shopify-huggingface-baglanti-kodu.txt: Shopify fetch API + session_id + WhatsApp butonu
  • —whatsapp_policy.py: WhatsApp URL sabitleri
  • —11+ mesajda cevapta https://wa.me/905334619373 linki + whatsapp_url JSON 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:

bash
python test_faz6.py

Son Test Paketi (FAZ 7 — Production Ready)

bash
python test_faz7.py          # yerel 7 test
python test_faz7.py --live   # canli HF 7 test + /health
python test_faz7.py --all    # ikisi birden

Kapsam: adres, urun fiyati, iade, karsilama, 11. mesaj WA, Turkce encoding, 7 dil.