Fix predict proxy schema and error messages
This commit is contained in:
parent
508d267078
commit
328476a581
2 changed files with 18 additions and 4 deletions
|
|
@ -14,8 +14,8 @@ const CandleSchema = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
const PredictRequestSchema = z.object({
|
const PredictRequestSchema = z.object({
|
||||||
pair: z.string().min(1),
|
pair: z.string().min(1).optional(),
|
||||||
timeframe: z.string().min(1),
|
timeframe: z.string().min(1).optional(),
|
||||||
candles: z.array(CandleSchema),
|
candles: z.array(CandleSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,14 @@ export default function Home() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Prediction failed: ${response.statusText}`);
|
let message = response.statusText || 'Prediction failed';
|
||||||
|
try {
|
||||||
|
const errorBody = await response.json();
|
||||||
|
message = errorBody?.error || errorBody?.detail || message;
|
||||||
|
} catch {
|
||||||
|
// ignore parse errors
|
||||||
|
}
|
||||||
|
throw new Error(`Prediction failed: ${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
@ -678,7 +685,14 @@ export default function Home() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Batch prediction failed: ${response.statusText}`);
|
let message = response.statusText || 'Batch prediction failed';
|
||||||
|
try {
|
||||||
|
const errorBody = await response.json();
|
||||||
|
message = errorBody?.error || errorBody?.detail || message;
|
||||||
|
} catch {
|
||||||
|
// ignore parse errors
|
||||||
|
}
|
||||||
|
throw new Error(`Batch prediction failed: ${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue