Update app.py
Browse files
app.py
CHANGED
@@ -1,65 +1,3 @@
|
|
1 |
-
"""
|
2 |
-
import os
|
3 |
-
import keyfile
|
4 |
-
import warnings
|
5 |
-
import streamlit as st
|
6 |
-
from langchain_google_genai import ChatGoogleGenerativeAI
|
7 |
-
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
8 |
-
|
9 |
-
# Ignore warnings
|
10 |
-
warnings.filterwarnings("ignore")
|
11 |
-
|
12 |
-
# Streamlit settings
|
13 |
-
st.set_page_config(page_title="Magical Healer")
|
14 |
-
st.header("Welcome, What help do you need?")
|
15 |
-
|
16 |
-
# Initialize session state for messages
|
17 |
-
if "sessionMessages" not in st.session_state:
|
18 |
-
st.session_state["sessionMessages"] = [
|
19 |
-
SystemMessage(content="You are a medieval magical healer known for your peculiar sarcasm")
|
20 |
-
]
|
21 |
-
|
22 |
-
# Set Google API key
|
23 |
-
os.environ["GOOGLE_API_KEY"] = keyfile.GOOGLEKEY
|
24 |
-
|
25 |
-
# Initialize the model
|
26 |
-
llm = ChatGoogleGenerativeAI(
|
27 |
-
model="gemini-1.5-pro",
|
28 |
-
temperature=0.7,
|
29 |
-
convert_system_message_to_human=True
|
30 |
-
)
|
31 |
-
|
32 |
-
# Response function
|
33 |
-
def load_answer(question):
|
34 |
-
# Add user question to the message history
|
35 |
-
st.session_state.sessionMessages.append(HumanMessage(content=question))
|
36 |
-
|
37 |
-
# Get AI's response
|
38 |
-
assistant_answer = llm.invoke(st.session_state.sessionMessages)
|
39 |
-
|
40 |
-
# Append AI's answer to the session messages
|
41 |
-
if isinstance(assistant_answer, AIMessage):
|
42 |
-
st.session_state.sessionMessages.append(assistant_answer)
|
43 |
-
return assistant_answer.content
|
44 |
-
else:
|
45 |
-
st.session_state.sessionMessages.append(AIMessage(content=assistant_answer))
|
46 |
-
return assistant_answer
|
47 |
-
|
48 |
-
# Capture user input
|
49 |
-
def get_text():
|
50 |
-
input_text = st.text_input("You: ", key="input")
|
51 |
-
return str(input_text)
|
52 |
-
|
53 |
-
# Main implementation
|
54 |
-
user_input = get_text()
|
55 |
-
submit = st.button("Generate")
|
56 |
-
|
57 |
-
if submit and user_input:
|
58 |
-
response = load_answer(user_input)
|
59 |
-
st.subheader("Answer:")
|
60 |
-
st.write(response)
|
61 |
-
"""
|
62 |
-
|
63 |
import os
|
64 |
import keyfile
|
65 |
import warnings
|
@@ -73,7 +11,7 @@ warnings.filterwarnings("ignore")
|
|
73 |
# Streamlit settings
|
74 |
st.set_page_config(page_title="πΏ ArchanaCare π§ββοΈ", page_icon="π§ββοΈ", layout="centered")
|
75 |
st.markdown("<h1 style='text-align: center; color: #4B0082;'>Welcome to ArchanaCare πΏβ¨</h1>", unsafe_allow_html=True)
|
76 |
-
st.
|
77 |
|
78 |
# Adding vertical space without streamlit_extras
|
79 |
st.markdown("<br><br>", unsafe_allow_html=True)
|
@@ -162,5 +100,3 @@ st.markdown("""
|
|
162 |
}
|
163 |
</style>
|
164 |
""", unsafe_allow_html=True)
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import keyfile
|
3 |
import warnings
|
|
|
11 |
# Streamlit settings
|
12 |
st.set_page_config(page_title="πΏ ArchanaCare π§ββοΈ", page_icon="π§ββοΈ", layout="centered")
|
13 |
st.markdown("<h1 style='text-align: center; color: #4B0082;'>Welcome to ArchanaCare πΏβ¨</h1>", unsafe_allow_html=True)
|
14 |
+
st.markdown("<h3 style='color: #003366;'>How can I assist with your ailments or worries today? π§ͺπ«</h3>", unsafe_allow_html=True)
|
15 |
|
16 |
# Adding vertical space without streamlit_extras
|
17 |
st.markdown("<br><br>", unsafe_allow_html=True)
|
|
|
100 |
}
|
101 |
</style>
|
102 |
""", unsafe_allow_html=True)
|
|
|
|