Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,12 +3,10 @@ import os
|
|
| 3 |
from deep_translator import GoogleTranslator
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
|
| 6 |
-
# دریافت توکن از محیط
|
| 7 |
HF_TOKEN = os.environ.get("HUGGINGFACE_API_TOKEN")
|
| 8 |
if not HF_TOKEN:
|
| 9 |
raise RuntimeError("Missing HUGGINGFACE_API_TOKEN secret")
|
| 10 |
-
|
| 11 |
-
# ساخت کلاینت جدید
|
| 12 |
hf_client = InferenceClient(token=HF_TOKEN)
|
| 13 |
|
| 14 |
def generate_topics(field, major, keywords, audience, level):
|
|
@@ -61,29 +59,29 @@ def generate_topics(field, major, keywords, audience, level):
|
|
| 61 |
except Exception as e:
|
| 62 |
return f"<div style='color: red;'>❌ خطا در تماس با مدل DeepSeek: {e}</div>"
|
| 63 |
|
| 64 |
-
# CSS سفارشی
|
| 65 |
custom_css = """
|
| 66 |
body, .gradio-container {
|
| 67 |
background-color: white !important;
|
| 68 |
color: black !important;
|
| 69 |
}
|
| 70 |
|
| 71 |
-
/* همه متون داخل
|
| 72 |
-
.gradio-container .gr-markdown,
|
| 73 |
-
.gradio-container .gr-markdown h1,
|
| 74 |
-
.gradio-container .gr-markdown h2,
|
| 75 |
-
.gradio-container .gr-markdown h3,
|
| 76 |
-
.gradio-container .gr-markdown p {
|
| 77 |
-
color: black !important;
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
/* استایل ورودیها و دکمهها */
|
| 81 |
input, textarea, select, button {
|
| 82 |
background-color: white !important;
|
| 83 |
color: black !important;
|
| 84 |
border: 1px solid #ccc !important;
|
| 85 |
}
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
/* باکس خروجی: پسزمینه روشن و حاشیه مشکی */
|
| 88 |
#output_box {
|
| 89 |
background-color: #f9f9f9 !important;
|
|
@@ -93,7 +91,7 @@ input, textarea, select, button {
|
|
| 93 |
border-radius: 4px;
|
| 94 |
}
|
| 95 |
|
| 96 |
-
/* تم تیره
|
| 97 |
.gradio-container.dark {
|
| 98 |
background-color: white !important;
|
| 99 |
color: black !important;
|
|
@@ -103,7 +101,7 @@ input, textarea, select, button {
|
|
| 103 |
with gr.Blocks(css=custom_css, theme="default") as app:
|
| 104 |
# لوگوی شما
|
| 105 |
gr.Image(value="logo.png", interactive=False, show_label=False)
|
| 106 |
-
# تیتر
|
| 107 |
gr.Markdown("## 🎓 پیشنهادگر موضوع پایاننامه کاسپین")
|
| 108 |
|
| 109 |
with gr.Row():
|
|
|
|
| 3 |
from deep_translator import GoogleTranslator
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
|
| 6 |
+
# دریافت توکن از محیط
|
| 7 |
HF_TOKEN = os.environ.get("HUGGINGFACE_API_TOKEN")
|
| 8 |
if not HF_TOKEN:
|
| 9 |
raise RuntimeError("Missing HUGGINGFACE_API_TOKEN secret")
|
|
|
|
|
|
|
| 10 |
hf_client = InferenceClient(token=HF_TOKEN)
|
| 11 |
|
| 12 |
def generate_topics(field, major, keywords, audience, level):
|
|
|
|
| 59 |
except Exception as e:
|
| 60 |
return f"<div style='color: red;'>❌ خطا در تماس با مدل DeepSeek: {e}</div>"
|
| 61 |
|
| 62 |
+
# CSS سفارشی
|
| 63 |
custom_css = """
|
| 64 |
body, .gradio-container {
|
| 65 |
background-color: white !important;
|
| 66 |
color: black !important;
|
| 67 |
}
|
| 68 |
|
| 69 |
+
/* همه متون داخل ورودیها و دکمهها */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
input, textarea, select, button {
|
| 71 |
background-color: white !important;
|
| 72 |
color: black !important;
|
| 73 |
border: 1px solid #ccc !important;
|
| 74 |
}
|
| 75 |
|
| 76 |
+
/* تیتر و متن Markdown بهصورت تضمینی مشکی */
|
| 77 |
+
.markdown,
|
| 78 |
+
.markdown h1,
|
| 79 |
+
.markdown h2,
|
| 80 |
+
.markdown h3,
|
| 81 |
+
.markdown p {
|
| 82 |
+
color: black !important;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
/* باکس خروجی: پسزمینه روشن و حاشیه مشکی */
|
| 86 |
#output_box {
|
| 87 |
background-color: #f9f9f9 !important;
|
|
|
|
| 91 |
border-radius: 4px;
|
| 92 |
}
|
| 93 |
|
| 94 |
+
/* غیرفعالسازی هرگونه تم تیره */
|
| 95 |
.gradio-container.dark {
|
| 96 |
background-color: white !important;
|
| 97 |
color: black !important;
|
|
|
|
| 101 |
with gr.Blocks(css=custom_css, theme="default") as app:
|
| 102 |
# لوگوی شما
|
| 103 |
gr.Image(value="logo.png", interactive=False, show_label=False)
|
| 104 |
+
# تیتر مشکی
|
| 105 |
gr.Markdown("## 🎓 پیشنهادگر موضوع پایاننامه کاسپین")
|
| 106 |
|
| 107 |
with gr.Row():
|