Jeong-hun Kim commited on
Commit
151bab0
ยท
1 Parent(s): 3f3ac87
Files changed (2) hide show
  1. core/launch_gradio.py +2 -2
  2. core/make_reply.py +1 -2
core/launch_gradio.py CHANGED
@@ -24,9 +24,9 @@ def create_interface(ctx: ContextManager, makePipeline: MakePipeline):
24
  def render_chat(ctx: ContextManager):
25
  html = ""
26
  for item in ctx.getHistory():
27
- if item["role"] == ctx.getUserName():
28
  html += f"<div class='bubble-right'>{item['text']}</div>"
29
- elif item["role"] == ctx.getBotName():
30
  html += f"<div class='bubble-left'>{item['text']}</div>"
31
  return gr.update(value=html)
32
 
 
24
  def render_chat(ctx: ContextManager):
25
  html = ""
26
  for item in ctx.getHistory():
27
+ if item["role"] == "user":
28
  html += f"<div class='bubble-right'>{item['text']}</div>"
29
+ elif item["role"] == "bot":
30
  html += f"<div class='bubble-left'>{item['text']}</div>"
31
  return gr.update(value=html)
32
 
core/make_reply.py CHANGED
@@ -23,6 +23,7 @@ def generate_valid_response(ctx, makePipeline, user_msg) -> str:
23
  prompt = build_prompt(ctx.getHistory(), user_msg, user_name, bot_name)
24
  full_text = makePipeline.character_chat(prompt)
25
  response = extract_response(full_text)
 
26
  if is_valid_response(response, user_name, bot_name):
27
  break
28
  return clean_response(response, bot_name)
@@ -62,8 +63,6 @@ def extract_response(full_text):
62
  def is_valid_response(text: str, user_name, bot_name) -> bool:
63
  if user_name + ":" in text:
64
  return False
65
- if bot_name + ":" in text:
66
- return False
67
  return True
68
 
69
  # ์‘๋‹ต ํ˜•์‹ ์ •๋ฆฌ
 
23
  prompt = build_prompt(ctx.getHistory(), user_msg, user_name, bot_name)
24
  full_text = makePipeline.character_chat(prompt)
25
  response = extract_response(full_text)
26
+ print(f"debug: {response}")
27
  if is_valid_response(response, user_name, bot_name):
28
  break
29
  return clean_response(response, bot_name)
 
63
  def is_valid_response(text: str, user_name, bot_name) -> bool:
64
  if user_name + ":" in text:
65
  return False
 
 
66
  return True
67
 
68
  # ์‘๋‹ต ํ˜•์‹ ์ •๋ฆฌ