Spaces:
Runtime error
Runtime error
Update sherlock2.py
Browse files- sherlock2.py +6 -34
sherlock2.py
CHANGED
@@ -278,39 +278,6 @@ def investigate():
|
|
278 |
if user_query:
|
279 |
response = model.generate_content([sherlock_persona, sherlock_guidelines, user_query])
|
280 |
st.write(response.text)
|
281 |
-
|
282 |
-
def chat_with_sherlock():
|
283 |
-
"""Handles the chat interaction with Sherlock Holmes."""
|
284 |
-
# Initialize chat history if it doesn't exist
|
285 |
-
if "chat_history" not in st.session_state:
|
286 |
-
st.session_state["chat_history"] = []
|
287 |
-
|
288 |
-
# Create input and output containers
|
289 |
-
input_container = st.container()
|
290 |
-
output_container = st.container()
|
291 |
-
|
292 |
-
with input_container:
|
293 |
-
user_input = st.text_input("Ask Sherlock:", key="user_input")
|
294 |
-
submit_button = st.button("Ask Sherlock", key="submit_button")
|
295 |
-
|
296 |
-
if submit_button:
|
297 |
-
# Add user input to chat history
|
298 |
-
st.session_state["chat_history"].append({"role": "user", "content": user_input})
|
299 |
-
|
300 |
-
# Generate Sherlock's response
|
301 |
-
response = model.generate_content([sherlock_persona, sherlock_guidelines, user_input])
|
302 |
-
st.session_state["chat_history"].append({"role": "assistant", "content": response.text})
|
303 |
-
|
304 |
-
# Clear input text field
|
305 |
-
st.session_state["user_input"] = ""
|
306 |
-
|
307 |
-
with output_container:
|
308 |
-
for chat_entry in st.session_state["chat_history"]:
|
309 |
-
if chat_entry["role"] == "user":
|
310 |
-
st.markdown(f"**You:** {chat_entry['content']}")
|
311 |
-
else:
|
312 |
-
st.markdown(f"**Sherlock:** {chat_entry['content']}")
|
313 |
-
|
314 |
def main():
|
315 |
# --- Vintage Sherlock Holmes Theme ---
|
316 |
st.set_page_config(page_title="AI Detective Sherlock Holmes", page_icon=":mag_right:")
|
@@ -352,7 +319,12 @@ def main():
|
|
352 |
if choice == "Investigate Case":
|
353 |
investigate()
|
354 |
else:
|
355 |
-
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
if __name__ == "__main__":
|
358 |
main()
|
|
|
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:")
|
|
|
319 |
if choice == "Investigate Case":
|
320 |
investigate()
|
321 |
else:
|
322 |
+
# Chat with Sherlock Holmes (Gemini 1.5 Pro)
|
323 |
+
st.write("No case files uploaded. Feel free to chat with Sherlock Holmes.")
|
324 |
+
user_query = st.text_input("Ask Sherlock:")
|
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()
|