Spaces:
Sleeping
Sleeping
debug: add API response logging to identify contextualization issue after first round
Browse files- src/aiService.js +20 -0
src/aiService.js
CHANGED
|
@@ -138,6 +138,16 @@ Passage: "${passage}"`
|
|
| 138 |
}
|
| 139 |
|
| 140 |
const data = await response.json();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
const content = data.choices[0].message.content.trim();
|
| 142 |
|
| 143 |
// Try to parse as JSON array
|
|
@@ -207,6 +217,16 @@ Passage: "${passage}"`
|
|
| 207 |
}
|
| 208 |
|
| 209 |
const data = await response.json();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
let content = data.choices[0].message.content.trim();
|
| 211 |
|
| 212 |
// Clean up AI response artifacts
|
|
|
|
| 138 |
}
|
| 139 |
|
| 140 |
const data = await response.json();
|
| 141 |
+
|
| 142 |
+
// Debug: Log the actual API response
|
| 143 |
+
console.log('Word selection API response:', data);
|
| 144 |
+
|
| 145 |
+
// Check if response has expected structure
|
| 146 |
+
if (!data.choices || !data.choices[0] || !data.choices[0].message || !data.choices[0].message.content) {
|
| 147 |
+
console.error('Invalid word selection API response structure:', data);
|
| 148 |
+
throw new Error('API response missing expected content');
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
const content = data.choices[0].message.content.trim();
|
| 152 |
|
| 153 |
// Try to parse as JSON array
|
|
|
|
| 217 |
}
|
| 218 |
|
| 219 |
const data = await response.json();
|
| 220 |
+
|
| 221 |
+
// Debug: Log the actual API response
|
| 222 |
+
console.log('Contextualization API response:', data);
|
| 223 |
+
|
| 224 |
+
// Check if response has expected structure
|
| 225 |
+
if (!data.choices || !data.choices[0] || !data.choices[0].message || !data.choices[0].message.content) {
|
| 226 |
+
console.error('Invalid contextualization API response structure:', data);
|
| 227 |
+
throw new Error('API response missing expected content');
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
let content = data.choices[0].message.content.trim();
|
| 231 |
|
| 232 |
// Clean up AI response artifacts
|