import gradio as gr from transformers import pipeline # Hugging Face 모델 저장소에서 모델을 다운로드하여 초기화 generator = pipeline('text-generation', model='facebook/bart-base') def generate_self_introduction(job, strength, weakness, major, experience): # 입력 키워드 처리 job = job.strip() strength = [s.strip() for s in strength.split(',')] weakness = [w.strip() for w in weakness.split(',')] major = major.strip() experience = [e.strip() for e in experience.split(',')] # 자기소개서 생성 intro = f'안녕하세요, {job} 직무에 지원하는 [이름]입니다.\n' intro += f'저는 {major} 전공 출신으로 {experience[0]} 경험이 있습니다.\n' intro += f'저의 성격 장점은 {", ".join(strength)}입니다.\n' intro += f'저의 성격 단점은 {", ".join(weakness)}입니다.\n' intro += generator(job, max_length=1024, num_return_sequences=1)[0]['generated_text'][:500] # 최대 길이를 1024로 제한하고, 500자까지만 출력 return intro # Gradio 인터페이스 생성 iface = gr.Interface( fn=generate_self_introduction, inputs=[ gr.Textbox(label='취업할 직무 이름'), gr.Textbox(label='나의 성격 장점 (콤마로 구분)'), gr.Textbox(label='나의 성격 단점 (콤마로 구분)'), gr.Textbox(label='전공'), gr.Textbox(label='대외활동 경험 (콤마로 구분)'), ], outputs=gr.Textbox(label='자기소개서'), title='자기소개서 생성 서비스', description='취업할 직무 이름, 나의 성격 장점, 나의 성격 단점, 전공, 대외활동 경험을 입력하여 자기소개서를 생성합니다.' ) # Gradio 애플리케이션 실행 iface.launch()