Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,12 +4,21 @@ from sentence_transformers import SentenceTransformer
|
|
| 4 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 5 |
import networkx as nx
|
| 6 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Sentence-BERT ๋ชจ๋ธ ๋ก๋
|
| 9 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# ์ง์ ๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ์ฌ ๊ต์ก ํ๋ก๊ทธ๋จ์ ์ถ์ฒํ๊ณ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ๋ ํจ์
|
| 12 |
-
def analyze_data(employee_file, program_file):
|
| 13 |
# ์ง์ ๋ฐ์ดํฐ์ ๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ๋ถ๋ฌ์ค๊ธฐ
|
| 14 |
employee_df = pd.read_csv(employee_file.name)
|
| 15 |
program_df = pd.read_csv(program_file.name)
|
|
@@ -36,6 +45,9 @@ def analyze_data(employee_file, program_file):
|
|
| 36 |
else:
|
| 37 |
recommendation = f"์ง์ {employee['employee_name']}์๊ฒ ์ ํฉํ ํ๋ก๊ทธ๋จ์ด ์์ต๋๋ค."
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
recommendations.append(recommendation)
|
| 40 |
|
| 41 |
# ๊ฒฐ๊ณผ ํ
์คํธ
|
|
@@ -64,22 +76,56 @@ def analyze_data(employee_file, program_file):
|
|
| 64 |
return result_text, plt.gcf()
|
| 65 |
|
| 66 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
| 67 |
-
def main(employee_file, program_file):
|
| 68 |
-
return analyze_data(employee_file, program_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
# Gradio ๋ธ๋ก
|
| 71 |
with gr.Blocks() as demo:
|
| 72 |
with gr.Row():
|
| 73 |
with gr.Column(scale=1):
|
| 74 |
gr.Markdown("# HybridRAG ์์คํ
")
|
| 75 |
-
gr.Markdown("๋ ๊ฐ์ CSV ํ์ผ์ ์
๋ก๋ํ์ฌ ๋ถ์์ ์งํํ์ธ์.")
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
analyze_button = gr.Button("๋ถ์ ์์")
|
| 80 |
output_text = gr.Textbox(label="๋ถ์ ๊ฒฐ๊ณผ")
|
| 81 |
|
| 82 |
-
analyze_button.click(main, inputs=[employee_file, program_file], outputs=[output_text])
|
| 83 |
|
| 84 |
with gr.Column(scale=2):
|
| 85 |
gr.Markdown("### ์ ๋ณด ํจ๋")
|
|
@@ -89,7 +135,7 @@ with gr.Blocks() as demo:
|
|
| 89 |
chart_output = gr.Plot(label="์๊ฐํ ์ฐจํธ")
|
| 90 |
|
| 91 |
# ๋ถ์ ๋ฒํผ ํด๋ฆญ ์ ์ฐจํธ ์
๋ฐ์ดํธ
|
| 92 |
-
analyze_button.click(main, inputs=[employee_file, program_file], outputs=[output_text, chart_output])
|
| 93 |
|
| 94 |
# Gradio ์ธํฐํ์ด์ค ์คํ
|
| 95 |
demo.launch()
|
|
|
|
| 4 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 5 |
import networkx as nx
|
| 6 |
import matplotlib.pyplot as plt
|
| 7 |
+
import csv
|
| 8 |
+
import datetime
|
| 9 |
|
| 10 |
# Sentence-BERT ๋ชจ๋ธ ๋ก๋
|
| 11 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 12 |
|
| 13 |
+
# ์ถ์ฒ ๊ฒฐ๊ณผ์ ํผ๋๋ฐฑ์ ๊ธฐ๋กํ๋ ํจ์
|
| 14 |
+
def log_recommendation(employee_name, recommended_programs, feedback=None):
|
| 15 |
+
with open('recommendation_log.csv', mode='a', newline='') as file:
|
| 16 |
+
writer = csv.writer(file)
|
| 17 |
+
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 18 |
+
writer.writerow([timestamp, employee_name, recommended_programs, feedback])
|
| 19 |
+
|
| 20 |
# ์ง์ ๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ์ฌ ๊ต์ก ํ๋ก๊ทธ๋จ์ ์ถ์ฒํ๊ณ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ๋ ํจ์
|
| 21 |
+
def analyze_data(employee_file, program_file, feedback=None):
|
| 22 |
# ์ง์ ๋ฐ์ดํฐ์ ๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ๋ถ๋ฌ์ค๊ธฐ
|
| 23 |
employee_df = pd.read_csv(employee_file.name)
|
| 24 |
program_df = pd.read_csv(program_file.name)
|
|
|
|
| 45 |
else:
|
| 46 |
recommendation = f"์ง์ {employee['employee_name']}์๊ฒ ์ ํฉํ ํ๋ก๊ทธ๋จ์ด ์์ต๋๋ค."
|
| 47 |
|
| 48 |
+
# ํผ๋๋ฐฑ ๋ก๊ทธ ๊ธฐ๋ก
|
| 49 |
+
log_recommendation(employee['employee_name'], recommended_programs, feedback)
|
| 50 |
+
|
| 51 |
recommendations.append(recommendation)
|
| 52 |
|
| 53 |
# ๊ฒฐ๊ณผ ํ
์คํธ
|
|
|
|
| 76 |
return result_text, plt.gcf()
|
| 77 |
|
| 78 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
| 79 |
+
def main(employee_file, program_file, feedback):
|
| 80 |
+
return analyze_data(employee_file, program_file, feedback)
|
| 81 |
+
|
| 82 |
+
# ์์ ๋ฐ์ดํฐ๋ฅผ ๋ณด์ฌ์ฃผ๋ ํจ์
|
| 83 |
+
def show_example_data():
|
| 84 |
+
employee_example = pd.DataFrame({
|
| 85 |
+
'employee_id': ['001', '002'],
|
| 86 |
+
'employee_name': ['ํ๊ธธ๋', '๊น์ํฌ'],
|
| 87 |
+
'current_role': ['๋ฐ์ดํฐ ๋ถ์๊ฐ', '๋ง์ผํ
๋งค๋์ '],
|
| 88 |
+
'current_skills': ['Python, SQL, ๋ฐ์ดํฐ ์๊ฐํ', '๋ง์ผํ
์ ๋ต, ๋ฐ์ดํฐ ๋ถ์'],
|
| 89 |
+
'past_training': ['Python ๊ธฐ๋ณธ ๊ณผ์ , SQL ์ค๊ธ', '๋ฐ์ดํฐ ๋ถ์ ๊ธฐ์ด ๊ณผ์ '],
|
| 90 |
+
'performance_review': ['์ฑ๊ณผ ์ฐ์', '์ฑ๊ณผ ์ข์'],
|
| 91 |
+
'learning_goal': ['๋จธ์ ๋ฌ๋ ๊ธฐ์ด ํ์ต', '๊ณ ๊ธ ๋ฐ์ดํฐ ๋ถ์ ๊ธฐ์ ํ์ต']
|
| 92 |
+
})
|
| 93 |
+
|
| 94 |
+
program_example = pd.DataFrame({
|
| 95 |
+
'program_id': ['101', '102'],
|
| 96 |
+
'program_name': ['Python ๊ณ ๊ธ ๊ณผ์ ', '๋ฐ์ดํฐ ์๊ฐํ ์ฌํ ๊ณผ์ '],
|
| 97 |
+
'learning_objectives': ['Python ๊ณ ๊ธ ๊ธฐ์ ์ต๋', '๋ฐ์ดํฐ ์๊ฐํ ๋๊ตฌ ์ฌ์ฉ๋ฒ ์์ง'],
|
| 98 |
+
'skills_acquired': ['Python ๊ณ ๊ธ, ๋ฐ์ดํฐ ์ฒ๋ฆฌ', 'Tableau, ๋ฐ์ดํฐ ์๊ฐํ ๋๊ตฌ'],
|
| 99 |
+
'prerequisites': ['Python ๊ธฐ์ด', '๋ฐ์ดํฐ ์๊ฐํ ๊ธฐ์ด'],
|
| 100 |
+
'duration': ['4์ฃผ', '2์ฃผ'],
|
| 101 |
+
'learning_outcome': ['๋๊ท๋ชจ ๋ฐ์ดํฐ ๋ถ์ ๋ฅ๋ ฅ', '์๊ฐํ ๊ฒฐ๊ณผ๋ฌผ ์์ฑ ๋ฅ๋ ฅ']
|
| 102 |
+
})
|
| 103 |
+
|
| 104 |
+
return employee_example, program_example
|
| 105 |
|
| 106 |
# Gradio ๋ธ๋ก
|
| 107 |
with gr.Blocks() as demo:
|
| 108 |
with gr.Row():
|
| 109 |
with gr.Column(scale=1):
|
| 110 |
gr.Markdown("# HybridRAG ์์คํ
")
|
| 111 |
+
gr.Markdown("๋ ๊ฐ์ CSV ํ์ผ์ ์ข์ธก ์ฌ์ด๋๋ฐ์์ ์
๋ก๋ํ์ฌ ๋ถ์์ ์งํํ์ธ์.")
|
| 112 |
|
| 113 |
+
# ์ฌ์ด๋๋ฐ์ ํ์ผ ์
๋ก๋ ์ต์
์ถ๊ฐ
|
| 114 |
+
with gr.Sidebar():
|
| 115 |
+
employee_file = gr.File(label="์ง์ ๋ฐ์ดํฐ ์
๋ก๋")
|
| 116 |
+
program_file = gr.File(label="๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ์
๋ก๋")
|
| 117 |
+
feedback_input = gr.Radio(choices=["๋ง์กฑ", "๋ถ๋ง์กฑ"], label="์ถ์ฒ ๊ฒฐ๊ณผ์ ๋ํ ํผ๋๋ฐฑ")
|
| 118 |
+
|
| 119 |
+
# ์์ ๋ฐ์ดํฐ๋ฅผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ก ์ ๊ณต
|
| 120 |
+
example_button = gr.Button("์์ ๋ฐ์ดํฐ ๋ณด๊ธฐ")
|
| 121 |
+
employee_example_output = gr.DataFrame(label="์ง์ ๋ฐ์ดํฐ ์์")
|
| 122 |
+
program_example_output = gr.DataFrame(label="๊ต์ก ํ๋ก๊ทธ๋จ ๋ฐ์ดํฐ ์์")
|
| 123 |
+
example_button.click(show_example_data, outputs=[employee_example_output, program_example_output])
|
| 124 |
+
|
| 125 |
analyze_button = gr.Button("๋ถ์ ์์")
|
| 126 |
output_text = gr.Textbox(label="๋ถ์ ๊ฒฐ๊ณผ")
|
| 127 |
|
| 128 |
+
analyze_button.click(main, inputs=[employee_file, program_file, feedback_input], outputs=[output_text])
|
| 129 |
|
| 130 |
with gr.Column(scale=2):
|
| 131 |
gr.Markdown("### ์ ๋ณด ํจ๋")
|
|
|
|
| 135 |
chart_output = gr.Plot(label="์๊ฐํ ์ฐจํธ")
|
| 136 |
|
| 137 |
# ๋ถ์ ๋ฒํผ ํด๋ฆญ ์ ์ฐจํธ ์
๋ฐ์ดํธ
|
| 138 |
+
analyze_button.click(main, inputs=[employee_file, program_file, feedback_input], outputs=[output_text, chart_output])
|
| 139 |
|
| 140 |
# Gradio ์ธํฐํ์ด์ค ์คํ
|
| 141 |
demo.launch()
|