hchevva commited on
Commit
5b07a9d
·
verified ·
1 Parent(s): 4a01f30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -20,7 +20,7 @@ from openai import OpenAI # OpenAI Responses API client
20
  # Defaults
21
  # -----------------------------
22
  DEFAULT_CONTROLLED_VOCAB_JSON = """{
23
- "risk_stance_enum": ["high_concern","moderate_concern","low_concern","inconclusive","not_assessed"],
24
  "study_type_enum": ["in_vivo","in_vitro","epidemiology","in_silico","review","methodology","other"],
25
  "exposure_route_enum": ["oral","inhalation","dermal","parenteral","multiple","not_reported"],
26
  "species_enum": ["human","rat","mouse","rabbit","dog","non_human_primate","cell_line","other","not_reported"],
@@ -216,7 +216,13 @@ def parse_field_spec(spec: str) -> Tuple[Dict[str, Any], List[str], Dict[str, st
216
 
217
 
218
  def build_extraction_schema(field_props: Dict[str, Any], required_fields: List[str], vocab: Dict[str, Any]) -> Dict[str, Any]:
219
- risk_enum = vocab.get("risk_stance_enum", ["high_concern","moderate_concern","low_concern","inconclusive","not_assessed"])
 
 
 
 
 
 
220
 
221
  schema = {
222
  "type": "object",
@@ -230,7 +236,7 @@ def build_extraction_schema(field_props: Dict[str, Any], required_fields: List[s
230
  "type": "object",
231
  "additionalProperties": False,
232
  "properties": field_props,
233
- "required": required_fields
234
  },
235
  "evidence": {
236
  "type": "array",
 
20
  # Defaults
21
  # -----------------------------
22
  DEFAULT_CONTROLLED_VOCAB_JSON = """{
23
+ "risk_stance_enum": ["acceptable","acceptable_with_uncertainty","not_acceptable","insufficient_data"],
24
  "study_type_enum": ["in_vivo","in_vitro","epidemiology","in_silico","review","methodology","other"],
25
  "exposure_route_enum": ["oral","inhalation","dermal","parenteral","multiple","not_reported"],
26
  "species_enum": ["human","rat","mouse","rabbit","dog","non_human_primate","cell_line","other","not_reported"],
 
216
 
217
 
218
  def build_extraction_schema(field_props: Dict[str, Any], required_fields: List[str], vocab: Dict[str, Any]) -> Dict[str, Any]:
219
+ risk_enum = vocab.get(
220
+ "risk_stance_enum",
221
+ ["acceptable", "acceptable_with_uncertainty", "not_acceptable", "insufficient_data"]
222
+ )
223
+
224
+ # IMPORTANT: strict schema requires required == all property keys
225
+ all_field_keys = list(field_props.keys())
226
 
227
  schema = {
228
  "type": "object",
 
236
  "type": "object",
237
  "additionalProperties": False,
238
  "properties": field_props,
239
+ "required": all_field_keys # <-- FIX
240
  },
241
  "evidence": {
242
  "type": "array",