ta2cay commited on
Commit
e47b642
·
verified ·
1 Parent(s): 457afa9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -6
app.py CHANGED
@@ -12,21 +12,35 @@ def download_file(url):
12
  dataset_url = "https://huggingface.co/datasets/ta2cay/caycuma_info/resolve/main/caycuma_info.csv"
13
  data = pd.read_csv(download_file(dataset_url))
14
 
15
- # Soruya cevap veren fonksiyon
16
  def answer_question(question):
17
  response = data[data["Soru"].str.contains(question, case=False, na=False)]
 
18
  if not response.empty:
19
- return response.iloc[0]["Cevap"]
 
 
 
 
 
 
 
 
 
 
20
  else:
21
- return "Bu soru ile ilgili eğitilme sürecim devam ediyor."
 
 
 
22
 
23
  # Gradio arayüzü
24
  iface = gr.Interface(
25
  fn=answer_question,
26
  inputs=gr.Textbox(lines=2, placeholder="Sorunuzu buraya yazın...", label="Soru"),
27
- outputs="text",
28
- title="Yapay Zeka ile Çaycuma Bilgi Modeli",
29
- description="Çaycuma ile ilgili sorularınızı sorun",
30
  theme="default"
31
  )
32
 
 
12
  dataset_url = "https://huggingface.co/datasets/ta2cay/caycuma_info/resolve/main/caycuma_info.csv"
13
  data = pd.read_csv(download_file(dataset_url))
14
 
15
+ # Soruya cevap veren ve ilgili görseli döndüren fonksiyon
16
  def answer_question(question):
17
  response = data[data["Soru"].str.contains(question, case=False, na=False)]
18
+
19
  if not response.empty:
20
+ answer = response.iloc[0]["Cevap"]
21
+
22
+ # Belirli sorulara göre görsel eklemek
23
+ if "nerede" in question.lower():
24
+ image = "caycuma_map.png"
25
+ elif "nüfus" in question.lower():
26
+ image = "caycuma_population.png"
27
+ elif "tarih" in question.lower():
28
+ image = "caycuma_history.png"
29
+ else:
30
+ image = None
31
  else:
32
+ answer = "Bu soruya dair bir bilgi bulamadım."
33
+ image = None
34
+
35
+ return answer, image
36
 
37
  # Gradio arayüzü
38
  iface = gr.Interface(
39
  fn=answer_question,
40
  inputs=gr.Textbox(lines=2, placeholder="Sorunuzu buraya yazın...", label="Soru"),
41
+ outputs=["text", "image"],
42
+ title="Çaycuma Bilgi Modeli",
43
+ description="Çaycuma ile ilgili sorularınızı sorun ve ilgili görselleri görün.",
44
  theme="default"
45
  )
46