Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
# التنسيق البصري الفاخر
|
| 5 |
custom_css = """
|
| 6 |
body, .gradio-container {
|
| 7 |
background-color: #000000 !important;
|
|
@@ -44,9 +44,10 @@ def generate_byok(prompt, hf_token):
|
|
| 44 |
except Exception as e:
|
| 45 |
return None, f"خطأ في الاتصال اللحظي: {str(e)}"
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
|
| 51 |
with gr.Column(elem_id="col-container"):
|
| 52 |
gr.Markdown("<h1 style='text-align: center; color: #00f3ff; margin-bottom: 0;'>7.com.ly</h1>")
|
|
@@ -62,10 +63,8 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
|
| 62 |
with gr.Accordion("منطقة تفعيل المفتاح الخاص (محفوظ في متصفحك)", open=True):
|
| 63 |
hf_token = gr.Text(label="مفتاح العميل اللحظي (Hugging Face Token)", placeholder="hf_...", type="password")
|
| 64 |
|
| 65 |
-
#
|
| 66 |
demo.load(fn=lambda x: x, inputs=[token_storage], outputs=[hf_token])
|
| 67 |
-
|
| 68 |
-
# 2. حفظ المفتاح فوراً في ذاكرة المتصفح بمجرد قيامك بكتابته أو تعديله
|
| 69 |
hf_token.change(fn=lambda x: x, inputs=[hf_token], outputs=[token_storage])
|
| 70 |
|
| 71 |
run_button.click(
|
|
@@ -75,4 +74,5 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
|
| 75 |
)
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
# التنسيق البصري الفاخر لـ 7.com.ly
|
| 5 |
custom_css = """
|
| 6 |
body, .gradio-container {
|
| 7 |
background-color: #000000 !important;
|
|
|
|
| 44 |
except Exception as e:
|
| 45 |
return None, f"خطأ في الاتصال اللحظي: {str(e)}"
|
| 46 |
|
| 47 |
+
# تهيئة Blocks بدون برامترات ميتة توافقاً مع قواعد الإصدار السادس
|
| 48 |
+
with gr.Blocks() as demo:
|
| 49 |
+
# تصحيح مسمى متغير الحفظ اللحظي للمتصفح
|
| 50 |
+
token_storage = gr.BrowserState()
|
| 51 |
|
| 52 |
with gr.Column(elem_id="col-container"):
|
| 53 |
gr.Markdown("<h1 style='text-align: center; color: #00f3ff; margin-bottom: 0;'>7.com.ly</h1>")
|
|
|
|
| 63 |
with gr.Accordion("منطقة تفعيل المفتاح الخاص (محفوظ في متصفحك)", open=True):
|
| 64 |
hf_token = gr.Text(label="مفتاح العميل اللحظي (Hugging Face Token)", placeholder="hf_...", type="password")
|
| 65 |
|
| 66 |
+
# استدعاء وحفظ المفتاح محلياً
|
| 67 |
demo.load(fn=lambda x: x, inputs=[token_storage], outputs=[hf_token])
|
|
|
|
|
|
|
| 68 |
hf_token.change(fn=lambda x: x, inputs=[hf_token], outputs=[token_storage])
|
| 69 |
|
| 70 |
run_button.click(
|
|
|
|
| 74 |
)
|
| 75 |
|
| 76 |
if __name__ == "__main__":
|
| 77 |
+
# تمرير الـ css والثيم هنا داخل دالة launch لإصلاح الـ Runtime Error تماماً
|
| 78 |
+
demo.launch(css=custom_css, theme=gr.themes.Base())
|