Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
model = pipeline("text-generation", model="gpt2") # مدل GPT-2
|
| 5 |
+
|
| 6 |
+
def generate_text(message):
|
| 7 |
+
response = model(message, max_length=50, num_return_sequences=1)
|
| 8 |
+
return response[0]['generated_text']
|
| 9 |
+
|
| 10 |
+
iface = gr.Interface(
|
| 11 |
+
fn=generate_text,
|
| 12 |
+
inputs=gr.Textbox(label="پیام ورودی"),
|
| 13 |
+
outputs=gr.Textbox(label="پاسخ مدل"),
|
| 14 |
+
title="چت با GPT-2"
|
| 15 |
+
)
|
| 16 |
+
iface.launch(share=True) # share=True برای URL عمومی
|