archana2324's picture
Create app.py
d94bdb4 verified
raw
history blame
1.1 kB
#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