Spaces:
Sleeping
Sleeping
Update st1.py
Browse files
st1.py
CHANGED
|
@@ -3,27 +3,37 @@
|
|
| 3 |
|
| 4 |
# In[2]:
|
| 5 |
|
|
|
|
|
|
|
| 6 |
|
| 7 |
import streamlit as st
|
| 8 |
import requests as req
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
-
#
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
st.title("Welcome to shujath bot working as an mentor")
|
| 15 |
-
text=st.text_area(label="write your query",key="text_box")
|
| 16 |
-
b=st.button(label="submit")
|
| 17 |
if b:
|
| 18 |
-
json={"text":text}
|
| 19 |
-
res=req.post(
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
st.write(res.status_code)
|
| 22 |
st.write(res.json()["output"])
|
| 23 |
-
#CLEAR THE TEXT AREA
|
| 24 |
-
st.session_state.text_box = ""
|
| 25 |
-
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# In[ ]:
|
| 29 |
|
|
|
|
| 3 |
|
| 4 |
# In[2]:
|
| 5 |
|
| 6 |
+
# In[8]:
|
| 7 |
+
|
| 8 |
|
| 9 |
import streamlit as st
|
| 10 |
import requests as req
|
| 11 |
|
| 12 |
+
st.title("Welcome to shujath bot working as an mentor")
|
| 13 |
|
| 14 |
+
# track clearing
|
| 15 |
+
if "clear" not in st.session_state:
|
| 16 |
+
st.session_state.clear = False
|
| 17 |
|
| 18 |
+
text = st.text_area("write your query", key="text_box",
|
| 19 |
+
value="" if st.session_state.clear else None)
|
| 20 |
+
|
| 21 |
+
b = st.button("submit")
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
if b:
|
| 24 |
+
json = {"text": text}
|
| 25 |
+
res = req.post(
|
| 26 |
+
url="https://shujju786.app.n8n.cloud/webhook/20903516-7506-4c81-8394-d484641a98f0",
|
| 27 |
+
json=json
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
if res.status_code == 200:
|
| 31 |
st.write(res.status_code)
|
| 32 |
st.write(res.json()["output"])
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
# ✔ clear textarea on next rerun
|
| 35 |
+
st.session_state.clear = True
|
| 36 |
+
st.rerun()
|
| 37 |
|
| 38 |
# In[ ]:
|
| 39 |
|