NegotiateAI / src /utils /writer.py
Rahka's picture
upload version 2
0988abd verified
raw
history blame
1.43 kB
import time
import streamlit as st
def typewriter(text: str, references: list, speed: int, app: str = "inc"):
tokens = text.split()
container = st.empty()
for index in range(len(tokens) + 1):
curr_full_text = " ".join(tokens[:index])
container.markdown(curr_full_text)
time.sleep(1 / speed)
curr_full_text += "\n"
container.markdown(curr_full_text)
if app == "knowledge_hub":
curr_full_text += "\n **Note:** \n"
curr_full_text += "\n"
curr_full_text += "This response is generated based on the available documents in the database and may not represent a comprehensive or definitive view of the topic. For complete and accurate scientific knowledge, consider consulting the original papers or additional sources. If the answer indicates that no response is possible, you may consider using a different filter or trying without any filter at all. \n"
container.markdown(curr_full_text)
if app == "inc":
curr_full_text += "\n **Note:** \n"
curr_full_text += "\n"
curr_full_text += "If the answer is that no response is possible, you may consider applying a different filter. \n"
container.markdown(curr_full_text)
curr_full_text += "\n **References** \n"
curr_full_text += "\n"
container.markdown(curr_full_text)
curr_full_text += "\n".join(references)
container.markdown(curr_full_text)