Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Modeli ve pipeline'ı başlatıyoruz (Space ayağa kalkarken modeli indirecek)
|
| 5 |
+
pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
|
| 6 |
+
|
| 7 |
+
def generate_response(prompt):
|
| 8 |
+
# Prompt'u modele gönderip yanıtı alıyoruz
|
| 9 |
+
output = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
|
| 10 |
+
return output[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
# Arayüzü oluşturuyoruz (Arka planda otomatik API endpoint açar)
|
| 13 |
+
demo = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
| 14 |
+
demo.launch()
|