تعديل app.py لاختبار التوكن
Browse files
app.py
CHANGED
|
@@ -1,19 +1,12 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
-
from transformers import pipeline
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
#
|
| 7 |
hf_token = os.getenv("esamoai5")
|
| 8 |
|
| 9 |
-
# إنشاء نموذج محادثة باستخدام GPT2
|
| 10 |
-
generator = pipeline("text-generation", model="gpt2", use_auth_token=hf_token)
|
| 11 |
-
|
| 12 |
def chat_with_ai(message):
|
| 13 |
-
|
| 14 |
-
return response[0]['generated_text']
|
| 15 |
|
| 16 |
-
# واجهة Gradio للمحادثة
|
| 17 |
iface = gr.Interface(
|
| 18 |
fn=chat_with_ai,
|
| 19 |
inputs=gr.Textbox(lines=2, placeholder="اكتب رسالتك هنا..."),
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# قراءة التوكن من Secret
|
| 5 |
hf_token = os.getenv("esamoai5")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
def chat_with_ai(message):
|
| 8 |
+
return f"توكنك يعمل! الرسالة: {message}"
|
|
|
|
| 9 |
|
|
|
|
| 10 |
iface = gr.Interface(
|
| 11 |
fn=chat_with_ai,
|
| 12 |
inputs=gr.Textbox(lines=2, placeholder="اكتب رسالتك هنا..."),
|