feat: Add OCR Processing Layers Viewer UI and log proxy middleware
This commit is contained in:
1 parent
54b46fc35f
commit
aa3233e411
11 files changed
+964
-30
No files matched your search
@@ -0,0 +1,51 @@
|
||||
// Active Log Tracker for OCR Processing Layers
|
||||
|
||||
export interface VllmCall {
|
||||
request: any;
|
||||
response: any;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export interface ActiveUploadLog {
|
||||
filename: string;
|
||||
vllm_calls: VllmCall[];
|
||||
ocr_raw?: any;
|
||||
stage_1_output?: any;
|
||||
stage_2_output?: any;
|
||||
frontend_response?: any;
|
||||
}
|
||||
|
||||
// Store active log in global context to persist across Next.js hot-reloads
|
||||
const globalForActiveLog = global as unknown as {
|
||||
activeLog: ActiveUploadLog | null;
|
||||
};
|
||||
|
||||
export function startActiveLog(filename: string) {
|
||||
globalForActiveLog.activeLog = {
|
||||
filename,
|
||||
vllm_calls: []
|
||||
};
|
||||
console.log(`[ActiveLog] Started tracking log for ${filename}`);
|
||||
}
|
||||
|
||||
export function logVllmCall(request: any, response: any) {
|
||||
if (globalForActiveLog.activeLog) {
|
||||
globalForActiveLog.activeLog.vllm_calls.push({
|
||||
request,
|
||||
response,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
console.log(`[ActiveLog] Logged vLLM call for ${globalForActiveLog.activeLog.filename} (total calls: ${globalForActiveLog.activeLog.vllm_calls.length})`);
|
||||
} else {
|
||||
console.log("[ActiveLog] Warning: Attempted to log vLLM call but no active log session is running.");
|
||||
}
|
||||
}
|
||||
|
||||
export function getActiveLog(): ActiveUploadLog | null {
|
||||
return globalForActiveLog.activeLog;
|
||||
}
|
||||
|
||||
export function clearActiveLog() {
|
||||
globalForActiveLog.activeLog = null;
|
||||
console.log("[ActiveLog] Cleared active log tracking context");
|
||||
}
|
||||
Reference in new issue
Block a user