Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
# μ§μ λ°μ΄ν°λ₯Ό λΆμνμ¬ κ΅μ‘ νλ‘κ·Έλ¨μ μΆμ²νκ³ κ²°κ³Όλ₯Ό μκ°ννλ ν¨μ | |
def analyze_data(employee_file, program_file): | |
# μ§μ λ°μ΄ν°μ κ΅μ‘ νλ‘κ·Έλ¨ λ°μ΄ν° λΆλ¬μ€κΈ° | |
employee_df = pd.read_csv(employee_file.name) | |
program_df = pd.read_csv(program_file.name) | |
# μ§μλ³ μΆμ² νλ‘κ·Έλ¨ λ¦¬μ€νΈ | |
recommendations = [] | |
for _, employee in employee_df.iterrows(): | |
recommended_programs = [] | |
for _, program in program_df.iterrows(): | |
# μ§μμ νμ¬ μλκ³Ό νμ΅ λͺ©νλ₯Ό κΈ°λ°μΌλ‘ μ ν©ν νλ‘κ·Έλ¨μ μΆμ² | |
if any(skill in program['skills_acquired'] for skill in employee['current_skills'].split(',')) or \ | |
employee['learning_goal'] in program['learning_objectives']: | |
recommended_programs.append(f"{program['program_name']} ({program['duration']})") | |
if recommended_programs: | |
recommendation = f"μ§μ {employee['employee_name']}μ μΆμ² νλ‘κ·Έλ¨: {', '.join(recommended_programs)}" | |
else: | |
recommendation = f"μ§μ {employee['employee_name']}μκ² μ ν©ν νλ‘κ·Έλ¨μ΄ μμ΅λλ€." | |
recommendations.append(recommendation) | |
# κ²°κ³Όλ₯Ό ν μ€νΈλ‘ λ°ν | |
result_text = "\n".join(recommendations) | |
# μκ°νμ© μ°¨νΈ μμ± | |
plt.figure(figsize=(8, 4)) | |
employee_roles = employee_df['current_role'].value_counts() | |
employee_roles.plot(kind='bar', color='skyblue') | |
plt.title('μ§μλ³ νμ¬ μ§λ¬΄ λΆν¬') | |
plt.xlabel('μ§λ¬΄') | |
plt.ylabel('μ§μ μ') | |
# μ°¨νΈλ₯Ό λ°ν | |
plt.tight_layout() | |
return result_text, plt.gcf() | |
# Gradio μΈν°νμ΄μ€ μ μ | |
def main(employee_file, program_file): | |
return analyze_data(employee_file, program_file) | |
# μ¬μ΄λλ°μμ νμΌ μ λ‘λ κΈ°λ₯ ꡬν | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
with gr.Column(scale=1): | |
gr.Markdown("# HybridRAG μμ€ν ") | |
gr.Markdown("λ κ°μ CSV νμΌμ μ λ‘λνμ¬ λΆμμ μ§ννμΈμ.") | |
employee_file = gr.File(label="μ§μ λ°μ΄ν° μ λ‘λ") | |
program_file = gr.File(label="κ΅μ‘ νλ‘κ·Έλ¨ λ°μ΄ν° μ λ‘λ") | |
analyze_button = gr.Button("λΆμ μμ") | |
output_text = gr.Textbox(label="λΆμ κ²°κ³Ό") | |
analyze_button.click(main, inputs=[employee_file, program_file], outputs=[output_text]) | |
with gr.Column(scale=2): | |
gr.Markdown("### μ 보 ν¨λ") | |
gr.Markdown("μ λ‘λλ λ°μ΄ν°μ λν λΆμ λ° κ²°κ³Όλ₯Ό μ¬κΈ°μ νμν©λλ€.") | |
# μκ°ν μ°¨νΈ μΆλ ₯ | |
chart_output = gr.Plot(label="μκ°ν μ°¨νΈ") | |
# λΆμ λ²νΌ ν΄λ¦ μ μ°¨νΈ μ λ°μ΄νΈ | |
analyze_button.click(main, inputs=[employee_file, program_file], outputs=[output_text, chart_output]) | |
# Gradio μΈν°νμ΄μ€ μ€ν | |
demo.launch() |