File size: 1,389 Bytes
2543f2c
 
 
e816aeb
2543f2c
e816aeb
 
2543f2c
e816aeb
 
2543f2c
 
 
b98b6c1
 
 
 
 
 
2543f2c
 
e816aeb
 
2543f2c
b98b6c1
 
2543f2c
 
 
 
 
 
 
 
 
 
 
b98b6c1
2543f2c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import gradio as gr
from transformers import pipeline
from googletrans import Translator

# تولید موضوع به انگلیسی
text_generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b")

# ترجمه به فارسی با googletrans
translator = Translator()

def generate_topics(field, major, keywords, audience, level):
    prompt = f"""
Suggest 3 academic thesis topics based on the following information:
Field: {field}
Specialization: {major}
Keywords: {keywords}
Target audience: {audience}
Level: {level}
"""

    english_output = text_generator(prompt, max_new_tokens=256)[0]['generated_text']
    translated_output = translator.translate(english_output, src='en', dest='fa').text

    final_output = translated_output.strip() + "\n\n📢 برای مشاوره و راهنمایی تخصصی با گروه مشاوره کاسپین تماس بگیرید:\n02188252497"
    return final_output

iface = gr.Interface(
    fn=generate_topics,
    inputs=[
        gr.Textbox(label="رشته"),
        gr.Textbox(label="گرایش"),
        gr.Textbox(label="کلیدواژه‌ها"),
        gr.Textbox(label="جامعه هدف"),
        gr.Dropdown(choices=["کارشناسی ارشد", "دکتری"], label="مقطع")
    ],
    outputs="text",
    title="🎓 پیشنهادگر موضوع پایان‌نامه کاسپین"
)

iface.launch()