Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from openai import OpenAI
|
|
4 |
from deep_translator import GoogleTranslator
|
5 |
|
6 |
# دریافت کلید از محیط (در Hugging Face از Secrets استفاده کن)
|
7 |
-
client = OpenAI(api_key=os.environ["
|
8 |
|
9 |
# تابع اصلی پیشنهاد موضوع پایاننامه
|
10 |
def generate_topics(field, major, keywords, audience, level):
|
@@ -19,7 +19,7 @@ def generate_topics(field, major, keywords, audience, level):
|
|
19 |
|
20 |
try:
|
21 |
completion = client.chat.completions.create(
|
22 |
-
model="gpt-
|
23 |
messages=[
|
24 |
{"role": "system", "content": "You are an academic advisor assistant."},
|
25 |
{"role": "user", "content": prompt}
|
@@ -43,7 +43,7 @@ def generate_topics(field, major, keywords, audience, level):
|
|
43 |
except Exception as e:
|
44 |
return f"<div style='color: red;'>❌ خطا در تماس با OpenAI API: {e}</div>"
|
45 |
|
46 |
-
# رابط کاربری Gradio با
|
47 |
iface = gr.Interface(
|
48 |
fn=generate_topics,
|
49 |
inputs=[
|
@@ -54,7 +54,7 @@ iface = gr.Interface(
|
|
54 |
gr.Dropdown(["کارشناسی ارشد", "دکتری"], label="مقطع")
|
55 |
],
|
56 |
outputs=gr.HTML(
|
57 |
-
label="موضوعات پیشنهادی",
|
58 |
elem_id="output_box"
|
59 |
),
|
60 |
title="🎓 پیشنهادگر موضوع پایاننامه کاسپین",
|
@@ -64,7 +64,8 @@ iface = gr.Interface(
|
|
64 |
min-height: 350px !important;
|
65 |
max-height: 600px !important;
|
66 |
overflow-y: auto !important;
|
67 |
-
background-color: #
|
|
|
68 |
padding: 20px;
|
69 |
border: 2px solid #ccc;
|
70 |
font-family: 'Tahoma', sans-serif;
|
|
|
4 |
from deep_translator import GoogleTranslator
|
5 |
|
6 |
# دریافت کلید از محیط (در Hugging Face از Secrets استفاده کن)
|
7 |
+
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"]) # ✅ درست شد
|
8 |
|
9 |
# تابع اصلی پیشنهاد موضوع پایاننامه
|
10 |
def generate_topics(field, major, keywords, audience, level):
|
|
|
19 |
|
20 |
try:
|
21 |
completion = client.chat.completions.create(
|
22 |
+
model="gpt-3.5-turbo", # ✅ مدل معتبر و قابل استفاده عمومی
|
23 |
messages=[
|
24 |
{"role": "system", "content": "You are an academic advisor assistant."},
|
25 |
{"role": "user", "content": prompt}
|
|
|
43 |
except Exception as e:
|
44 |
return f"<div style='color: red;'>❌ خطا در تماس با OpenAI API: {e}</div>"
|
45 |
|
46 |
+
# رابط کاربری Gradio با ظاهر اصلاحشده برای نمایش درست خروجی
|
47 |
iface = gr.Interface(
|
48 |
fn=generate_topics,
|
49 |
inputs=[
|
|
|
54 |
gr.Dropdown(["کارشناسی ارشد", "دکتری"], label="مقطع")
|
55 |
],
|
56 |
outputs=gr.HTML(
|
57 |
+
label="موضوعات پیشنهادی",
|
58 |
elem_id="output_box"
|
59 |
),
|
60 |
title="🎓 پیشنهادگر موضوع پایاننامه کاسپین",
|
|
|
64 |
min-height: 350px !important;
|
65 |
max-height: 600px !important;
|
66 |
overflow-y: auto !important;
|
67 |
+
background-color: #1e1e1e !important; /* پسزمینه تیره */
|
68 |
+
color: white !important; /* متن سفید */
|
69 |
padding: 20px;
|
70 |
border: 2px solid #ccc;
|
71 |
font-family: 'Tahoma', sans-serif;
|