babelAI commited on
Commit
36a658e
Β·
verified Β·
1 Parent(s): 5a50e48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py CHANGED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+
4
+
5
+ from langchain.chat_models import ChatOpenAI
6
+ from langchain.schema import(
7
+ AIMessage,
8
+ HumanMessage,
9
+ SystemMessage
10
+ )
11
+
12
+ # From here down is all the Streamlit UI.
13
+ st.set_page_config(page_title="DataStreams' Chat Model", page_icon=":robot:")
14
+ st.header("μ•ˆλ…•ν•˜μ„Έμš”. μ €λŠ” λ°μ΄ν„°μŠ€νŠΈλ¦Όμ¦ˆμ—μ„œ μ œμž‘ν•œ κ³ ν˜ˆμ•• μ „λ¬Έ 상담 AI λŒ€ν™” λ΄‡μ΄μ—μš”.")
15
+
16
+
17
+
18
+ if "sessionMessages" not in st.session_state:
19
+ st.session_state.sessionMessages = [
20
+ SystemMessage(content="You are a renowned doctor specializing in hypertension.")
21
+ ]
22
+
23
+
24
+
25
+ def load_answer(question):
26
+
27
+ st.session_state.sessinMessages.append(HumanMessage(content=question))
28
+
29
+ assistant_answer = chat(st.session_state.sessionMessages)
30
+
31
+ st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
32
+
33
+ return assistant_answer.content
34
+
35
+
36
+ def get_text():
37
+ input_text = st.text_input("You: ", key= input)
38
+ return input_text