rosemariafontana commited on
Commit
06dde0f
·
verified ·
1 Parent(s): f1c6894

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -147,7 +147,10 @@ def generate_json(specification, model_version):
147
  ],
148
  response_format=FarmActivities,
149
  )
150
-
 
 
 
151
  farm_generated_json = farm_info_response.choices[0].message.parsed
152
  print(farm_generated_json) # debugging
153
 
@@ -161,14 +164,15 @@ def generate_json(specification, model_version):
161
  ],
162
  response_format=Interactions,
163
  )
164
-
 
 
 
165
  interactions_generated_json = interactions_response.choices[0].message.parsed
166
  print(interactions_generated_json) # debugging 2
167
 
168
  interactions_pretty_json = interactions_generated_json.json()
169
 
170
- if 'error' in response:
171
- raise ValueError(f"API error: {response['error']['message']}")
172
 
173
  trial_response = client.beta.chat.completions.parse(
174
  model=model_version, # Use GPT model that supports structured output
@@ -179,13 +183,14 @@ def generate_json(specification, model_version):
179
  response_format=Trial,
180
  )
181
 
 
 
 
182
  trial_generated_json = trial_response.choices[0].message.parsed
183
  print(trial_generated_json) # debugging 2
184
 
185
  trial_pretty_json = trial_generated_json.json()
186
 
187
- if 'error' in response:
188
- raise ValueError(f"API error: {response['error']['message']}")
189
 
190
  return farm_pretty_json, interactions_pretty_json, trial_pretty_json
191
 
 
147
  ],
148
  response_format=FarmActivities,
149
  )
150
+
151
+ if 'error' in farm_info_response:
152
+ raise ValueError(f"API error: {interactions_response['error']['message']}")
153
+
154
  farm_generated_json = farm_info_response.choices[0].message.parsed
155
  print(farm_generated_json) # debugging
156
 
 
164
  ],
165
  response_format=Interactions,
166
  )
167
+
168
+ if 'error' in interactions_response:
169
+ raise ValueError(f"API error: {interactions_response['error']['message']}")
170
+
171
  interactions_generated_json = interactions_response.choices[0].message.parsed
172
  print(interactions_generated_json) # debugging 2
173
 
174
  interactions_pretty_json = interactions_generated_json.json()
175
 
 
 
176
 
177
  trial_response = client.beta.chat.completions.parse(
178
  model=model_version, # Use GPT model that supports structured output
 
183
  response_format=Trial,
184
  )
185
 
186
+ if 'error' in trial_response:
187
+ raise ValueError(f"API error: {trial_response['error']['message']}")
188
+
189
  trial_generated_json = trial_response.choices[0].message.parsed
190
  print(trial_generated_json) # debugging 2
191
 
192
  trial_pretty_json = trial_generated_json.json()
193
 
 
 
194
 
195
  return farm_pretty_json, interactions_pretty_json, trial_pretty_json
196