EEggeE commited on
Commit
0c47e11
·
verified ·
1 Parent(s): b402ad0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Model ID'si
5
+ model_id = "sambanovasystems/SambaLingo-Turkish-Chat"
6
+
7
+ # Modeli ve tokenizer'ı yükle
8
+ model = AutoModelForCausalLM.from_pretrained(model_id)
9
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
10
+
11
+ # Modelden yanıt almak için bir fonksiyon tanımla
12
+ def respond_to_query(question):
13
+ inputs = tokenizer(question, return_tensors="pt")
14
+ outputs = model.generate(**inputs)
15
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
16
+ return response
17
+
18
+ # Gradio arayüzünü oluştur
19
+ interface = gr.Interface(fn=respond_to_query, inputs="text", outputs="text")
20
+
21
+ # Arayüzü başlat
22
+ interface.launch()