@pandi2352/gemini-ocr 1.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -3
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ async function processSingleFile(input, options) {
|
|
|
56
56
|
if (!options.apiKey)
|
|
57
57
|
throw new Error('Gemini API key is required.');
|
|
58
58
|
const gemini = new llm_1.GeminiClient(options.apiKey, logger);
|
|
59
|
-
const modelName = options.model || 'gemini-
|
|
59
|
+
const modelName = options.model || 'gemini-2.5-flash';
|
|
60
60
|
// Input Processing
|
|
61
61
|
const inputHandler = new input_handler_1.InputHandler(logger);
|
|
62
62
|
const normalized = await inputHandler.processInput(input);
|
|
@@ -199,7 +199,7 @@ async function processSingleFile(input, options) {
|
|
|
199
199
|
entityResult,
|
|
200
200
|
pageCount,
|
|
201
201
|
language: 'en',
|
|
202
|
-
documentType: 'unknown',
|
|
202
|
+
documentType: mimeType?.includes('pdf') ? 'pdf' : mimeType?.includes('image') ? 'image' : mimeType || 'unknown',
|
|
203
203
|
confidence: null,
|
|
204
204
|
timings: {
|
|
205
205
|
startTime: startTime.toISOString(),
|
|
@@ -216,10 +216,19 @@ async function processSingleFile(input, options) {
|
|
|
216
216
|
}
|
|
217
217
|
catch (error) {
|
|
218
218
|
const endTime = new Date();
|
|
219
|
+
let errorMessage = error.message || 'Unknown error';
|
|
220
|
+
try {
|
|
221
|
+
// Try to make the error message cleaner or parse if it looks like JSON
|
|
222
|
+
if (errorMessage.startsWith('[') || errorMessage.startsWith('{')) {
|
|
223
|
+
const parsed = JSON.parse(errorMessage);
|
|
224
|
+
errorMessage = parsed;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (e) { }
|
|
219
228
|
// Error Result (Structured)
|
|
220
229
|
return {
|
|
221
230
|
status: 'error',
|
|
222
|
-
error:
|
|
231
|
+
error: errorMessage,
|
|
223
232
|
extractedText: '',
|
|
224
233
|
summary: null,
|
|
225
234
|
mindmap: null,
|
package/dist/types.d.ts
CHANGED