min24ss commited on
Commit
95205b3
ยท
verified ยท
1 Parent(s): 9e7fc2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -77,13 +77,13 @@ choices = [
77
  "4. ์‹œ์Šคํ…œ์„ ๊ฑฐ๋ถ€ํ•˜๊ณ  ๊ทธ๋ƒฅ ๋„๋ง์นœ๋‹ค."
78
  ]
79
 
80
- def respond(message, history):
81
  try:
82
  sel_num = int(message.strip())
83
  if sel_num < 1 or sel_num > len(choices):
84
- return "โŒ ์˜ฌ๋ฐ”๋ฅธ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. (1~4)"
85
  except ValueError:
86
- return "โŒ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. (์˜ˆ: 1, 2, 3, 4)"
87
 
88
  user_choice = choices[sel_num - 1]
89
  result = qa_chain({"query": user_choice})
@@ -99,12 +99,18 @@ def respond(message, history):
99
  """
100
 
101
  response = llm_pipeline(prompt)[0]["generated_text"]
102
- return f"[์„ฑ์ง„์šฐ]\n{response}"
103
 
104
- # ====== Gradio ChatInterface ======
 
 
 
 
 
 
 
105
  demo = gr.ChatInterface(
106
  respond,
107
- title="์„ฑ์ง„์šฐ ์„ ํƒ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ (์นด์นด์˜คํ†ก ์Šคํƒ€์ผ)",
108
  description="1~4๋ฒˆ ์ค‘ ํ•˜๋‚˜๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์„ฑ์ง„์šฐ์˜ ์‘๋‹ต์ด ๋Œ€ํ™” ํ˜•์‹์œผ๋กœ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค."
109
  )
110
 
 
77
  "4. ์‹œ์Šคํ…œ์„ ๊ฑฐ๋ถ€ํ•˜๊ณ  ๊ทธ๋ƒฅ ๋„๋ง์นœ๋‹ค."
78
  ]
79
 
80
+ ddef respond(message, history):
81
  try:
82
  sel_num = int(message.strip())
83
  if sel_num < 1 or sel_num > len(choices):
84
+ return gr.ChatMessage(role="assistant", content="โŒ ์˜ฌ๋ฐ”๋ฅธ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. (1~4)")
85
  except ValueError:
86
+ return gr.ChatMessage(role="assistant", content="โŒ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. (์˜ˆ: 1, 2, 3, 4)")
87
 
88
  user_choice = choices[sel_num - 1]
89
  result = qa_chain({"query": user_choice})
 
99
  """
100
 
101
  response = llm_pipeline(prompt)[0]["generated_text"]
 
102
 
103
+ # ์‚ฌ์šฉ์ž ๋ฉ”์‹œ์ง€(์˜ค๋ฅธ์ชฝ)
104
+ user_msg = gr.ChatMessage(role="user", content=f"{sel_num}๋ฒˆ ์„ ํƒ ({user_choice})")
105
+ # ์„ฑ์ง„์šฐ ๋ฉ”์‹œ์ง€(์™ผ์ชฝ)
106
+ sjw_msg = gr.ChatMessage(role="assistant", content=response)
107
+
108
+ return [user_msg, sjw_msg]
109
+
110
+
111
  demo = gr.ChatInterface(
112
  respond,
113
+ title="์„ฑ์ง„์šฐ ์„ ํƒ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ (์นด์นด์˜คํ†ก ์Šคํƒ€์ผ, ์„ฑ์ง„์šฐ ์™ผ์ชฝ)",
114
  description="1~4๋ฒˆ ์ค‘ ํ•˜๋‚˜๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์„ฑ์ง„์šฐ์˜ ์‘๋‹ต์ด ๋Œ€ํ™” ํ˜•์‹์œผ๋กœ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค."
115
  )
116