Warehouse stock bilgisinin chatbot'a ulaşması sağlandı
Browse files- Basic search'te de her zaman warehouse stock çağrılıyor
- Debug loglar eklendi
- Stok bilgisi bulunamasa bile chatbot'a bilgi veriliyor
- System message olarak stok bilgisi ekleniyor
app.py
CHANGED
@@ -216,8 +216,9 @@ def get_warehouse_stock(product_name):
|
|
216 |
try:
|
217 |
from improved_chatbot import ImprovedChatbot
|
218 |
USE_IMPROVED_SEARCH = True
|
219 |
-
|
220 |
-
|
|
|
221 |
USE_IMPROVED_SEARCH = False
|
222 |
|
223 |
# Gradio uyarılarını bastır
|
@@ -546,6 +547,28 @@ def chatbot_fn(user_message, history, image=None):
|
|
546 |
|
547 |
# Use basic search as fallback or if improved search didn't find anything
|
548 |
if not product_found_improved:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
# Kullanıcı mesajında ürün ismi geçiyorsa ekle
|
550 |
input_words = user_message.lower().split()
|
551 |
for word in input_words:
|
|
|
216 |
try:
|
217 |
from improved_chatbot import ImprovedChatbot
|
218 |
USE_IMPROVED_SEARCH = True
|
219 |
+
print("DEBUG - Improved chatbot loaded successfully")
|
220 |
+
except ImportError as e:
|
221 |
+
print(f"DEBUG - Improved chatbot not available: {e}, using basic search")
|
222 |
USE_IMPROVED_SEARCH = False
|
223 |
|
224 |
# Gradio uyarılarını bastır
|
|
|
547 |
|
548 |
# Use basic search as fallback or if improved search didn't find anything
|
549 |
if not product_found_improved:
|
550 |
+
print(f"DEBUG chatbot_fn - No improved search result, trying basic search for: {user_message}")
|
551 |
+
|
552 |
+
# Her zaman warehouse stock bilgisini almayı dene
|
553 |
+
try:
|
554 |
+
warehouse_stock = get_warehouse_stock(user_message)
|
555 |
+
if warehouse_stock and warehouse_stock != ["Hiçbir mağazada mevcut değil"]:
|
556 |
+
warehouse_info = f"🏪 MAĞAZA STOK BİLGİLERİ:\n"
|
557 |
+
for store_info in warehouse_stock:
|
558 |
+
warehouse_info += f"• {store_info}\n"
|
559 |
+
system_messages.append({
|
560 |
+
"role": "system",
|
561 |
+
"content": f"GÜNCEL STOK DURUMU:\n{warehouse_info}\n\nBu bilgileri kullanarak kullanıcıya hangi mağazada stok olduğunu söyle."
|
562 |
+
})
|
563 |
+
print(f"DEBUG - Added warehouse stock to system messages: {warehouse_info}")
|
564 |
+
elif warehouse_stock == ["Hiçbir mağazada mevcut değil"]:
|
565 |
+
system_messages.append({
|
566 |
+
"role": "system",
|
567 |
+
"content": "🏪 MAĞAZA STOK BİLGİLERİ: Sorduğunuz ürün hiçbir mağazada mevcut değil."
|
568 |
+
})
|
569 |
+
except Exception as e:
|
570 |
+
print(f"DEBUG - Warehouse stock error in basic search: {e}")
|
571 |
+
|
572 |
# Kullanıcı mesajında ürün ismi geçiyorsa ekle
|
573 |
input_words = user_message.lower().split()
|
574 |
for word in input_words:
|