diginoron commited on
Commit
b9e4088
·
verified ·
1 Parent(s): c4c3804

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -3,12 +3,10 @@ import os
3
  from deep_translator import GoogleTranslator
4
  from huggingface_hub import InferenceClient
5
 
6
- # دریافت توکن از محیط (در Hugging Face Secrets تنظیم شود)
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):
@@ -43,7 +41,6 @@ def generate_topics(field, major, keywords, audience, level):
43
  max_tokens=512
44
  )
45
  english_output = response.choices[0].message.content.strip()
46
-
47
  try:
48
  translated = GoogleTranslator(source='en', target='fa').translate(english_output)
49
  except:
@@ -59,11 +56,10 @@ def generate_topics(field, major, keywords, audience, level):
59
  "<strong>021-88252497</strong>"
60
  "</div>"
61
  )
62
-
63
  except Exception as e:
64
  return f"<div style='color: red;'>❌ خطا در تماس با مدل DeepSeek: {e}</div>"
65
 
66
- # CSS سفارشی برای بک‌گراند سفید و متن مشکی
67
  custom_css = """
68
  /* پس‌زمینه کلی سفید و متن مشکی */
69
  body, .gradio-container {
@@ -71,6 +67,11 @@ body, .gradio-container {
71
  color: black !important;
72
  }
73
 
 
 
 
 
 
74
  /* استایل ورودی‌ها و دکمه‌ها */
75
  input, textarea, select, button {
76
  background-color: white !important;
@@ -78,10 +79,13 @@ input, textarea, select, button {
78
  border: 1px solid #ccc !important;
79
  }
80
 
81
- /* استایل HTML خروجی */
82
  #output_box {
83
- background-color: white !important;
84
  color: black !important;
 
 
 
85
  }
86
 
87
  /* برداشتن تم تیره Gradio */
@@ -94,7 +98,7 @@ input, textarea, select, button {
94
  with gr.Blocks(css=custom_css, theme="default") as app:
95
  # لوگوی شما
96
  gr.Image(value="logo.png", interactive=False, show_label=False)
97
- # عنوان
98
  gr.Markdown("## 🎓 پیشنهادگر موضوع پایان‌نامه کاسپین")
99
 
100
  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):
 
41
  max_tokens=512
42
  )
43
  english_output = response.choices[0].message.content.strip()
 
44
  try:
45
  translated = GoogleTranslator(source='en', target='fa').translate(english_output)
46
  except:
 
56
  "<strong>021-88252497</strong>"
57
  "</div>"
58
  )
 
59
  except Exception as e:
60
  return f"<div style='color: red;'>❌ خطا در تماس با مدل DeepSeek: {e}</div>"
61
 
62
+ # CSS سفارشی
63
  custom_css = """
64
  /* پس‌زمینه کلی سفید و متن مشکی */
65
  body, .gradio-container {
 
67
  color: black !important;
68
  }
69
 
70
+ /* تیتر Markdown */
71
+ .gradio-container .markdown h2 {
72
+ color: black !important;
73
+ }
74
+
75
  /* استایل ورودی‌ها و دکمه‌ها */
76
  input, textarea, select, button {
77
  background-color: white !important;
 
79
  border: 1px solid #ccc !important;
80
  }
81
 
82
+ /* باکس خروجی: پس‌زمینه روشن و حاشیه مشکی */
83
  #output_box {
84
+ background-color: #f9f9f9 !important;
85
  color: black !important;
86
+ border: 1px solid #333 !important;
87
+ padding: 15px;
88
+ border-radius: 4px;
89
  }
90
 
91
  /* برداشتن تم تیره Gradio */
 
98
  with gr.Blocks(css=custom_css, theme="default") as app:
99
  # لوگوی شما
100
  gr.Image(value="logo.png", interactive=False, show_label=False)
101
+ # تیتر
102
  gr.Markdown("## 🎓 پیشنهادگر موضوع پایان‌نامه کاسپین")
103
 
104
  with gr.Row():