jayash391 commited on
Commit
51a9839
·
verified ·
1 Parent(s): c398c9e

Update sherlock2.py

Browse files
Files changed (1) hide show
  1. sherlock2.py +33 -2
sherlock2.py CHANGED
@@ -267,7 +267,39 @@ def investigate():
267
  uploaded_images = st.file_uploader("Upload Case Images", accept_multiple_files=True, type=["jpg", "png", "jpeg"])
268
 
269
  if uploaded_documents and uploaded_images and st.button("Analyze Case"):
270
- # ... (keep the existing code for case investigation)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
 
272
  # Generate a case report in Sherlock Holmes's style
273
  report_prompt = """
@@ -279,7 +311,6 @@ def investigate():
279
  final_report = model.generate_content([sherlock_persona, sherlock_guidelines, report_prompt,
280
  *case_embeddings, str(wikipedia_info), str(web_search_results)])
281
  st.header("Case Report")
282
- st.write(final_report.text)
283
 
284
  # Display chat history
285
  display_chat_history()
 
267
  uploaded_images = st.file_uploader("Upload Case Images", accept_multiple_files=True, type=["jpg", "png", "jpeg"])
268
 
269
  if uploaded_documents and uploaded_images and st.button("Analyze Case"):
270
+
271
+ # Extract text from uploaded documents
272
+ case_text = extract_text_from_files(uploaded_documents)
273
+
274
+ # Extract keywords and important information from the text
275
+ keywords = extract_keywords_simple("\n\n".join(case_text))
276
+
277
+ # Generate embeddings for the extracted text
278
+ case_embeddings = generate_embeddings_from_documents(case_text)
279
+
280
+ # Process images using Gemini Pro Vision
281
+ image_insights = process_images(uploaded_images)
282
+
283
+ # Combine text, image, and keyword information
284
+ combined_information = {
285
+ "case_text": case_text,
286
+ "case_embeddings": case_embeddings,
287
+ "image_insights": image_insights,
288
+ "keywords": keywords
289
+ }
290
+
291
+ # Analyze combined information using Gemini 1.5 Pro
292
+ prompt = """
293
+ You are Sherlock Holmes, the renowned detective. Analyze the following case information and provide insights or
294
+ suggestions for further investigation:
295
+ """ + str(combined_information)
296
+
297
+ response = model.generate_content([sherlock_persona, sherlock_guidelines, prompt, *case_embeddings])
298
+ st.write(response.text)
299
+
300
+ # Search Wikipedia and the web for related information
301
+ wikipedia_info = search_and_scrape_wikipedia(keywords)
302
+ web_search_results = search_internet("\n\n".join(case_text)) # Search the web
303
 
304
  # Generate a case report in Sherlock Holmes's style
305
  report_prompt = """
 
311
  final_report = model.generate_content([sherlock_persona, sherlock_guidelines, report_prompt,
312
  *case_embeddings, str(wikipedia_info), str(web_search_results)])
313
  st.header("Case Report")
 
314
 
315
  # Display chat history
316
  display_chat_history()