Update app.py
Browse files
app.py
CHANGED
@@ -117,7 +117,6 @@ def image_chat():
|
|
117 |
st.subheader("Gemini Pro Response:")
|
118 |
st.write(response_gemini)
|
119 |
|
120 |
-
# Function to display Q&A Chat application
|
121 |
def qa_chat():
|
122 |
st.header("Q&A Chat Application")
|
123 |
# Initialize session state for chat history if it doesn't exist
|
@@ -125,4 +124,28 @@ def qa_chat():
|
|
125 |
st.session_state['chat_history'] = []
|
126 |
|
127 |
input_qa = st.text_area("Input for Q&A:", key="input_qa")
|
128 |
-
submit_qa = st.button("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
st.subheader("Gemini Pro Response:")
|
118 |
st.write(response_gemini)
|
119 |
|
|
|
120 |
def qa_chat():
|
121 |
st.header("Q&A Chat Application")
|
122 |
# Initialize session state for chat history if it doesn't exist
|
|
|
124 |
st.session_state['chat_history'] = []
|
125 |
|
126 |
input_qa = st.text_area("Input for Q&A:", key="input_qa")
|
127 |
+
submit_qa = st.button("Ask the question")
|
128 |
+
|
129 |
+
if submit_qa and input_qa:
|
130 |
+
response_qa = get_gemini_response(input_qa)
|
131 |
+
# Add user query and response to session state chat history
|
132 |
+
st.session_state['chat_history'].append(("You", input_qa))
|
133 |
+
st.subheader("Q&A Response:")
|
134 |
+
for chunk in response_qa:
|
135 |
+
st.write(chunk.text)
|
136 |
+
st.session_state['chat_history'].append(("Gemini Pro", chunk.text))
|
137 |
+
|
138 |
+
st.subheader("Q&A Chat History:")
|
139 |
+
for role, text in st.session_state['chat_history']:
|
140 |
+
st.write(f"{role}: {text}")
|
141 |
+
|
142 |
+
# Map selected application to corresponding function
|
143 |
+
selected_app_func = {
|
144 |
+
"PDF Chat": pdf_chat,
|
145 |
+
"Image Chat": image_chat,
|
146 |
+
"Q&A Chat": qa_chat
|
147 |
+
}
|
148 |
+
|
149 |
+
# Run the selected application function
|
150 |
+
selected_app_func[selected_app]()
|
151 |
+
|