Basic search tamamen kaldırıldı
Browse files- Sadece warehouse stock API kullanılıyor
- Gereksiz ve yavaş basic search yok
- Temiz ve hızlı çözüm
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -691,11 +691,11 @@ def chatbot_fn(user_message, history, image=None):
|
|
| 691 |
except Exception as e:
|
| 692 |
print(f"Improved search error: {e}")
|
| 693 |
|
| 694 |
-
#
|
| 695 |
if not product_found_improved:
|
| 696 |
-
print(f"DEBUG chatbot_fn -
|
| 697 |
|
| 698 |
-
#
|
| 699 |
if warehouse_stock_data and warehouse_stock_data != ["Hiçbir mağazada mevcut değil"]:
|
| 700 |
warehouse_info = f"🏪 MAĞAZA STOK BİLGİLERİ:\n"
|
| 701 |
for store_info in warehouse_stock_data:
|
|
@@ -704,97 +704,15 @@ def chatbot_fn(user_message, history, image=None):
|
|
| 704 |
"role": "system",
|
| 705 |
"content": f"GÜNCEL STOK DURUMU:\n{warehouse_info}\n\nBu bilgileri kullanarak kullanıcıya hangi mağazada stok olduğunu söyle."
|
| 706 |
})
|
| 707 |
-
print(f"DEBUG - Using warehouse stock
|
| 708 |
-
# Skip basic search since we have warehouse info
|
| 709 |
-
skip_basic_search = True
|
| 710 |
elif warehouse_stock_data == ["Hiçbir mağazada mevcut değil"]:
|
| 711 |
system_messages.append({
|
| 712 |
"role": "system",
|
| 713 |
"content": "🏪 MAĞAZA STOK BİLGİLERİ: Sorduğunuz ürün hiçbir mağazada mevcut değil."
|
| 714 |
})
|
| 715 |
-
print(f"DEBUG - Product not available in any store
|
| 716 |
-
skip_basic_search = True
|
| 717 |
else:
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
# Kullanıcı mesajında ürün ismi geçiyorsa ve warehouse stock yoksa basic search yap
|
| 721 |
-
if not skip_basic_search:
|
| 722 |
-
print(f"DEBUG - No warehouse stock, trying basic search")
|
| 723 |
-
# Kullanıcı mesajında ürün ismi geçiyorsa ekle
|
| 724 |
-
input_words = user_message.lower().split()
|
| 725 |
-
for word in input_words:
|
| 726 |
-
for product_info in products:
|
| 727 |
-
if word in product_info[0] or word in product_info[2].lower():
|
| 728 |
-
# Stokta olup olmadığını kontrol et
|
| 729 |
-
if product_info[1][0] == "stokta":
|
| 730 |
-
# Normal fiyat
|
| 731 |
-
normal_price = f"\\nFiyat: {product_info[1][1]} TL"
|
| 732 |
-
|
| 733 |
-
# Kampanyalı fiyat kontrolü
|
| 734 |
-
rebate_price = ""
|
| 735 |
-
discount_info = ""
|
| 736 |
-
eft_price = ""
|
| 737 |
-
rebate_money_order_price = ""
|
| 738 |
-
|
| 739 |
-
# Kampanyalı fiyat var mı kontrol et
|
| 740 |
-
if len(product_info[1]) > 4 and product_info[1][4] and product_info[1][4] != "":
|
| 741 |
-
rebate_price = f"\\nKampanyalı fiyat: {product_info[1][4]} TL"
|
| 742 |
-
|
| 743 |
-
# İndirim miktarını hesapla
|
| 744 |
-
try:
|
| 745 |
-
normal_price_float = float(product_info[1][1])
|
| 746 |
-
rebate_price_float = float(product_info[1][4])
|
| 747 |
-
discount_amount = normal_price_float - rebate_price_float
|
| 748 |
-
|
| 749 |
-
# İndirim miktarı 0'dan büyükse göster
|
| 750 |
-
if discount_amount > 0:
|
| 751 |
-
# İndirim miktarı için yuvarlama kurallarını uygula
|
| 752 |
-
if discount_amount > 200000:
|
| 753 |
-
discount_amount_rounded = round(discount_amount / 5000) * 5000
|
| 754 |
-
elif discount_amount > 30000:
|
| 755 |
-
discount_amount_rounded = round(discount_amount / 1000) * 1000
|
| 756 |
-
elif discount_amount > 10000:
|
| 757 |
-
discount_amount_rounded = round(discount_amount / 100) * 100
|
| 758 |
-
else:
|
| 759 |
-
discount_amount_rounded = round(discount_amount / 10) * 10
|
| 760 |
-
|
| 761 |
-
# İndirim bilgisi
|
| 762 |
-
discount_info = f"\\nYapılan indirim: {discount_amount_rounded:.0f} TL"
|
| 763 |
-
except (ValueError, TypeError):
|
| 764 |
-
discount_info = ""
|
| 765 |
-
|
| 766 |
-
# Havale indirimli kampanyalı fiyat bilgisini gösterme
|
| 767 |
-
rebate_money_order_price = ""
|
| 768 |
-
else:
|
| 769 |
-
# Kampanyalı değilse, havale indirimli normal fiyatı göster
|
| 770 |
-
if product_info[1][3] and product_info[1][3] != "":
|
| 771 |
-
eft_price = f"\\nHavale indirimli fiyat: {product_info[1][3]} TL"
|
| 772 |
-
|
| 773 |
-
# Ürün linki ve resim
|
| 774 |
-
product_link = f"\\nÜrün linki: {product_info[1][2]}"
|
| 775 |
-
product_image = ""
|
| 776 |
-
if len(product_info[1]) > 6 and product_info[1][6]: # Resim URL'si varsa
|
| 777 |
-
product_image = f"\\nÜrün resmi: {product_info[1][6]}"
|
| 778 |
-
|
| 779 |
-
# Mağaza stok bilgilerini ekle (optimize edilmiş versiyon)
|
| 780 |
-
warehouse_stock_info = ""
|
| 781 |
-
try:
|
| 782 |
-
warehouse_stock = get_warehouse_stock(product_info[2])
|
| 783 |
-
if warehouse_stock and warehouse_stock != ["Hiçbir mağazada mevcut değil"]:
|
| 784 |
-
warehouse_stock_info = f"\\n🏪 Mağaza stok bilgileri:\\n"
|
| 785 |
-
for store_info in warehouse_stock:
|
| 786 |
-
warehouse_stock_info += f"• {store_info}\\n"
|
| 787 |
-
elif warehouse_stock == ["Hiçbir mağazada mevcut değil"]:
|
| 788 |
-
warehouse_stock_info = f"\\n🏪 Mağaza stok bilgileri: Hiçbir mağazada mevcut değil\\n"
|
| 789 |
-
except Exception as e:
|
| 790 |
-
print(f"Warehouse stock error for {product_info[2]}: {e}")
|
| 791 |
-
|
| 792 |
-
# Tüm bilgileri birleştir
|
| 793 |
-
new_msg = f"{product_info[2]} {product_info[1][0]}\\n{normal_price}{rebate_price}{discount_info}{eft_price}{rebate_money_order_price}{product_link}{product_image}{warehouse_stock_info}"
|
| 794 |
-
else:
|
| 795 |
-
# Ürün stokta yoksa sadece stok durumunu bildir
|
| 796 |
-
new_msg = f"{product_info[2]} {product_info[1][0]}"
|
| 797 |
-
system_messages.append({"role": "system", "content": new_msg})
|
| 798 |
|
| 799 |
messages = system_messages + history + [{"role": "user", "content": user_message}]
|
| 800 |
|
|
|
|
| 691 |
except Exception as e:
|
| 692 |
print(f"Improved search error: {e}")
|
| 693 |
|
| 694 |
+
# Only use warehouse stock data if available
|
| 695 |
if not product_found_improved:
|
| 696 |
+
print(f"DEBUG chatbot_fn - Using warehouse stock data for: {user_message}")
|
| 697 |
|
| 698 |
+
# Warehouse stock bilgisi varsa kullan
|
| 699 |
if warehouse_stock_data and warehouse_stock_data != ["Hiçbir mağazada mevcut değil"]:
|
| 700 |
warehouse_info = f"🏪 MAĞAZA STOK BİLGİLERİ:\n"
|
| 701 |
for store_info in warehouse_stock_data:
|
|
|
|
| 704 |
"role": "system",
|
| 705 |
"content": f"GÜNCEL STOK DURUMU:\n{warehouse_info}\n\nBu bilgileri kullanarak kullanıcıya hangi mağazada stok olduğunu söyle."
|
| 706 |
})
|
| 707 |
+
print(f"DEBUG - Using warehouse stock data")
|
|
|
|
|
|
|
| 708 |
elif warehouse_stock_data == ["Hiçbir mağazada mevcut değil"]:
|
| 709 |
system_messages.append({
|
| 710 |
"role": "system",
|
| 711 |
"content": "🏪 MAĞAZA STOK BİLGİLERİ: Sorduğunuz ürün hiçbir mağazada mevcut değil."
|
| 712 |
})
|
| 713 |
+
print(f"DEBUG - Product not available in any store")
|
|
|
|
| 714 |
else:
|
| 715 |
+
print(f"DEBUG - No warehouse stock data available")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 716 |
|
| 717 |
messages = system_messages + history + [{"role": "user", "content": user_message}]
|
| 718 |
|