Spaces:
Sleeping
Sleeping
soojeongcrystal
commited on
Commit
β’
ca15903
1
Parent(s):
9d9c526
Update app.py
Browse files
app.py
CHANGED
@@ -12,10 +12,11 @@ from datetime import datetime, timedelta
|
|
12 |
# νκ΅μ΄ μ²λ¦¬λ₯Ό μν KoSentence-BERT λͺ¨λΈ λ‘λ
|
13 |
model = SentenceTransformer('jhgan/ko-sbert-sts')
|
14 |
|
15 |
-
# λλλ°λ₯Έκ³ λ ν°νΈ μ€μ
|
16 |
font_path = "./NanumBarunGothic.ttf"
|
17 |
font_prop = fm.FontProperties(fname=font_path)
|
18 |
-
plt.rcParams['font.family'] =
|
|
|
|
|
19 |
|
20 |
# μ μ λ³μ
|
21 |
global_recommendations = None
|
@@ -31,16 +32,15 @@ def create_csv_string(recommendations):
|
|
31 |
writer.writerow(rec)
|
32 |
return output.getvalue()
|
33 |
|
34 |
-
# μ°¨νΈ μμ± ν¨μ
|
35 |
def create_chart(G):
|
36 |
plt.figure(figsize=(10, 8))
|
37 |
pos = nx.spring_layout(G)
|
38 |
nx.draw(G, pos, with_labels=True, node_color='lightblue', node_size=3000, font_size=10, font_weight='bold', edge_color='gray')
|
39 |
plt.title("μ§μκ³Ό νλ‘κ·Έλ¨ κ°μ κ΄κ³", fontsize=14, fontweight='bold')
|
40 |
-
plt.tight_layout()
|
41 |
|
42 |
buf = io.BytesIO()
|
43 |
-
plt.savefig(buf, format='png')
|
44 |
buf.seek(0)
|
45 |
plt.close()
|
46 |
return buf
|
@@ -76,8 +76,11 @@ def validate_and_get_columns(employee_df, program_df):
|
|
76 |
return None, employee_cols, program_cols
|
77 |
|
78 |
# μ νλΈ λ°μ΄ν° μ΄ μ ν ν¨μ
|
|
|
79 |
def select_youtube_columns(youtube_file):
|
80 |
global youtube_columns
|
|
|
|
|
81 |
youtube_df = pd.read_csv(youtube_file.name)
|
82 |
required_youtube_cols = ["title", "description", "url", "upload_date"]
|
83 |
youtube_columns = auto_match_columns(youtube_df, required_youtube_cols)
|
@@ -194,9 +197,9 @@ def hybrid_rag(employee_file, program_file, youtube_file, title_col, description
|
|
194 |
|
195 |
# κ²°κ³Ό ν
μ΄λΈ λ°μ΄ν°νλ μ μμ±
|
196 |
result_df = pd.DataFrame(recommendation_rows, columns=["Employee ID", "Employee Name", "Recommended Programs", "Recommended YouTube Content"])
|
197 |
-
|
198 |
-
return result_df, chart_buffer, gr.File(value=global_csv_string, visible=True), gr.Button.update(visible=True)
|
199 |
|
|
|
|
|
200 |
# μ±ν
μλ΅ ν¨μ
|
201 |
def chat_response(message, history):
|
202 |
global global_recommendations
|
|
|
12 |
# νκ΅μ΄ μ²λ¦¬λ₯Ό μν KoSentence-BERT λͺ¨λΈ λ‘λ
|
13 |
model = SentenceTransformer('jhgan/ko-sbert-sts')
|
14 |
|
|
|
15 |
font_path = "./NanumBarunGothic.ttf"
|
16 |
font_prop = fm.FontProperties(fname=font_path)
|
17 |
+
plt.rcParams['font.family'] = 'NanumBarunGothic'
|
18 |
+
plt.rcParams['font.sans-serif'] = ['NanumBarunGothic']
|
19 |
+
fm.fontManager.addfont(font_path)
|
20 |
|
21 |
# μ μ λ³μ
|
22 |
global_recommendations = None
|
|
|
32 |
writer.writerow(rec)
|
33 |
return output.getvalue()
|
34 |
|
|
|
35 |
def create_chart(G):
|
36 |
plt.figure(figsize=(10, 8))
|
37 |
pos = nx.spring_layout(G)
|
38 |
nx.draw(G, pos, with_labels=True, node_color='lightblue', node_size=3000, font_size=10, font_weight='bold', edge_color='gray')
|
39 |
plt.title("μ§μκ³Ό νλ‘κ·Έλ¨ κ°μ κ΄κ³", fontsize=14, fontweight='bold')
|
40 |
+
plt.tight_layout(pad=1.0)
|
41 |
|
42 |
buf = io.BytesIO()
|
43 |
+
plt.savefig(buf, format='png', bbox_inches='tight')
|
44 |
buf.seek(0)
|
45 |
plt.close()
|
46 |
return buf
|
|
|
76 |
return None, employee_cols, program_cols
|
77 |
|
78 |
# μ νλΈ λ°μ΄ν° μ΄ μ ν ν¨μ
|
79 |
+
|
80 |
def select_youtube_columns(youtube_file):
|
81 |
global youtube_columns
|
82 |
+
if youtube_file is None:
|
83 |
+
return [gr.Dropdown(choices=[], value="") for _ in range(4)]
|
84 |
youtube_df = pd.read_csv(youtube_file.name)
|
85 |
required_youtube_cols = ["title", "description", "url", "upload_date"]
|
86 |
youtube_columns = auto_match_columns(youtube_df, required_youtube_cols)
|
|
|
197 |
|
198 |
# κ²°κ³Ό ν
μ΄λΈ λ°μ΄ν°νλ μ μμ±
|
199 |
result_df = pd.DataFrame(recommendation_rows, columns=["Employee ID", "Employee Name", "Recommended Programs", "Recommended YouTube Content"])
|
|
|
|
|
200 |
|
201 |
+
return result_df, chart_buffer, gr.File(value=global_csv_string, visible=True), gr.Button(value="CSV λ€μ΄λ‘λ", visible=True)
|
202 |
+
|
203 |
# μ±ν
μλ΅ ν¨μ
|
204 |
def chat_response(message, history):
|
205 |
global global_recommendations
|