SaileshSivan commited on
Commit
8f277d4
·
1 Parent(s): a624bec

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Doctor AI
2
+ import streamlit as st
3
+
4
+ from langchain.schema import HumanMessage,SystemMessage,AIMessage
5
+ from langchain.chat_models import ChatOpenAI
6
+
7
+ ## Streamlit UI
8
+ st.set_page_config(page_title="Conversational Q&A Chatbot")
9
+ st.header("Hey, Let's Chat")
10
+
11
+ from dotenv import load_dotenv
12
+ load_dotenv()
13
+ import os
14
+
15
+ chat=ChatOpenAI(temperature=0.5)
16
+
17
+ if 'flowmessages' not in st.session_state:
18
+ st.session_state['flowmessages'] = [
19
+ SystemMessage(content="Your are an AI Doctor assistant. A user will give an input of what he is suffering from or what health problem he has, you should suggest the user with correct medicine and tell the user how to recover fastly from it. Gve a short and sharp answer. If the input is different from a body or health issue or any other medical issues, tell the user who you are and ask the user to provide the appropriate input.")
20
+ ]
21
+
22
+ ## Function to load OpenAI model and get respones
23
+
24
+ def get_chatmodel_response(question):
25
+
26
+ st.session_state['flowmessages'].append(HumanMessage(content=question))
27
+ answer=chat(st.session_state['flowmessages'])
28
+ st.session_state['flowmessages'].append(AIMessage(content=answer.content))
29
+ return answer.content
30
+
31
+ input=st.text_input("Input: ",key="input")
32
+ response=get_chatmodel_response(input)
33
+
34
+ submit=st.button("Ask the question")
35
+
36
+ ## If ask button is clicked
37
+
38
+ if submit:
39
+ st.subheader("The Response is")
40
+ st.write(response)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ langchain
2
+ openai
3
+ huggingface_hub
4
+ python-dotenv
5
+ streamlit