jayash391 commited on
Commit
97a06bb
·
verified ·
1 Parent(s): 1bc7df2

Update sherlock2.py

Browse files
Files changed (1) hide show
  1. sherlock2.py +43 -27
sherlock2.py CHANGED
@@ -329,6 +329,20 @@ def investigate():
329
  st.header("Case Report")
330
  st.write(final_report.text)
331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
 
333
  def main():
334
  # --- Vintage Sherlock Holmes Theme ---
@@ -337,7 +351,28 @@ def main():
337
  # Custom CSS for Styling
338
  vintage_css = """
339
  <style>
340
- ... (CSS code remains the same) ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  </style>
342
  """
343
  st.markdown(vintage_css, unsafe_allow_html=True) # Apply custom CSS
@@ -346,33 +381,14 @@ def main():
346
  st.title("AI Detective Sherlock Holmes")
347
  st.header("_'Elementary, my dear Watson!'_")
348
 
349
- # Initialize chat history
350
- if 'chat_history' not in st.session_state:
351
- st.session_state.chat_history = []
352
-
353
- # Function to display chat history with highlighted user input and chatbot response
354
- def display_chat_history():
355
- for user_msg, bot_msg in st.session_state.chat_history:
356
- st.info(f"**You:** {user_msg}")
357
- st.success(f"**Sherlock:** {bot_msg}")
358
-
359
- st.sidebar.title("Case Files")
360
- st.sidebar.info("Upload your case files and let Sherlock analyze the evidence.")
361
-
362
- investigate()
363
-
364
- # Chat with Sherlock
365
- st.sidebar.title("Consult with Sherlock")
366
- user_query = st.sidebar.text_input("Ask Sherlock:", key="user_input")
367
- if user_query:
368
- chat_history_summary = summarize_chat_history(st.session_state.chat_history)
369
- conversation_history = [sherlock_persona, sherlock_guidelines, chat_history_summary, f"Human: {user_query}"]
370
- response = model.generate_content(conversation_history)
371
- st.session_state.chat_history.append((user_query, response.text))
372
- display_chat_history()
373
 
374
- # Call the fixInputToBottom function after rendering the input text box
375
- st.markdown("<script>fixInputToBottom();</script>", unsafe_allow_html=True)
 
376
 
377
  if __name__ == "__main__":
378
  main()
 
329
  st.header("Case Report")
330
  st.write(final_report.text)
331
 
332
+ def chat_with_sherlock():
333
+ """Handles the chat interaction with Sherlock Holmes."""
334
+ st.header("Consult with Sherlock")
335
+
336
+ # Display chat history
337
+ display_chat_history()
338
+
339
+ user_query = st.text_input("Ask Sherlock:", key="user_input")
340
+ if user_query:
341
+ chat_history_summary = summarize_chat_history(st.session_state.chat_history)
342
+ conversation_history = [sherlock_persona, sherlock_guidelines, chat_history_summary, f"Human: {user_query}"]
343
+ response = model.generate_content(conversation_history)
344
+ st.session_state.chat_history.append((user_query, response.text))
345
+ display_chat_history()
346
 
347
  def main():
348
  # --- Vintage Sherlock Holmes Theme ---
 
351
  # Custom CSS for Styling
352
  vintage_css = """
353
  <style>
354
+ body {
355
+ background-color: #d2b48c; /* Antique White */
356
+ color: #332200; /* Dark Brown */
357
+ font-family: 'Times New Roman', serif;
358
+ }
359
+ h1, h2, h3 {
360
+ color: #8b4513; /* Saddle Brown */
361
+ }
362
+ .stTextInput > div > div > input {
363
+ border: 1px solid #8b4513;
364
+ border-radius: 5px;
365
+ padding: 10px;
366
+ font-size: 16px;
367
+ width: 100%;
368
+ box-sizing: border-box;
369
+ }
370
+ .stButton > button {
371
+ background-color: #8b4513;
372
+ color: white;
373
+ border: none;
374
+ border-radius: 5px;
375
+ }
376
  </style>
377
  """
378
  st.markdown(vintage_css, unsafe_allow_html=True) # Apply custom CSS
 
381
  st.title("AI Detective Sherlock Holmes")
382
  st.header("_'Elementary, my dear Watson!'_")
383
 
384
+ pages = {
385
+ "Investigate a Case": investigate,
386
+ "Chat with Sherlock": chat_with_sherlock
387
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
 
389
+ st.sidebar.title("Navigation")
390
+ page = st.sidebar.radio("Choose an action:", list(pages.keys()))
391
+ pages[page]()
392
 
393
  if __name__ == "__main__":
394
  main()