Update app.py
Browse files
app.py
CHANGED
|
@@ -38,10 +38,16 @@ def get_valuation(item_description, image=None):
|
|
| 38 |
try:
|
| 39 |
response = requests.post(DEEPSEEK_ENDPOINT, json=data, headers=headers)
|
| 40 |
response.raise_for_status()
|
| 41 |
-
return response.json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
except requests.exceptions.RequestException as e:
|
| 43 |
st.error(f"API Error: {str(e)}")
|
| 44 |
-
|
| 45 |
|
| 46 |
# Streamlit UI
|
| 47 |
st.set_page_config(page_title="Auction Valuation Tool", layout="wide")
|
|
|
|
| 38 |
try:
|
| 39 |
response = requests.post(DEEPSEEK_ENDPOINT, json=data, headers=headers)
|
| 40 |
response.raise_for_status()
|
| 41 |
+
return response.json().get("choices", [{}])[0].get("message", {}).get("content", "No response from API.")
|
| 42 |
+
except requests.exceptions.HTTPError as http_err:
|
| 43 |
+
st.error(f"HTTP error occurred: {http_err}")
|
| 44 |
+
except requests.exceptions.ConnectionError:
|
| 45 |
+
st.error("Connection error. Please check your internet connection.")
|
| 46 |
+
except requests.exceptions.Timeout:
|
| 47 |
+
st.error("Request timed out. Please try again later.")
|
| 48 |
except requests.exceptions.RequestException as e:
|
| 49 |
st.error(f"API Error: {str(e)}")
|
| 50 |
+
return None
|
| 51 |
|
| 52 |
# Streamlit UI
|
| 53 |
st.set_page_config(page_title="Auction Valuation Tool", layout="wide")
|