SamiKoen commited on
Commit
ad4aa26
·
verified ·
1 Parent(s): c260987

Delete Stok

Browse files
Files changed (1) hide show
  1. Stok +0 -50
Stok DELETED
@@ -1,50 +0,0 @@
1
- import requests
2
- import xml.etree.ElementTree as ET
3
- from transformers import pipeline
4
-
5
- # Hugging Face pipeline'ını yükle
6
- nlp = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
7
-
8
- # API url'si
9
- url = 'https://bizimhesap.com/api/product/getproductsasxml?apikey=6F4BAF303FA240608A39653824B6C495'
10
-
11
- # Verileri al
12
- response = requests.get(url)
13
- xml_data = response.content
14
-
15
- # XML verilerini ayrıştır
16
- root = ET.fromstring(xml_data)
17
- products = root.findall('urunler/urun')
18
-
19
- # Chatbot'a girdi al
20
- input_text = input("Merhaba, ne yapabilirim? ")
21
-
22
- # Girdiye göre yanıt üret
23
- if 'stok' in input_text and ('durum' in input_text or 'seviye' in input_text):
24
- # Eğer kullanıcı stok durumunu sorduysa
25
- for product in products:
26
- if product.find('urun_ad').text.lower() in input_text.lower():
27
- stok = int(product.find('stok').text)
28
- if stok > 0:
29
- response_text = f"{product.find('urun_ad').text} ürününden {stok} adet mevcut."
30
- else:
31
- response_text = f"{product.find('urun_ad').text} ürünü stoklarda yok."
32
- break
33
- else:
34
- response_text = "Aradığınız ürün stoklarda yok."
35
- elif 'fiyat' in input_text:
36
- # Eğer kullanıcı fiyat bilgisi istiyorsa
37
- for product in products:
38
- if product.find('urun_ad').text.lower() in input_text.lower():
39
- price = float(product.find('satis_fiyat').text)
40
- response_text = f"{product.find('urun_ad').text} ürününün fiyatı {price:.2f} TL."
41
- break
42
- else:
43
- response_text = "Aradığınız ürün fiyatı hakkında bilgi verilemedi."
44
- else:
45
- # Girdiye göre otomatik bir yanıt üret
46
- generated_text = nlp(input_text, max_length=50, do_sample=True, temperature=0.7)
47
- response_text = generated_text[0]['generated_text'].strip()
48
-
49
- # Yanıtı yazdır
50
- print(response_text)