iammuhammadfurqan commited on
Commit
0d72715
1 Parent(s): ab6200e

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +41 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Conversational Q&A Chatbot
2
+ import streamlit as st
3
+
4
+ from langchain.schema import HumanMessage,SystemMessage,AIMessage
5
+ from langchain.chat_models import ChatOpenAI
6
+ # from dotenv import load_dotenv
7
+
8
+ # load_dotenv() # take environment variables from .env.
9
+
10
+
11
+ ## Streamlit UI
12
+
13
+ st.set_page_config(page_title="Conversational Q&A ChatBot")
14
+ st.header("Hey, Let's Chat")
15
+
16
+ chat = ChatOpenAI(temperature=0.6)
17
+
18
+ if 'flowmessages' not in st.session_state:
19
+ st.session_state['flowmessages']=[
20
+ SystemMessage(content="Yor are a comedian AI assitant")
21
+ ]
22
+
23
+ ## Function to load OpenAI model and get respones
24
+
25
+ def get_chatmodel_response(question):
26
+
27
+ st.session_state['flowmessages'].append(HumanMessage(content=question))
28
+ answer=chat(st.session_state['flowmessages'])
29
+ st.session_state['flowmessages'].append(AIMessage(content=answer.content))
30
+ return answer.content
31
+
32
+ input=st.text_input("Input: ",key="input")
33
+ response=get_chatmodel_response(input)
34
+
35
+ submit=st.button("Ask the question")
36
+
37
+ ## If ask button is clicked
38
+
39
+ if submit:
40
+ st.subheader("The Response is")
41
+ st.write(response)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ openai
2
+ langchain
3
+ streamlit
4
+ huggingface_hub
5
+ python-dotenv