mjwong commited on
Commit
74cf241
·
verified ·
1 Parent(s): 77c5f52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -29,6 +29,11 @@ SPECIES_RANK_API_URL = os.getenv(
29
  ""
30
  )
31
 
 
 
 
 
 
32
  MODEL_NAME = os.getenv(
33
  "MODEL_NAME",
34
  "hf-hub:imageomics/bioclip"
@@ -142,9 +147,14 @@ def app_function(uploaded_image: Optional[np.ndarray], country: Optional[str]) -
142
 
143
  logger.info("app_function: Performing taxonomic lookup for '%s'", proposed_scientific)
144
  try:
145
- response = requests.get(f"{SPECIES_RANK_API_URL}{proposed_scientific}", timeout=10)
146
  response.raise_for_status()
147
- taxonomic_data = response.json()
 
 
 
 
 
148
  except requests.exceptions.RequestException as e:
149
  logger.error("app_function: Taxonomic lookup failed for '%s'. Exception: %s", proposed_scientific, e)
150
  taxonomic_data = {}
 
29
  ""
30
  )
31
 
32
+ SPECIES_RANK_LICENSE_PARAMS = os.getenv(
33
+ "SPECIES_RANK_LICENSE_PARAMS",
34
+ ""
35
+ )
36
+
37
  MODEL_NAME = os.getenv(
38
  "MODEL_NAME",
39
  "hf-hub:imageomics/bioclip"
 
147
 
148
  logger.info("app_function: Performing taxonomic lookup for '%s'", proposed_scientific)
149
  try:
150
+ response = requests.get(f"{SPECIES_RANK_API_URL}{proposed_scientific}{SPECIES_RANK_LICENSE_PARAMS}", timeout=10)
151
  response.raise_for_status()
152
+ results = response.json().get("results", [])
153
+ if isinstance(results, list) and results:
154
+ taxonomic_data = results[0]
155
+ else:
156
+ taxonomic_data = {}
157
+
158
  except requests.exceptions.RequestException as e:
159
  logger.error("app_function: Taxonomic lookup failed for '%s'. Exception: %s", proposed_scientific, e)
160
  taxonomic_data = {}