Measterly commited on
Commit
e57bac3
·
verified ·
1 Parent(s): 629f411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
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()["choices"][0]["message"]["content"]
 
 
 
 
 
 
42
  except requests.exceptions.RequestException as e:
43
  st.error(f"API Error: {str(e)}")
44
- return None
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")