SamiKoen commited on
Commit
5a5a4bb
·
verified ·
1 Parent(s): e2a874a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -50
app.py CHANGED
@@ -353,61 +353,61 @@ def chatbot_fn(user_message, history, image=None):
353
  if word in product_info[0] or word in product_info[2].lower():
354
  # Stokta olup olmadığını kontrol et
355
  if product_info[1][0] == "stokta":
356
- # Normal fiyat
357
- normal_price = f"\\nFiyat: {product_info[1][1]} TL"
358
-
359
- # Kampanyalı fiyat kontrolü
360
- rebate_price = ""
361
- discount_info = ""
362
- eft_price = ""
363
- rebate_money_order_price = ""
364
-
365
- # Kampanyalı fiyat var mı kontrol et
366
- if len(product_info[1]) > 4 and product_info[1][4] and product_info[1][4] != "":
367
- rebate_price = f"\\nKampanyalı fiyat: {product_info[1][4]} TL"
368
 
369
- # İndirim miktarını hesapla
370
- try:
371
- normal_price_float = float(product_info[1][1])
372
- rebate_price_float = float(product_info[1][4])
373
- discount_amount = normal_price_float - rebate_price_float
 
 
 
 
374
 
375
- # İndirim miktarı 0'dan büyükse göster
376
- if discount_amount > 0:
377
- # İndirim miktarı için yuvarlama kurallarını uygula
378
- if discount_amount > 200000:
379
- discount_amount_rounded = round(discount_amount / 5000) * 5000
380
- elif discount_amount > 30000:
381
- discount_amount_rounded = round(discount_amount / 1000) * 1000
382
- elif discount_amount > 10000:
383
- discount_amount_rounded = round(discount_amount / 100) * 100
384
- else:
385
- discount_amount_rounded = round(discount_amount / 10) * 10
 
 
 
 
 
 
386
 
387
- # İndirim bilgisi
388
- discount_info = f"\\nYapılan indirim: {discount_amount_rounded:.0f} TL"
389
- except (ValueError, TypeError):
390
- discount_info = ""
 
 
 
 
 
 
 
391
 
392
- # Havale indirimli kampanyalı fiyat bilgisini gösterme
393
- rebate_money_order_price = ""
 
 
 
 
 
 
394
  else:
395
- # Kampanyalı değilse, havale indirimli normal fiyatı göster
396
- if product_info[1][3] and product_info[1][3] != "":
397
- eft_price = f"\\nHavale indirimli fiyat: {product_info[1][3]} TL"
398
-
399
- # Ürün linki ve resim
400
- product_link = f"\\nÜrün linki: {product_info[1][2]}"
401
- product_image = ""
402
- if len(product_info[1]) > 6 and product_info[1][6]: # Resim URL'si varsa
403
- product_image = f"\\nÜrün resmi: {product_info[1][6]}"
404
-
405
- # Tüm bilgileri birleştir
406
- 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}"
407
- else:
408
- # Ürün stokta yoksa sadece stok durumunu bildir
409
- new_msg = f"{product_info[2]} {product_info[1][0]}"
410
- system_messages.append({"role": "system", "content": new_msg})
411
 
412
  messages = system_messages + history + [{"role": "user", "content": user_message}]
413
 
 
353
  if word in product_info[0] or word in product_info[2].lower():
354
  # Stokta olup olmadığını kontrol et
355
  if product_info[1][0] == "stokta":
356
+ # Normal fiyat
357
+ normal_price = f"\\nFiyat: {product_info[1][1]} TL"
 
 
 
 
 
 
 
 
 
 
358
 
359
+ # Kampanyalı fiyat kontrolü
360
+ rebate_price = ""
361
+ discount_info = ""
362
+ eft_price = ""
363
+ rebate_money_order_price = ""
364
+
365
+ # Kampanyalı fiyat var mı kontrol et
366
+ if len(product_info[1]) > 4 and product_info[1][4] and product_info[1][4] != "":
367
+ rebate_price = f"\\nKampanyalı fiyat: {product_info[1][4]} TL"
368
 
369
+ # İndirim miktarını hesapla
370
+ try:
371
+ normal_price_float = float(product_info[1][1])
372
+ rebate_price_float = float(product_info[1][4])
373
+ discount_amount = normal_price_float - rebate_price_float
374
+
375
+ # İndirim miktarı 0'dan büyükse göster
376
+ if discount_amount > 0:
377
+ # İndirim miktarı için yuvarlama kurallarını uygula
378
+ if discount_amount > 200000:
379
+ discount_amount_rounded = round(discount_amount / 5000) * 5000
380
+ elif discount_amount > 30000:
381
+ discount_amount_rounded = round(discount_amount / 1000) * 1000
382
+ elif discount_amount > 10000:
383
+ discount_amount_rounded = round(discount_amount / 100) * 100
384
+ else:
385
+ discount_amount_rounded = round(discount_amount / 10) * 10
386
 
387
+ # İndirim bilgisi
388
+ discount_info = f"\\nYapılan indirim: {discount_amount_rounded:.0f} TL"
389
+ except (ValueError, TypeError):
390
+ discount_info = ""
391
+
392
+ # Havale indirimli kampanyalı fiyat bilgisini gösterme
393
+ rebate_money_order_price = ""
394
+ else:
395
+ # Kampanyalı değilse, havale indirimli normal fiyatı göster
396
+ if product_info[1][3] and product_info[1][3] != "":
397
+ eft_price = f"\\nHavale indirimli fiyat: {product_info[1][3]} TL"
398
 
399
+ # Ürün linki ve resim
400
+ product_link = f"\\nÜrün linki: {product_info[1][2]}"
401
+ product_image = ""
402
+ if len(product_info[1]) > 6 and product_info[1][6]: # Resim URL'si varsa
403
+ product_image = f"\\nÜrün resmi: {product_info[1][6]}"
404
+
405
+ # Tüm bilgileri birleştir
406
+ 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}"
407
  else:
408
+ # Ürün stokta yoksa sadece stok durumunu bildir
409
+ new_msg = f"{product_info[2]} {product_info[1][0]}"
410
+ system_messages.append({"role": "system", "content": new_msg})
 
 
 
 
 
 
 
 
 
 
 
 
 
411
 
412
  messages = system_messages + history + [{"role": "user", "content": user_message}]
413