-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces a UI for a chat bot using the RAG service we developed previously. Testing done: ran locally --------- Signed-off-by: Gabriel Georgiev <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
459d6fc
commit 5aa78f1
Showing
3 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2021-2024 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import streamlit as st | ||
from question import get_api_response | ||
|
||
st.title("VDK Demo Chat Bot") | ||
|
||
# Initialize chat history | ||
if "messages" not in st.session_state: | ||
st.session_state.messages = [] | ||
|
||
# Display chat messages from history on app rerun | ||
for message in st.session_state.messages: | ||
with st.chat_message(message["role"]): | ||
st.markdown(message["content"]) | ||
|
||
# React to user input | ||
if prompt := st.chat_input("What is up?"): | ||
# Display user message in chat message container | ||
st.chat_message("user").markdown(prompt) | ||
# Add user message to chat history | ||
st.session_state.messages.append({"role": "user", "content": prompt}) | ||
|
||
response = get_api_response(prompt) | ||
# Display assistant response in chat message container | ||
with st.chat_message("assistant"): | ||
st.markdown(response) | ||
# Add assistant response to chat history | ||
st.session_state.messages.append({"role": "assistant", "content": response}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters