-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve OCR pipeline initialization
Co-Authored-By: ben <ben@prologe.io>
- Loading branch information
1 parent
7d1c2b6
commit 15a0b72
Showing
3 changed files
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1 @@ | ||
import { processOCRForInvoicesAndAdmin } from '@/lib/ocr/pipeline'; | ||
|
||
// Initialize the OCR pipeline when this route is first accessed | ||
let initialized = false; | ||
|
||
export async function GET() { | ||
if (!initialized) { | ||
initialized = true; | ||
// Start the OCR pipeline | ||
setInterval(() => { | ||
processOCRForInvoicesAndAdmin().catch(console.error); | ||
}, 60000); | ||
} | ||
return new Response('OCR pipeline initialized', { status: 200 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { processOCRForInvoicesAndAdmin } from './pipeline'; | ||
|
||
let initialized = false; | ||
|
||
export function initializeOCRPipeline() { | ||
if (!initialized && typeof window === 'undefined') { | ||
initialized = true; | ||
// Start the OCR pipeline | ||
setInterval(() => { | ||
processOCRForInvoicesAndAdmin().catch(console.error); | ||
}, 60000); | ||
console.log('OCR pipeline initialized'); | ||
} | ||
} |