Spaces:
Sleeping
Sleeping
Akshayram1
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -12,10 +12,8 @@ load_dotenv()
|
|
12 |
api_key = os.getenv("GENERATIVEAI_API_KEY")
|
13 |
genai.configure(api_key=api_key)
|
14 |
|
15 |
-
# Global variable to maintain chat session
|
16 |
chat = None
|
17 |
-
if 'chat_history' not in st.session_state:
|
18 |
-
st.session_state.chat_history = []
|
19 |
|
20 |
# Generation configuration and safety settings
|
21 |
generation_config = {
|
@@ -131,22 +129,14 @@ def text_summary(text, isNew=False):
|
|
131 |
st.title("Financial Summary Chatbot")
|
132 |
st.write("Welcome to the Financial Summary Chatbot! Enter your text below to get a financial summary.")
|
133 |
|
134 |
-
#
|
135 |
-
|
136 |
-
for entry in st.session_state.chat_history:
|
137 |
-
st.markdown(entry, unsafe_allow_html=True)
|
138 |
-
|
139 |
-
# User input area for prompt
|
140 |
-
user_input = st.text_area("Enter your text here:", "", key="input")
|
141 |
|
142 |
# Button to submit the text
|
143 |
if st.button("Get Summary"):
|
144 |
if user_input.strip():
|
145 |
summary = text_summary(user_input, isNew=True) # Start a new session each time
|
146 |
-
|
147 |
-
st.
|
148 |
-
st.session_state.chat_history.append(f"<strong>Bot:</strong><br/>{summary}<br/><br/>")
|
149 |
-
# Clear the text area
|
150 |
-
st.session_state.input = "" # Reset input state to empty
|
151 |
else:
|
152 |
st.warning("Please enter some text to summarize.")
|
|
|
12 |
api_key = os.getenv("GENERATIVEAI_API_KEY")
|
13 |
genai.configure(api_key=api_key)
|
14 |
|
15 |
+
# Global variable to maintain chat session
|
16 |
chat = None
|
|
|
|
|
17 |
|
18 |
# Generation configuration and safety settings
|
19 |
generation_config = {
|
|
|
129 |
st.title("Financial Summary Chatbot")
|
130 |
st.write("Welcome to the Financial Summary Chatbot! Enter your text below to get a financial summary.")
|
131 |
|
132 |
+
# Input area for user text
|
133 |
+
user_input = st.text_area("Enter your text here:", "")
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
# Button to submit the text
|
136 |
if st.button("Get Summary"):
|
137 |
if user_input.strip():
|
138 |
summary = text_summary(user_input, isNew=True) # Start a new session each time
|
139 |
+
st.write("### Summary:")
|
140 |
+
st.markdown(summary, unsafe_allow_html=True)
|
|
|
|
|
|
|
141 |
else:
|
142 |
st.warning("Please enter some text to summarize.")
|