Skip to content

Commit

Permalink
Exception Handling on Errors in Vision Parser Model Responses
Browse files Browse the repository at this point in the history
  • Loading branch information
GwonHyeok committed Feb 13, 2025
1 parent 2f57df9 commit aa8f0e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/app/api/health-data-parser/visions/[id]/models/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ export async function GET(
const parser = visions.find(v => v.name === id)
if (!parser) return NextResponse.json({error: 'Not found'}, {status: 404})

const models = await parser.models({
apiUrl: searchParams.get('apiUrl') || undefined,
});
let models: VisionParserModel[]
try {
models = await parser.models({
apiUrl: searchParams.get('apiUrl') || undefined,
});
} catch (e) {
console.error(e)
models = []
}
return NextResponse.json({models})
}
4 changes: 2 additions & 2 deletions src/components/source/source-add-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1138,11 +1138,11 @@ export default function SourceAddScreen() {
}, [visionDataList, visionParser]);

useEffect(() => {
if (visionModelDataList?.models && visionParserModel === undefined) {
if (visionModelDataList?.models && visionModelDataList.models.length > 0 && visionParserModel === undefined) {
const {name} = visionModelDataList.models[0];
setVisionParserModel({value: name, label: name})
}
}, [visionModelDataList, visionParserModel]);
}, [visionModelDataList, visionParser, visionParserModel]);

useEffect(() => {
if (documentDataList?.documents && documentParser === undefined) {
Expand Down

0 comments on commit aa8f0e9

Please sign in to comment.