Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,6 @@ os.environ["LANGCHAIN_API_KEY"] = os.getenv('LANGSMITH_API')
|
|
21 |
|
22 |
UPLOAD_DIR = "uploaded_files"
|
23 |
|
24 |
-
|
25 |
def cleanup_files():
|
26 |
if os.path.isdir(UPLOAD_DIR):
|
27 |
shutil.rmtree(UPLOAD_DIR, ignore_errors=True)
|
@@ -123,7 +122,7 @@ if uploaded_file is not None:
|
|
123 |
embedding
|
124 |
)
|
125 |
|
126 |
-
template = '''You are WattBot, Wattpad's friendly chatbot assistant
|
127 |
|
128 |
prompt = ChatPromptTemplate.from_template(template)
|
129 |
retriever = vector_base.as_retriever()
|
@@ -160,5 +159,11 @@ if uploaded_file is not None:
|
|
160 |
unsafe_allow_html=True
|
161 |
)
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
if st.session_state.cleanup_done:
|
164 |
cleanup_files()
|
|
|
21 |
|
22 |
UPLOAD_DIR = "uploaded_files"
|
23 |
|
|
|
24 |
def cleanup_files():
|
25 |
if os.path.isdir(UPLOAD_DIR):
|
26 |
shutil.rmtree(UPLOAD_DIR, ignore_errors=True)
|
|
|
122 |
embedding
|
123 |
)
|
124 |
|
125 |
+
template = '''You are WattBot, Wattpad's friendly chatbot assistant, designed to help readers and writers with insightful answers about stories, writing tips, and the Wattpad platform. Please answer the {question} based only on the given {context}. If the question is unrelated to the context or beyond your knowledge, respond with "I'm not sure about that, but feel free to explore more on Wattpad!" Keep your responses concise, using a maximum of three sentences.'''
|
126 |
|
127 |
prompt = ChatPromptTemplate.from_template(template)
|
128 |
retriever = vector_base.as_retriever()
|
|
|
159 |
unsafe_allow_html=True
|
160 |
)
|
161 |
|
162 |
+
# Reset functionality
|
163 |
+
if st.button("Reset and Upload a New PDF"):
|
164 |
+
st.session_state.clear()
|
165 |
+
st.session_state.cleanup_done = False
|
166 |
+
st.experimental_rerun()
|
167 |
+
|
168 |
if st.session_state.cleanup_done:
|
169 |
cleanup_files()
|