Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
import json
|
4 |
from transformers import pipeline
|
5 |
|
6 |
# Modeli yükle
|
@@ -10,13 +9,12 @@ model = pipeline("question-answering", model="savasy/bert-base-turkish-squad")
|
|
10 |
def answer_question(file, question):
|
11 |
try:
|
12 |
if file is None:
|
13 |
-
return "Lütfen önce bir
|
14 |
|
15 |
-
# Dosyayı aç ve
|
16 |
-
|
17 |
-
data = json.load(f)
|
18 |
|
19 |
-
|
20 |
context = df.to_string(index=False)
|
21 |
|
22 |
# Hugging Face pipeline kullanarak soru-cevap yap
|
@@ -33,12 +31,12 @@ def answer_question(file, question):
|
|
33 |
demo = gr.Interface(
|
34 |
fn=answer_question,
|
35 |
inputs=[
|
36 |
-
gr.File(label="📂
|
37 |
-
gr.Textbox(label="💬 Soru", placeholder="Örn:
|
38 |
],
|
39 |
outputs="text",
|
40 |
title="🧠 Türkçe Soru-Cevap Chatbot",
|
41 |
-
description="Yüklediğiniz
|
42 |
)
|
43 |
|
44 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# Modeli yükle
|
|
|
9 |
def answer_question(file, question):
|
10 |
try:
|
11 |
if file is None:
|
12 |
+
return "Lütfen önce bir CSV dosyası yükleyin."
|
13 |
|
14 |
+
# Dosyayı aç ve CSV olarak yükle
|
15 |
+
df = pd.read_csv(file.name)
|
|
|
16 |
|
17 |
+
# CSV verisini metne dönüştür
|
18 |
context = df.to_string(index=False)
|
19 |
|
20 |
# Hugging Face pipeline kullanarak soru-cevap yap
|
|
|
31 |
demo = gr.Interface(
|
32 |
fn=answer_question,
|
33 |
inputs=[
|
34 |
+
gr.File(label="📂 CSV Dosyası", file_types=[".csv"]),
|
35 |
+
gr.Textbox(label="💬 Soru", placeholder="Örn: Kişinin yaşı nedir?")
|
36 |
],
|
37 |
outputs="text",
|
38 |
title="🧠 Türkçe Soru-Cevap Chatbot",
|
39 |
+
description="Yüklediğiniz CSV dosyasına göre sorular sorabilirsiniz. Model: savasy/bert-base-turkish-squad"
|
40 |
)
|
41 |
|
42 |
if __name__ == "__main__":
|