Spaces:
Runtime error
Runtime error
Update sherlock2.py
Browse files- sherlock2.py +55 -1
sherlock2.py
CHANGED
@@ -213,6 +213,12 @@ def search_internet(case_text):
|
|
213 |
|
214 |
return internet_search_results
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
def investigate():
|
217 |
"""Handles the case investigation process, including file upload, text extraction, embedding generation,
|
218 |
image processing, information analysis using Gemini models, web/Wikipedia search, and case report generation.
|
@@ -269,6 +275,16 @@ def investigate():
|
|
269 |
st.header("Case Report")
|
270 |
st.write(final_report.text)
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
else:
|
273 |
st.info("Please upload both case documents and images to proceed with the investigation.")
|
274 |
|
@@ -278,6 +294,12 @@ def investigate():
|
|
278 |
if user_query:
|
279 |
response = model.generate_content([sherlock_persona, sherlock_guidelines, user_query])
|
280 |
st.write(response.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
def main():
|
282 |
# --- Vintage Sherlock Holmes Theme ---
|
283 |
st.set_page_config(page_title="AI Detective Sherlock Holmes", page_icon=":mag_right:")
|
@@ -295,7 +317,11 @@ def main():
|
|
295 |
}
|
296 |
.stTextInput > div > div > input {
|
297 |
border: 1px solid #8b4513;
|
298 |
-
border-radius: 5px;
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
.stButton > button {
|
301 |
background-color: #8b4513;
|
@@ -307,10 +333,33 @@ def main():
|
|
307 |
"""
|
308 |
st.markdown(vintage_css, unsafe_allow_html=True) # Apply custom CSS
|
309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
# Title and Header
|
311 |
st.title("AI Detective Sherlock Holmes")
|
312 |
st.header("_'Elementary, my dear Watson!'_")
|
313 |
|
|
|
|
|
|
|
314 |
# Add a sidebar for navigation
|
315 |
st.sidebar.title("Navigation")
|
316 |
options = ["Investigate Case", "Chat with Sherlock"]
|
@@ -325,6 +374,11 @@ def main():
|
|
325 |
if user_query:
|
326 |
response = model.generate_content([sherlock_persona, sherlock_guidelines, user_query])
|
327 |
st.write(response.text)
|
|
|
|
|
|
|
|
|
|
|
328 |
|
329 |
if __name__ == "__main__":
|
330 |
main()
|
|
|
213 |
|
214 |
return internet_search_results
|
215 |
|
216 |
+
# Function to display chat history with highlighted user input and chatbot response
|
217 |
+
def display_chat_history():
|
218 |
+
for user_msg, bot_msg in st.session_state.chat_history:
|
219 |
+
st.info(f"**You:** {user_msg}")
|
220 |
+
st.success(f"**Sherlock:** {bot_msg}")
|
221 |
+
|
222 |
def investigate():
|
223 |
"""Handles the case investigation process, including file upload, text extraction, embedding generation,
|
224 |
image processing, information analysis using Gemini models, web/Wikipedia search, and case report generation.
|
|
|
275 |
st.header("Case Report")
|
276 |
st.write(final_report.text)
|
277 |
|
278 |
+
user_query = st.text_input("Ask Sherlock:")
|
279 |
+
if user_query:
|
280 |
+
response = model.generate_content([sherlock_persona, sherlock_guidelines, user_query])
|
281 |
+
st.write(response.text)
|
282 |
+
st.session_state.chat_history.append((user_query, response.text)) # Add chat to history
|
283 |
+
display_chat_history() # Display chat history
|
284 |
+
|
285 |
+
# Call the fixInputToBottom function after rendering the input text box
|
286 |
+
st.markdown("<script>fixInputToBottom();</script>", unsafe_allow_html=True)
|
287 |
+
|
288 |
else:
|
289 |
st.info("Please upload both case documents and images to proceed with the investigation.")
|
290 |
|
|
|
294 |
if user_query:
|
295 |
response = model.generate_content([sherlock_persona, sherlock_guidelines, user_query])
|
296 |
st.write(response.text)
|
297 |
+
st.session_state.chat_history.append((user_query, response.text)) # Add chat to history
|
298 |
+
display_chat_history() # Display chat history
|
299 |
+
|
300 |
+
# Call the fixInputToBottom function after rendering the input text box
|
301 |
+
st.markdown("<script>fixInputToBottom();</script>", unsafe_allow_html=True)
|
302 |
+
|
303 |
def main():
|
304 |
# --- Vintage Sherlock Holmes Theme ---
|
305 |
st.set_page_config(page_title="AI Detective Sherlock Holmes", page_icon=":mag_right:")
|
|
|
317 |
}
|
318 |
.stTextInput > div > div > input {
|
319 |
border: 1px solid #8b4513;
|
320 |
+
border-radius: 5px;
|
321 |
+
padding: 10px;
|
322 |
+
font-size: 16px;
|
323 |
+
width: 100%;
|
324 |
+
box-sizing: border-box;
|
325 |
}
|
326 |
.stButton > button {
|
327 |
background-color: #8b4513;
|
|
|
333 |
"""
|
334 |
st.markdown(vintage_css, unsafe_allow_html=True) # Apply custom CSS
|
335 |
|
336 |
+
# JavaScript function to fix the input text box to the bottom of the screen
|
337 |
+
st.markdown(
|
338 |
+
"""
|
339 |
+
<script>
|
340 |
+
function fixInputToBottom() {
|
341 |
+
const inputContainer = document.querySelector('.stTextInput');
|
342 |
+
if (inputContainer) {
|
343 |
+
inputContainer.style.position = 'fixed';
|
344 |
+
inputContainer.style.bottom = '20px';
|
345 |
+
inputContainer.style.left = '20px';
|
346 |
+
inputContainer.style.right = '20px';
|
347 |
+
inputContainer.style.zIndex = '999';
|
348 |
+
}
|
349 |
+
}
|
350 |
+
window.addEventListener('load', fixInputToBottom);
|
351 |
+
</script>
|
352 |
+
""",
|
353 |
+
unsafe_allow_html=True
|
354 |
+
)
|
355 |
+
|
356 |
# Title and Header
|
357 |
st.title("AI Detective Sherlock Holmes")
|
358 |
st.header("_'Elementary, my dear Watson!'_")
|
359 |
|
360 |
+
# Display chat history
|
361 |
+
display_chat_history()
|
362 |
+
|
363 |
# Add a sidebar for navigation
|
364 |
st.sidebar.title("Navigation")
|
365 |
options = ["Investigate Case", "Chat with Sherlock"]
|
|
|
374 |
if user_query:
|
375 |
response = model.generate_content([sherlock_persona, sherlock_guidelines, user_query])
|
376 |
st.write(response.text)
|
377 |
+
st.session_state.chat_history.append((user_query, response.text)) # Add chat to history
|
378 |
+
display_chat_history() # Display chat history
|
379 |
+
|
380 |
+
# Call the fixInputToBottom function after rendering the input text box
|
381 |
+
st.markdown("<script>fixInputToBottom();</script>", unsafe_allow_html=True)
|
382 |
|
383 |
if __name__ == "__main__":
|
384 |
main()
|