Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,8 @@ chatbot_url = "https://nlprocessor.us/projectchatbot.html#chatbot"
|
|
| 8 |
# Embed the chatbot using an iframe
|
| 9 |
iframe_code = f'<iframe src="{chatbot_url}" width="100%" height="600px" style="border:none;"></iframe>'
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
def send_message_to_rasa(message):
|
| 14 |
"""Sends a message to the Rasa chatbot and returns the response."""
|
|
@@ -35,7 +36,7 @@ def main():
|
|
| 35 |
if "text" in response:
|
| 36 |
st.session_state["chat_history"].append({"sender": "bot", "text": response["text"]})
|
| 37 |
|
| 38 |
-
st.session_state["user_input"] = ""
|
| 39 |
|
| 40 |
# Display chat history
|
| 41 |
for message in st.session_state["chat_history"]:
|
|
@@ -45,4 +46,4 @@ def main():
|
|
| 45 |
st.write(f"**Bot:** {message['text']}")
|
| 46 |
|
| 47 |
if __name__ == "__main__":
|
| 48 |
-
main()
|
|
|
|
| 8 |
# Embed the chatbot using an iframe
|
| 9 |
iframe_code = f'<iframe src="{chatbot_url}" width="100%" height="600px" style="border:none;"></iframe>'
|
| 10 |
|
| 11 |
+
# Use Streamlit's built-in components module
|
| 12 |
+
st.components.v1.html(iframe_code, height=600)
|
| 13 |
|
| 14 |
def send_message_to_rasa(message):
|
| 15 |
"""Sends a message to the Rasa chatbot and returns the response."""
|
|
|
|
| 36 |
if "text" in response:
|
| 37 |
st.session_state["chat_history"].append({"sender": "bot", "text": response["text"]})
|
| 38 |
|
| 39 |
+
st.session_state["user_input"] = "" # Clear the input box
|
| 40 |
|
| 41 |
# Display chat history
|
| 42 |
for message in st.session_state["chat_history"]:
|
|
|
|
| 46 |
st.write(f"**Bot:** {message['text']}")
|
| 47 |
|
| 48 |
if __name__ == "__main__":
|
| 49 |
+
main()
|