Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +6 -2
src/streamlit_app.py
CHANGED
@@ -70,7 +70,11 @@ if submitted:
|
|
70 |
|
71 |
if "choices" in ai_response:
|
72 |
try:
|
73 |
-
|
|
|
|
|
|
|
|
|
74 |
content_json = json.loads(content)
|
75 |
st.success("Analysis complete!")
|
76 |
st.subheader("Rooftop Analysis")
|
@@ -90,4 +94,4 @@ if submitted:
|
|
90 |
else:
|
91 |
st.error("Failed to analyze the image. Please try again.")
|
92 |
else:
|
93 |
-
st.warning("Please upload an image and fill all fields.")
|
|
|
70 |
|
71 |
if "choices" in ai_response:
|
72 |
try:
|
73 |
+
choice = ai_response["choices"][0]
|
74 |
+
if isinstance(choice, dict) and "message" in choice and "content" in choice["message"]:
|
75 |
+
content = choice["message"]["content"]
|
76 |
+
else:
|
77 |
+
raise ValueError("Invalid response format: 'message' or 'content' missing.")
|
78 |
content_json = json.loads(content)
|
79 |
st.success("Analysis complete!")
|
80 |
st.subheader("Rooftop Analysis")
|
|
|
94 |
else:
|
95 |
st.error("Failed to analyze the image. Please try again.")
|
96 |
else:
|
97 |
+
st.warning("Please upload an image and fill all fields.")
|