Spaces:
Sleeping
Sleeping
Update sherlock2.py
Browse files- sherlock2.py +24 -40
sherlock2.py
CHANGED
@@ -15,6 +15,9 @@ import textract
|
|
15 |
|
16 |
load_dotenv()
|
17 |
|
|
|
|
|
|
|
18 |
# Load pre-trained Gemini model
|
19 |
model = genai.GenerativeModel('models/gemini-1.0-pro')
|
20 |
vision_model = genai.GenerativeModel('models/gemini-pro-vision')
|
@@ -230,22 +233,18 @@ def display_chat_history():
|
|
230 |
def clear_chat():
|
231 |
st.session_state.chat_history = []
|
232 |
|
233 |
-
def
|
234 |
-
"""Displays a popup with information about Sherlock and instructions."""
|
235 |
-
st.
|
236 |
-
|
237 |
-
|
238 |
-
**About Sherlock:**
|
239 |
-
Sherlock Holmes is a brilliant detective known for his exceptional deductive reasoning skills. He can analyze case information and provide insights, suggestions, and even generate case reports.
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
3. Click "Enter" or the "Send" button to get Sherlock's response.
|
245 |
-
4. Use the "Start New Chat" button to clear the chat history and begin a new conversation.
|
246 |
|
247 |
-
|
248 |
-
|
249 |
|
250 |
def investigate():
|
251 |
"""Handles the case investigation process with improved UI and functionality."""
|
@@ -385,32 +384,17 @@ def main():
|
|
385 |
st.title("AI Detective Sherlock Holmes")
|
386 |
st.header("_'Elementary, my dear Watson!'_")
|
387 |
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
"Investigate a Case": investigate,
|
400 |
-
"Chat with Sherlock": chat_with_sherlock
|
401 |
-
}
|
402 |
-
|
403 |
-
st.sidebar.title("Navigation")
|
404 |
-
page = st.sidebar.radio("Choose an action:", list(pages.keys()))
|
405 |
-
|
406 |
-
# Show intro popup only after successful API key validation
|
407 |
-
show_sherlock_intro()
|
408 |
-
|
409 |
-
pages[page]()
|
410 |
-
except Exception as e:
|
411 |
-
st.error("Invalid Gemini API Key. Please try again.")
|
412 |
-
else:
|
413 |
-
st.warning("Please enter your Gemini API Key to proceed.")
|
414 |
|
415 |
if __name__ == "__main__":
|
416 |
main()
|
|
|
15 |
|
16 |
load_dotenv()
|
17 |
|
18 |
+
# Configure Gemini API access
|
19 |
+
genai.configure(api_key=os.getenv("GEMINI_API_KEY_PROJECTID"))
|
20 |
+
|
21 |
# Load pre-trained Gemini model
|
22 |
model = genai.GenerativeModel('models/gemini-1.0-pro')
|
23 |
vision_model = genai.GenerativeModel('models/gemini-pro-vision')
|
|
|
233 |
def clear_chat():
|
234 |
st.session_state.chat_history = []
|
235 |
|
236 |
+
def show_intro_popup():
|
237 |
+
"""Displays a popup with information about Sherlock and chat instructions."""
|
238 |
+
with st.expander("Welcome to AI Detective Sherlock Holmes!"): # Use expander for a collapsible popup
|
239 |
+
st.write("""
|
240 |
+
**Meet Sherlock Holmes, the world's most renowned detective!**
|
|
|
|
|
241 |
|
242 |
+
This application allows you to:
|
243 |
+
* **Investigate Cases:** Upload case files and images for Sherlock to analyze.
|
244 |
+
* **Chat with Sherlock:** Ask him questions and get his insights.
|
|
|
|
|
245 |
|
246 |
+
**To chat with Sherlock, go to the "Chat with Sherlock" page in the sidebar.**
|
247 |
+
""")
|
248 |
|
249 |
def investigate():
|
250 |
"""Handles the case investigation process with improved UI and functionality."""
|
|
|
384 |
st.title("AI Detective Sherlock Holmes")
|
385 |
st.header("_'Elementary, my dear Watson!'_")
|
386 |
|
387 |
+
|
388 |
+
pages = {
|
389 |
+
"Investigate a Case": investigate,
|
390 |
+
"Chat with Sherlock": chat_with_sherlock
|
391 |
+
}
|
392 |
+
|
393 |
+
show_intro_popup()
|
394 |
+
|
395 |
+
st.sidebar.title("Navigation")
|
396 |
+
page = st.sidebar.radio("Choose an action:", list(pages.keys()))
|
397 |
+
pages[page]()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
|
399 |
if __name__ == "__main__":
|
400 |
main()
|