codebyam commited on
Commit
5987209
·
verified ·
1 Parent(s): 70717a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -68,7 +68,7 @@ async def vote(vote_input: VoteInput):
68
  response = requests.post(f"{Url}/vote", json=data, timeout=10)
69
  response.raise_for_status()
70
  except requests.RequestException as e:
71
- raise HTTPException(status_code=502, detail=f"Failed to record vote: {str(e)}")
72
  return {"status": "success"}
73
 
74
 
@@ -881,6 +881,7 @@ async def read_items():
881
  const bodyDiv = document.createElement("div");
882
  bodyDiv.classList.add("card-body");
883
  bodyDiv.innerHTML = formatTextWithLineBreaks(text);
 
884
 
885
  const actionRow = document.createElement("div");
886
  actionRow.classList.add("action-row");
@@ -974,10 +975,13 @@ async def read_items():
974
  const messages = [];
975
  chatWindow.querySelectorAll(".message").forEach((msg) => {
976
  const role = msg.classList.contains("user-message") ? "user" : "bot";
977
- const textEl = msg.querySelector(".card-body") || msg.querySelector(".bubble");
978
- const text = textEl?.innerText || "";
979
- const withCopy = !!msg.querySelector(".output-card");
980
  const cardEl = msg.querySelector(".output-card");
 
 
 
 
981
  const uniqueId = cardEl?.dataset.uniqueId || null;
982
  const voted = cardEl?.dataset.voted || null;
983
  messages.push({ role, text, withCopy, uniqueId, voted });
 
68
  response = requests.post(f"{Url}/vote", json=data, timeout=10)
69
  response.raise_for_status()
70
  except requests.RequestException as e:
71
+ raise HTTPException(status_code=502, detail="Invalid")
72
  return {"status": "success"}
73
 
74
 
 
881
  const bodyDiv = document.createElement("div");
882
  bodyDiv.classList.add("card-body");
883
  bodyDiv.innerHTML = formatTextWithLineBreaks(text);
884
+ card.dataset.text = text;
885
 
886
  const actionRow = document.createElement("div");
887
  actionRow.classList.add("action-row");
 
975
  const messages = [];
976
  chatWindow.querySelectorAll(".message").forEach((msg) => {
977
  const role = msg.classList.contains("user-message") ? "user" : "bot";
978
+
979
+ let text;
 
980
  const cardEl = msg.querySelector(".output-card");
981
+ if (cardEl) {text = cardEl.dataset.text || "";
982
+ } else {text = msg.querySelector(".bubble")?.innerText || "";
983
+ }
984
+ const withCopy = !!cardEl;
985
  const uniqueId = cardEl?.dataset.uniqueId || null;
986
  const voted = cardEl?.dataset.voted || null;
987
  messages.push({ role, text, withCopy, uniqueId, voted });