soojeongcrystal commited on
Commit
9d9c526
β€’
1 Parent(s): 7a733b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -14,8 +14,8 @@ model = SentenceTransformer('jhgan/ko-sbert-sts')
14
 
15
  # λ‚˜λˆ”λ°”λ₯Έκ³ λ”• 폰트 μ„€μ •
16
  font_path = "./NanumBarunGothic.ttf"
17
- fm.fontManager.addfont(font_path)
18
- plt.rc('font', family='NanumBarunGothic')
19
 
20
  # μ „μ—­ λ³€μˆ˜
21
  global_recommendations = None
@@ -195,7 +195,7 @@ def hybrid_rag(employee_file, program_file, youtube_file, title_col, description
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, filename="recommendations.csv"), gr.Button.update(visible=True)
199
 
200
  # μ±„νŒ… 응닡 ν•¨μˆ˜
201
  def chat_response(message, history):
@@ -209,6 +209,11 @@ def chat_response(message, history):
209
 
210
  return "μ£„μ†‘ν•©λ‹ˆλ‹€. ν•΄λ‹Ή μ§μ›μ˜ 정보λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€. λ‹€λ₯Έ 직원 이름을 μž…λ ₯ν•΄μ£Όμ„Έμš”."
211
 
 
 
 
 
 
212
  # Gradio 블둝
213
  with gr.Blocks(css=".gradio-button {background-color: #007bff; color: white;} .gradio-textbox {border-color: #6c757d;}") as demo:
214
  gr.Markdown("<h1 style='text-align: center; color: #2c3e50;'>πŸ’Ό HybridRAG μ‹œμŠ€ν…œ (유튜브 μ½˜ν…μΈ  포함)</h1>")
@@ -250,7 +255,7 @@ with gr.Blocks(css=".gradio-button {background-color: #007bff; color: white;} .g
250
  )
251
 
252
  # CSV λ‹€μš΄λ‘œλ“œ λ²„νŠΌ
253
- download_button.click(lambda: gr.File(value=global_csv_string, visible=True, filename="recommendations.csv"), inputs=[], outputs=[csv_download])
254
 
255
  # μ±„νŒ… κΈ°λŠ₯
256
  msg.submit(chat_response, [msg, chatbot], [chatbot])
 
14
 
15
  # λ‚˜λˆ”λ°”λ₯Έκ³ λ”• 폰트 μ„€μ •
16
  font_path = "./NanumBarunGothic.ttf"
17
+ font_prop = fm.FontProperties(fname=font_path)
18
+ plt.rcParams['font.family'] = font_prop.get_name()
19
 
20
  # μ „μ—­ λ³€μˆ˜
21
  global_recommendations = None
 
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):
 
209
 
210
  return "μ£„μ†‘ν•©λ‹ˆλ‹€. ν•΄λ‹Ή μ§μ›μ˜ 정보λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€. λ‹€λ₯Έ 직원 이름을 μž…λ ₯ν•΄μ£Όμ„Έμš”."
211
 
212
+ # CSV λ‹€μš΄λ‘œλ“œ ν•¨μˆ˜
213
+ def download_csv():
214
+ global global_csv_string
215
+ return gr.File(value=global_csv_string, visible=True)
216
+
217
  # Gradio 블둝
218
  with gr.Blocks(css=".gradio-button {background-color: #007bff; color: white;} .gradio-textbox {border-color: #6c757d;}") as demo:
219
  gr.Markdown("<h1 style='text-align: center; color: #2c3e50;'>πŸ’Ό HybridRAG μ‹œμŠ€ν…œ (유튜브 μ½˜ν…μΈ  포함)</h1>")
 
255
  )
256
 
257
  # CSV λ‹€μš΄λ‘œλ“œ λ²„νŠΌ
258
+ download_button.click(download_csv, inputs=[], outputs=[csv_download])
259
 
260
  # μ±„νŒ… κΈ°λŠ₯
261
  msg.submit(chat_response, [msg, chatbot], [chatbot])