Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,7 @@ def generate_gemini_response(disease_list, user_context="", conversation_history
|
|
41 |
|
42 |
# Start with detected diseases
|
43 |
prompt = f"""
|
44 |
-
You are an expert plant pathologist. The detected crop diseases
|
45 |
|
46 |
User's context or question: {user_context if user_context else "Provide a general analysis"}
|
47 |
"""
|
@@ -166,25 +166,24 @@ if uploaded_file:
|
|
166 |
|
167 |
|
168 |
# AI-generated diagnosis from Gemini
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
|
173 |
# Save response to history
|
174 |
-
|
175 |
|
176 |
# Display the diagnosis
|
177 |
-
|
178 |
|
179 |
# Show past conversation history
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
st.write("β
No high-confidence diseases detected.")
|
188 |
|
189 |
# Instructions for users
|
190 |
st.markdown("""
|
|
|
41 |
|
42 |
# Start with detected diseases
|
43 |
prompt = f"""
|
44 |
+
You are an expert plant pathologist. The detected crop diseases is: {predicted_labels}.
|
45 |
|
46 |
User's context or question: {user_context if user_context else "Provide a general analysis"}
|
47 |
"""
|
|
|
166 |
|
167 |
|
168 |
# AI-generated diagnosis from Gemini
|
169 |
+
st.subheader("π AI Diagnosis")
|
170 |
+
with st.spinner("Generating diagnosis... π"):
|
171 |
+
diagnosis = generate_gemini_response(detected_disease_names, user_context, st.session_state.conversation_history[file_id])
|
172 |
|
173 |
# Save response to history
|
174 |
+
st.session_state.conversation_history[file_id].append({"question": user_context, "response": diagnosis})
|
175 |
|
176 |
# Display the diagnosis
|
177 |
+
st.write(diagnosis)
|
178 |
|
179 |
# Show past conversation history
|
180 |
+
if st.session_state.conversation_history[file_id]:
|
181 |
+
st.subheader("ποΈ Conversation History")
|
182 |
+
for i, entry in enumerate(st.session_state.conversation_history[file_id]):
|
183 |
+
with st.expander(f"Q{i+1}: {entry['question'][:50]}..."):
|
184 |
+
st.write("**User:**", entry["question"])
|
185 |
+
st.write("**AI:**", entry["response"])
|
186 |
+
|
|
|
187 |
|
188 |
# Instructions for users
|
189 |
st.markdown("""
|