Gauri-tr commited on
Commit
a329093
·
verified ·
1 Parent(s): e56a6df

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from dotenv import load_dotenv
3
+ from langchainAI import get_langchain_response
4
+
5
+ load_dotenv()
6
+ st.set_page_config(page_title="Conversation helper")
7
+ st.header("Let's talk! :)")
8
+
9
+ if "messages" not in st.session_state:
10
+ st.session_state.messages = []
11
+
12
+
13
+ for message in st.session_state.messages:
14
+ with st.chat_message(message["role"]):
15
+ st.markdown(message["content"])
16
+
17
+ if prompt := st.chat_input("How can I help?"):
18
+
19
+ st.session_state.messages.append({"role": "user", "content": prompt})
20
+
21
+ with st.chat_message("user"):
22
+ st.markdown(prompt)
23
+
24
+ with st.chat_message("assistant"):
25
+ with st.spinner("Thinking..."):
26
+ response = get_langchain_response(prompt)
27
+ st.write(response)
28
+
29
+ # Update chat history with assistant's response
30
+ message = {"role": "assistant", "content": response}
31
+ st.session_state.messages.append(message)