Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# استفاده از inference از Hugging Face
|
5 |
+
pipe = pipeline("text-generation", model="google/gemma-1.1-7b-it") # بهجای 27B چون رایگان نیست
|
6 |
+
|
7 |
+
def generate_topics(field, major, keywords, audience, level):
|
8 |
+
prompt = f"""
|
9 |
+
با توجه به اطلاعات زیر، چند موضوع مناسب برای پایاننامه پیشنهاد بده:
|
10 |
+
|
11 |
+
رشته: {field}
|
12 |
+
گرایش: {major}
|
13 |
+
کلیدواژهها: {keywords}
|
14 |
+
جامعه هدف: {audience}
|
15 |
+
مقطع: {level}
|
16 |
+
|
17 |
+
لطفاً ۳ موضوع پیشنهادی ارائه کن.
|
18 |
+
در پایان، بنویس:
|
19 |
+
برای مشاوره و راهنمایی تخصصی با گروه مشاوره کاسپین تماس بگیرید:
|
20 |
+
02188252497
|
21 |
+
"""
|
22 |
+
result = pipe(prompt, max_new_tokens=250)[0]['generated_text']
|
23 |
+
return result
|
24 |
+
|
25 |
+
iface = gr.Interface(
|
26 |
+
fn=generate_topics,
|
27 |
+
inputs=[
|
28 |
+
gr.Textbox(label="رشته"),
|
29 |
+
gr.Textbox(label="گرایش"),
|
30 |
+
gr.Textbox(label="کلیدواژهها"),
|
31 |
+
gr.Textbox(label="جامعه هدف"),
|
32 |
+
gr.Dropdown(choices=["کارشناسی ارشد", "دکتری"], label="مقطع")
|
33 |
+
],
|
34 |
+
outputs="text",
|
35 |
+
title="پیشنهادگر هوشمند موضوع پایاننامه کاسپین 🎓"
|
36 |
+
)
|
37 |
+
|
38 |
+
iface.launch()
|