Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -204,6 +204,7 @@ def main():
|
|
204 |
# Layout of input/response containers
|
205 |
input_container = st.container()
|
206 |
selected_region = st.selectbox("Choose a region:", list(soil_types.keys()))
|
|
|
207 |
|
208 |
if st.button("Clear Chat"):
|
209 |
st.session_state['past'] = []
|
@@ -225,29 +226,30 @@ def main():
|
|
225 |
## Function for taking user prompt as input followed by producing AI generated responses
|
226 |
|
227 |
## Conditional display of AI generated responses as a function of user provided prompts
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
251 |
|
252 |
if __name__ == "__main__":
|
253 |
main()
|
|
|
204 |
# Layout of input/response containers
|
205 |
input_container = st.container()
|
206 |
selected_region = st.selectbox("Choose a region:", list(soil_types.keys()))
|
207 |
+
submit_question = st.button("Send")
|
208 |
|
209 |
if st.button("Clear Chat"):
|
210 |
st.session_state['past'] = []
|
|
|
226 |
## Function for taking user prompt as input followed by producing AI generated responses
|
227 |
|
228 |
## Conditional display of AI generated responses as a function of user provided prompts
|
229 |
+
if submit_question:
|
230 |
+
with response_container:
|
231 |
+
if user_input:
|
232 |
+
response = generate_response(user_input,str(selected_region), str(date))
|
233 |
+
st.session_state.past.append(user_input)
|
234 |
+
st.session_state.generated.append(response)
|
235 |
+
|
236 |
+
if st.session_state['generated']:
|
237 |
+
for i in range(len(st.session_state['generated'])):
|
238 |
+
message(st.session_state['past'][i], is_user=True, key=str(i) + '_user', logo="https://i.pinimg.com/originals/d5/b2/13/d5b21384ccaaa6f9ef32986f17c50638.png")
|
239 |
+
message(st.session_state["generated"][i], key=str(i), logo= "https://emojiisland.com/cdn/shop/products/Robot_Emoji_Icon_7070a254-26f7-4a54-8131-560e38e34c2e_large.png?v=1571606114")
|
240 |
+
|
241 |
+
# Add Google icon button to retrieve links
|
242 |
+
if st.button(f"Double-Check Response", key=f"google_button_{i}"):
|
243 |
+
search_query = get_search_query(st.session_state['generated'][i])
|
244 |
+
retrieved_links = search_url(search_query)
|
245 |
+
if retrieved_links:
|
246 |
+
st.markdown("**Google Search Results:**")
|
247 |
+
for j, link in enumerate(retrieved_links):
|
248 |
+
st.markdown(f"{j + 1}. [{link['title']}]({link['link']})")
|
249 |
+
|
250 |
+
# Display Google logo
|
251 |
+
google_logo_url = "https://companieslogo.com/img/orig/GOOG-0ed88f7c.png"
|
252 |
+
st.image(google_logo_url, width=50, caption="Google Logo")
|
253 |
|
254 |
if __name__ == "__main__":
|
255 |
main()
|