Spaces:
Sleeping
Sleeping
File size: 3,111 Bytes
1ec6c27 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
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() |