Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
|
| 4 |
|
| 5 |
def get_response(user_input):
|
|
@@ -14,6 +14,10 @@ def get_response(user_input):
|
|
| 14 |
st.set_page_config(page_title= "Chat with Websites", page_icon="🤖")
|
| 15 |
|
| 16 |
st.title("Chat with Websites")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
#sidebar
|
|
@@ -23,14 +27,15 @@ with st.sidebar:
|
|
| 23 |
openai_apikey = st.text_input("Enter your OpenAI API key")
|
| 24 |
|
| 25 |
user_query = st.chat_input("Type your message here...")
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
|
| 36 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from langchain_core import AIMessage, HumanMessage
|
| 3 |
|
| 4 |
|
| 5 |
def get_response(user_input):
|
|
|
|
| 14 |
st.set_page_config(page_title= "Chat with Websites", page_icon="🤖")
|
| 15 |
|
| 16 |
st.title("Chat with Websites")
|
| 17 |
+
chat_history = [
|
| 18 |
+
AIMessage(content = "Hello, I am a bot. How can I help you"),
|
| 19 |
+
|
| 20 |
+
]
|
| 21 |
|
| 22 |
|
| 23 |
#sidebar
|
|
|
|
| 27 |
openai_apikey = st.text_input("Enter your OpenAI API key")
|
| 28 |
|
| 29 |
user_query = st.chat_input("Type your message here...")
|
| 30 |
+
if user_query is not None and user_query !="":
|
| 31 |
+
response = get_response(user_query)
|
| 32 |
+
chat_history.append(HumanMessage(content=user_query))
|
| 33 |
|
| 34 |
+
with st.chat_message("Human"):
|
| 35 |
+
st.write(user_query)
|
| 36 |
|
| 37 |
+
with st.chat_message("AI"):
|
| 38 |
+
st.write(response)
|
| 39 |
|
| 40 |
|
| 41 |
|