Skip to content

Commit

Permalink
fix: feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisVLRT committed Jan 29, 2024
1 parent 8f5de4c commit 03bb36e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions frontend/lib/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ def chat():
len(st.session_state.get("messages", [])) > 0
and len(st.session_state.get("messages")) % 2 == 0
):
chat_id = st.session_state.get("chat_id")
get_chat(st.session_state.get("messages")[-1].chat_id)
messages = [Message(**message) for message in get_chat(chat_id)["messages"]]
streamlit_feedback(
key=str(len(st.session_state.get("messages"))),
key=str(len(messages)),
feedback_type="thumbs",
on_submit=lambda feedback: send_feedback(st.session_state.get("messages")[-1].id, feedback),
on_submit=lambda feedback: send_feedback(messages[-1].id, feedback),
)


Expand All @@ -80,3 +83,7 @@ def send_prompt(message: Message):
def send_feedback(message_id: str, feedback: str):
feedback = "thumbs_up" if feedback["score"] == "👍" else "thumbs_down"
return query("post", f"/feedback/{message_id}/{feedback}").text

def get_chat(chat_id: str):
chat = query("get", f"/chat/{chat_id}").json()
return chat
3 changes: 2 additions & 1 deletion frontend/lib/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ def list_chats():
return query("get", "/chat/list").json()

def get_chat(chat_id: str):
return query("get", f"/chat/{chat_id}").json()
chat = query("get", f"/chat/{chat_id}").json()
return chat

0 comments on commit 03bb36e

Please sign in to comment.