ldhldh commited on
Commit
d44468c
β€’
1 Parent(s): d0dbb47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -1,6 +1,5 @@
1
  from threading import Thread
2
  from huggingface_hub import hf_hub_download
3
- from llama_cpp import Llama
4
  import torch
5
  import gradio as gr
6
  import re
@@ -52,7 +51,7 @@ docsearch = FAISS.load_local("", embeddings)
52
  embeddings_filter = EmbeddingsFilter(
53
  embeddings=embeddings,
54
  similarity_threshold=0.7,
55
- k = 2,
56
  )
57
  # μ••μΆ• 검색기 생성
58
  compression_retriever = ContextualCompressionRetriever(
@@ -85,9 +84,14 @@ def gen(x, id, customer_data):
85
  index = len(id_list)
86
  id_list.append(id)
87
  customer_data_list.append(customer_data)
88
- customer_agree_list.append("No")
89
- history.append('상담원:무엇을 λ„μ™€λ“œλ¦΄κΉŒμš”?\n')
90
- bot_str = "* ν˜„μž¬ κ°€μž…μ •λ³΄λ₯Ό μ‘°νšŒν•  수 μ—†μŠ΅λ‹ˆλ‹€. λ¨Όμ € κ°œμΈμ •λ³΄ 이용 약관에 λ™μ˜ν•˜μ…”μ•Ό μ›ν™œν•œ 상담을 진행할 수 μžˆμŠ΅λ‹ˆλ‹€. \n무엇을 λ„μ™€λ“œλ¦΄κΉŒμš”?"
 
 
 
 
 
91
  return bot_str
92
  else:
93
  if x == "μ΄ˆκΈ°ν™”":
@@ -162,7 +166,8 @@ def gen(x, id, customer_data):
162
  {context}
163
 
164
  ### λͺ…λ Ήμ–΄:
165
- λ‹€μŒ 지침을 μ°Έκ³ ν•˜μ—¬ μƒλ‹΄μ›μœΌλ‘œμ„œ κ³ κ°μ—κ²Œ ν•„μš”ν•œ 응닡을 μ œκ³΅ν•˜μ„Έμš”.
 
166
  [지침]
167
  1.고객의 κ°€μž… 정보λ₯Ό κΌ­ ν™•μΈν•˜μ—¬ 고객이 κ°€μž…ν•œ λ³΄ν—˜μ— λŒ€ν•œ λ‚΄μš©λ§Œ μ œκ³΅ν•˜μ„Έμš”.
168
  2.고객이 κ°€μž…ν•œ λ³΄ν—˜μ΄λΌλ©΄ 고객의 μ§ˆλ¬Έμ— λŒ€ν•΄ 적절히 λ‹΅λ³€ν•˜μ„Έμš”.
@@ -199,6 +204,8 @@ def gen(x, id, customer_data):
199
  query=f"{customer_data_list[index]}, {x}"
200
  response = qa({"query":query})
201
  output_str = response['result'].rsplit(".")[0] + "."
 
 
202
  history[index] += f"고객:{x}\n상담원:{output_str}\n"
203
  if customer_agree_list[index] == "No":
204
  output_str = f"* ν˜„μž¬ κ°€μž…μ •λ³΄λ₯Ό μ‘°νšŒν•  수 μ—†μŠ΅λ‹ˆλ‹€. λ¨Όμ € κ°œμΈμ •λ³΄ 이용 약관에 λ™μ˜ν•˜μ…”μ•Ό μ›ν™œν•œ 상담을 진행할 수 μžˆμŠ΅λ‹ˆλ‹€." + output_str
@@ -228,4 +235,4 @@ with gr.Blocks() as demo:
228
  label="customer_data"
229
  )
230
  button_submit.click(gen, [user_text, id_text, customer_data], model_output)
231
- demo.queue().launch(enable_queue=True)
 
1
  from threading import Thread
2
  from huggingface_hub import hf_hub_download
 
3
  import torch
4
  import gradio as gr
5
  import re
 
51
  embeddings_filter = EmbeddingsFilter(
52
  embeddings=embeddings,
53
  similarity_threshold=0.7,
54
+ k = 3,
55
  )
