SAFE44 commited on
Commit
d44947d
·
verified ·
1 Parent(s): ee0ae1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- # التنسيق البصري الفاخر التابع لـ 7.com.ly (True Black & Cyber Neon)
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
- with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
48
- # تفعيل مخزن المتصفح السري (Browser Local Storage) لحفظ المفتاح تلقائياً
49
- token_storage = gr.BrowserState(value="")
 
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
- # 1. استدعاء المفتاح تلقائياً من ذاكرة المتصفح عند فتح الصفحة
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
- demo.launch()
 
 
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())