chatbott / ch.py
shujath000's picture
Update ch.py
2191555 verified
raw
history blame contribute delete
777 Bytes
#!/usr/bin/env python
# coding: utf-8
# In[20]:
import streamlit as st
import requests as req
st.title("ai chat bot created by shujath ahmed")
prompt=st.chat_input(placeholder="please type something")
if "messages" not in st.session_state:
st.session_state["messages"]=[]
else:
res=req.post(url="https://shujju786.app.n8n.cloud/webhook/c6678b08-dd24-4b8f-946b-ed00b76f0b44",json = {"text":prompt})
if res.status_code==200:
d=res.json()
st.session_state["messages"].extend([prompt,d["output"]])
for index,mess in enumerate(st.session_state["messages"]):
if index%2==0:
with st.chat_message("user"):
st.write(mess)
else:
with st.chat_message("assistant"):
st.write(mess)
# In[ ]:
# In[ ]: