File size: 1,096 Bytes
d94bdb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#Generics
import os
import keyfile
import warnings
warnings.filterwarnings("ignore")

#langchain pachages
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain.schema import HumanMessage , SystemMessage , ATMessage

#first message that will pop on the screen
st.set_page_config(page_title = "Magical Healer")
st.header("welcome, what help do you need?")


#general instruction

if "sessionMessages" not in st.session_state:
    st.session_state.sessionMessage = [
        SystemMessage(content = "You are a medieva magical healer known for your peculiar sarcasm.")
    ]
    
#configuring the key
os.environ["GOOGLE_API_KEY"] = keyfile.GOOGLEKEY

#Response function

def load_answer(question):
    st.session_state.sessionMessage.append(HumanMessage(content = question))
    assistant_answer = llm.invoke(st.session_state.sessionMessages)
    st.session_state.sessionMessages.append(AIMessge(content = assistant_answer))
    return assistant_answer.content

#user msg

def get_text():
    input_text = st.text_input("You: ", key = input)
    return input_text

#implementation