56
  # μ••μΆ• 검색기 생성
57
  compression_retriever = ContextualCompressionRetriever(
 
84
  index = len(id_list)
85
  id_list.append(id)
86
  customer_data_list.append(customer_data)
87
+ if x != "μ•½κ΄€λ™μ˜_λ™μ˜ν•¨":
88
+ customer_agree_list.append("No")
89
+ history.append('상담원:무엇을 λ„μ™€λ“œλ¦΄κΉŒμš”?\n')
90
+ bot_str = "* ν˜„μž¬ κ°€μž…μ •λ³΄λ₯Ό μ‘°νšŒν•  수 μ—†μŠ΅λ‹ˆλ‹€. λ¨Όμ € κ°œμΈμ •λ³΄ 이용 약관에 λ™μ˜ν•˜μ…”μ•Ό μ›ν™œν•œ 상담을 진행할 수 μžˆμŠ΅λ‹ˆλ‹€. \n무엇을 λ„μ™€λ“œλ¦΄κΉŒμš”?"
91
+ else:
92
+ customer_agree_list.append("Yes")
93
+ history.append('상담원:무엇을 λ„μ™€λ“œλ¦΄κΉŒμš”?\n')
94
+ bot_str = f"κ°œμΈμ •λ³΄ ν™œμš©μ— λ™μ˜ν•˜μ…¨μŠ΅λ‹ˆλ‹€. κ°€μž… λ³΄ν—˜μ„ μ‘°νšŒν•©λ‹ˆλ‹€.\n\nν˜„μž¬ κ³ κ°λ‹˜κ»˜μ„œ κ°€μž…λœ λ³΄ν—˜μ€ {customer_data}μž…λ‹ˆλ‹€.\n\nκΆκΈˆν•˜μ‹  것이 μžˆμœΌμ‹ κ°€μš”?"
95
  return bot_str
96
  else:
97
  if x == "μ΄ˆκΈ°ν™”":
 
166
  {context}
167
 
168
  ### λͺ…λ Ήμ–΄:
169
+ λ‹€μŒ 지침을 μ°Έκ³ ν•˜μ—¬ μƒλ‹΄μ›μœΌλ‘œμ„œ κ³ κ°μ—κ²Œ ν•„μš”ν•œ 응닡을 μ΅œλŒ€ν•œ μžμ„Έν•˜κ²Œ μ œκ³΅ν•˜μ„Έμš”.
170
+
171
  [지침]
172
  1.고객의 κ°€μž… 정보λ₯Ό κΌ­ ν™•μΈν•˜μ—¬ 고객이 κ°€μž…ν•œ λ³΄ν—˜μ— λŒ€ν•œ λ‚΄μš©λ§Œ μ œκ³΅ν•˜μ„Έμš”.
173
  2.고객이 κ°€μž…ν•œ λ³΄ν—˜μ΄λΌλ©΄ 고객의 μ§ˆλ¬Έμ— λŒ€ν•΄ 적절히 λ‹΅λ³€ν•˜μ„Έμš”.
 
204
  query=f"{customer_data_list[index]}, {x}"
205
  response = qa({"query":query})
206
  output_str = response['result'].rsplit(".")[0] + "."
207
+ if output_str.split(":")[0]=="상담원":
208
+ output_str = output_str.split(":")[1]
209
  history[index] += f"고객:{x}\n상담원:{output_str}\n"
210
  if customer_agree_list[index] == "No":
211
  output_str = f"* ν˜„μž¬ κ°€μž…μ •λ³΄λ₯Ό μ‘°νšŒν•  수 μ—†μŠ΅λ‹ˆλ‹€. λ¨Όμ € κ°œμΈμ •λ³΄ 이용 약관에 λ™μ˜ν•˜μ…”μ•Ό μ›ν™œν•œ 상담을 진행할 수 μžˆμŠ΅λ‹ˆλ‹€." + output_str
 
235
  label="customer_data"
236
  )
237
  button_submit.click(gen, [user_text, id_text, customer_data], model_output)
238
+ demo.queue().launch(enable_queue=True)