RomZay commited on
Commit
cba1cd6
·
verified ·
1 Parent(s): 0e5c78b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -11,7 +11,8 @@ headers = {
11
  "Content-Type": "application/json",
12
  }
13
 
14
- ASSISTANT_PIC_PATH = "./API.png"
 
15
 
16
  def respond(message, history, system_message, max_tokens, top_p, temperature):
17
  messages = []
@@ -47,7 +48,7 @@ def respond(message, history, system_message, max_tokens, top_p, temperature):
47
  if response.status_code == 200:
48
  response_json = response.json()
49
  assistant_reply = response_json["msq"]["message"][0]
50
- history.append((message, assistant_reply, "User", "Assistant", None, ASSISTANT_PIC_PATH))
51
  return history, assistant_reply
52
  else:
53
  return history, "Error: " + response.json().get("error", "Unknown error occurred.")
@@ -56,13 +57,13 @@ def render_message(history):
56
  messages_html = ""
57
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
58
  if user_message:
59
- messages_html += f"<div style='display: flex; align-items: center;'>"
60
  if user_pic:
61
  messages_html += f"<img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
62
  messages_html += f"<b>{user_profile}:</b> {user_message}</div><br>"
63
 
64
  if assistant_message:
65
- messages_html += f"<div style='display: flex; align-items: center;'>"
66
  if assistant_pic:
67
  messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
68
  messages_html += f"<b>{assistant_profile}:</b> {assistant_message}</div><br>"
 
11
  "Content-Type": "application/json",
12
  }
13
 
14
+ ASSISTANT_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/resolve/main/API.png"
15
+ USER_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/resolve/main/usr.png"
16
 
17
  def respond(message, history, system_message, max_tokens, top_p, temperature):
18
  messages = []
 
48
  if response.status_code == 200:
49
  response_json = response.json()
50
  assistant_reply = response_json["msq"]["message"][0]
51
+ history.append((message, assistant_reply, "You", "P-ALPLE", USER_PIC_PATH, ASSISTANT_PIC_PATH))
52
  return history, assistant_reply
53
  else:
54
  return history, "Error: " + response.json().get("error", "Unknown error occurred.")
 
57
  messages_html = ""
58
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
59
  if user_message:
60
+ messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
61
  if user_pic:
62
  messages_html += f"<img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
63
  messages_html += f"<b>{user_profile}:</b> {user_message}</div><br>"
64
 
65
  if assistant_message:
66
+ messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
67
  if assistant_pic:
68
  messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
69
  messages_html += f"<b>{assistant_profile}:</b> {assistant_message}</div><br>"