Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,10 +43,12 @@ def generate_topics(field, major, keywords, audience, level):
|
|
| 43 |
max_tokens=512
|
| 44 |
)
|
| 45 |
english_output = response.choices[0].message.content.strip()
|
|
|
|
| 46 |
try:
|
| 47 |
translated = GoogleTranslator(source='en', target='fa').translate(english_output)
|
| 48 |
except:
|
| 49 |
translated = english_output
|
|
|
|
| 50 |
items = [f"<li>{line}</li>" for line in translated.split("\n") if line.strip()]
|
| 51 |
translated_html = "<ol>" + "".join(items) + "</ol>"
|
| 52 |
|
|
@@ -57,41 +59,24 @@ def generate_topics(field, major, keywords, audience, level):
|
|
| 57 |
"<strong>021-88252497</strong>"
|
| 58 |
"</div>"
|
| 59 |
)
|
|
|
|
| 60 |
except Exception as e:
|
| 61 |
return f"<div style='color: red;'>❌ خطا در تماس با مدل DeepSeek: {e}</div>"
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
background-color: #1e1e1e !important;
|
| 70 |
-
color: white !important;
|
| 71 |
-
padding: 20px;
|
| 72 |
-
border: 2px solid #ccc;
|
| 73 |
-
font-family: 'Tahoma', sans-serif;
|
| 74 |
-
font-size: 16px;
|
| 75 |
-
text-align: right;
|
| 76 |
-
direction: rtl;
|
| 77 |
-
line-height: 1.8;
|
| 78 |
-
}
|
| 79 |
-
"""
|
| 80 |
|
| 81 |
-
with gr.Blocks(css=css, title="🎓 پیشنهادگر موضوع پایاننامه کاسپین") as app:
|
| 82 |
-
# لوگو بالای صفحه
|
| 83 |
-
gr.HTML(
|
| 84 |
-
"<div style='text-align:center;margin-bottom:10px;'>"
|
| 85 |
-
"<img src='/file=logo.png' width='200'/>"
|
| 86 |
-
"</div>"
|
| 87 |
-
)
|
| 88 |
with gr.Row():
|
| 89 |
with gr.Column():
|
| 90 |
field = gr.Textbox(label="رشته", placeholder="مثال: کامپیوتر")
|
| 91 |
major = gr.Textbox(label="گرایش", placeholder="مثال: هوش مصنوعی")
|
| 92 |
keywords = gr.Textbox(label="کلیدواژهها", placeholder="مثال: یادگیری عمیق، بینایی ماشین")
|
| 93 |
audience = gr.Textbox(label="جامعه هدف", placeholder="مثال: دانشجویان دکتری")
|
| 94 |
-
level = gr.Dropdown(["کارشناسی ارشد","دکتری"], label="مقطع")
|
| 95 |
submit = gr.Button("🎯 پیشنهاد موضوع")
|
| 96 |
with gr.Column():
|
| 97 |
output = gr.HTML(elem_id="output_box")
|
|
|
|
| 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:
|
| 50 |
translated = english_output
|
| 51 |
+
|
| 52 |
items = [f"<li>{line}</li>" for line in translated.split("\n") if line.strip()]
|
| 53 |
translated_html = "<ol>" + "".join(items) + "</ol>"
|
| 54 |
|
|
|
|
| 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 |
+
# اینجا کد Blocks با نمایش لوگو
|
| 67 |
+
with gr.Blocks(theme="default") as app:
|
| 68 |
+
# خط اول: لوگوی شما
|
| 69 |
+
gr.Image(value="logo.png", interactive=False, show_label=False)
|
| 70 |
+
|
| 71 |
+
gr.Markdown("## 🎓 پیشنهادگر موضوع پایاننامه کاسپین")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
with gr.Row():
|
| 74 |
with gr.Column():
|
| 75 |
field = gr.Textbox(label="رشته", placeholder="مثال: کامپیوتر")
|
| 76 |
major = gr.Textbox(label="گرایش", placeholder="مثال: هوش مصنوعی")
|
| 77 |
keywords = gr.Textbox(label="کلیدواژهها", placeholder="مثال: یادگیری عمیق، بینایی ماشین")
|
| 78 |
audience = gr.Textbox(label="جامعه هدف", placeholder="مثال: دانشجویان دکتری")
|
| 79 |
+
level = gr.Dropdown(["کارشناسی ارشد", "دکتری"], label="مقطع")
|
| 80 |
submit = gr.Button("🎯 پیشنهاد موضوع")
|
| 81 |
with gr.Column():
|
| 82 |
output = gr.HTML(elem_id="output_box")
|