feat: DeepSeek-OCR endpoint + GPU request queue for AI calls
Mizan ve DeepSeek-OCR aynı self-hosted GPU'yu paylaşıyor; backend'de hiçbir eşzamanlılık sınırı yoktu, yoğun anlarda istekler Ollama kuyruğunda 90sn'yi aşıp sessizce "başarısız" görünüyordu. aiQueue.ts, GPU'ya giden istek sayısını sınırlayıp fazlasını backend'de bekletiyor. Yeni POST /documents/ocr-image, tek bir görseli DeepSeek-OCR ile metne çeviriyor (Electron tarafındaki çok sayfalı TIFF/taranmış PDF işleme adımının kullanacağı uç, ayrı bir PR'da bağlanacak).
This commit is contained in:
@@ -4,7 +4,7 @@ import { AuthenticatedRequest } from '../middleware/auth';
|
||||
import * as officeParser from 'officeparser';
|
||||
import Tesseract from 'tesseract.js';
|
||||
import { findOrCreateCaseByTitle } from '../lib/caseLookup';
|
||||
import { callOllama } from '../lib/aiClient';
|
||||
import { callOllama, callOllamaVisionOcr } from '../lib/aiClient';
|
||||
import { getAiConfig } from '../lib/aiConfig';
|
||||
const heicConvert = require('heic-convert');
|
||||
|
||||
@@ -152,6 +152,24 @@ export const registerLocalDocument = async (req: AuthenticatedRequest, res: Resp
|
||||
}
|
||||
};
|
||||
|
||||
// Electron'daki extractText.js'in (taranmış görsel/TIFF sayfa/render edilmiş PDF
|
||||
// sayfası için) çağırdığı tek-sayfa OCR ucu. Tek bir görsel alır, DeepSeek-OCR ile
|
||||
// metne çevirir, sadece metni döner — sayfa birleştirme/dosya kaydı Electron
|
||||
// tarafında (extractText.js) yapılıyor, bu uç sadece OCR işini yapıyor.
|
||||
export const ocrImage = async (req: AuthenticatedRequest, res: Response) => {
|
||||
try {
|
||||
const { image_base64 } = req.body || {};
|
||||
if (!image_base64 || typeof image_base64 !== 'string') {
|
||||
return res.status(400).json({ error: 'image_base64 zorunludur.' });
|
||||
}
|
||||
const text = await callOllamaVisionOcr(image_base64);
|
||||
res.json({ text });
|
||||
} catch (error: any) {
|
||||
console.error('OCR Image Error:', error);
|
||||
res.status(500).json({ error: error.message || 'Internal Server Error' });
|
||||
}
|
||||
};
|
||||
|
||||
// uploadDocument ve uploadTemplate'in (template.controller.ts) ortak kullandığı
|
||||
// metin çıkarma adımı: resimler için Tesseract OCR, ofis belgeleri için officeParser.
|
||||
export async function extractTextFromUploadedFile(file: { buffer: Buffer; mimetype: string; originalname: string }): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user