@juspay/neurolink 8.8.0 → 8.10.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/CHANGELOG.md +17 -0
- package/dist/adapters/providerImageAdapter.js +131 -14
- package/dist/cli/factories/commandFactory.d.ts +1 -0
- package/dist/cli/factories/commandFactory.js +52 -2
- package/dist/constants/enums.d.ts +346 -15
- package/dist/constants/enums.js +476 -19
- package/dist/factories/providerRegistry.js +8 -7
- package/dist/lib/adapters/providerImageAdapter.js +131 -14
- package/dist/lib/constants/enums.d.ts +346 -15
- package/dist/lib/constants/enums.js +476 -19
- package/dist/lib/factories/providerRegistry.js +8 -7
- package/dist/lib/models/modelRegistry.js +1962 -210
- package/dist/lib/types/fileTypes.d.ts +10 -1
- package/dist/lib/types/generateTypes.d.ts +7 -0
- package/dist/lib/types/streamTypes.d.ts +7 -0
- package/dist/lib/utils/csvProcessor.d.ts +17 -0
- package/dist/lib/utils/csvProcessor.js +56 -4
- package/dist/models/modelRegistry.js +1962 -210
- package/dist/types/fileTypes.d.ts +10 -1
- package/dist/types/generateTypes.d.ts +7 -0
- package/dist/types/streamTypes.d.ts +7 -0
- package/dist/utils/csvProcessor.d.ts +17 -0
- package/dist/utils/csvProcessor.js +56 -4
- package/package.json +1 -1
|
@@ -41,7 +41,7 @@ export type FileProcessingResult = {
|
|
|
41
41
|
rowCount?: number;
|
|
42
42
|
columnCount?: number;
|
|
43
43
|
columnNames?: string[];
|
|
44
|
-
sampleData?: string;
|
|
44
|
+
sampleData?: string | unknown[];
|
|
45
45
|
hasEmptyColumns?: boolean;
|
|
46
46
|
version?: string;
|
|
47
47
|
estimatedPages?: number | null;
|
|
@@ -49,6 +49,14 @@ export type FileProcessingResult = {
|
|
|
49
49
|
apiType?: PDFAPIType;
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Sample data format options for CSV metadata
|
|
54
|
+
* - 'json': JSON string representation (default, backward compatible)
|
|
55
|
+
* - 'object': Structured array of row objects (best for programmatic use)
|
|
56
|
+
* - 'csv': CSV formatted string preview
|
|
57
|
+
* - 'markdown': Markdown table format
|
|
58
|
+
*/
|
|
59
|
+
export type SampleDataFormat = "object" | "json" | "csv" | "markdown";
|
|
52
60
|
/**
|
|
53
61
|
* CSV processor options
|
|
54
62
|
*/
|
|
@@ -56,6 +64,7 @@ export type CSVProcessorOptions = {
|
|
|
56
64
|
maxRows?: number;
|
|
57
65
|
formatStyle?: "raw" | "markdown" | "json";
|
|
58
66
|
includeHeaders?: boolean;
|
|
67
|
+
sampleDataFormat?: SampleDataFormat;
|
|
59
68
|
};
|
|
60
69
|
/**
|
|
61
70
|
* PDF API types for different providers
|
|
@@ -34,6 +34,7 @@ export type GenerateOptions = {
|
|
|
34
34
|
images?: Array<Buffer | string | ImageWithAltText>;
|
|
35
35
|
csvFiles?: Array<Buffer | string>;
|
|
36
36
|
pdfFiles?: Array<Buffer | string>;
|
|
37
|
+
videoFiles?: Array<Buffer | string>;
|
|
37
38
|
files?: Array<Buffer | string>;
|
|
38
39
|
content?: Content[];
|
|
39
40
|
};
|
|
@@ -45,6 +46,12 @@ export type GenerateOptions = {
|
|
|
45
46
|
formatStyle?: "raw" | "markdown" | "json";
|
|
46
47
|
includeHeaders?: boolean;
|
|
47
48
|
};
|
|
49
|
+
videoOptions?: {
|
|
50
|
+
frames?: number;
|
|
51
|
+
quality?: number;
|
|
52
|
+
format?: "jpeg" | "png";
|
|
53
|
+
transcribeAudio?: boolean;
|
|
54
|
+
};
|
|
48
55
|
provider?: AIProviderName | string;
|
|
49
56
|
model?: string;
|
|
50
57
|
region?: string;
|
|
@@ -145,6 +145,7 @@ export type StreamOptions = {
|
|
|
145
145
|
images?: Array<Buffer | string | ImageWithAltText>;
|
|
146
146
|
csvFiles?: Array<Buffer | string>;
|
|
147
147
|
pdfFiles?: Array<Buffer | string>;
|
|
148
|
+
videoFiles?: Array<Buffer | string>;
|
|
148
149
|
files?: Array<Buffer | string>;
|
|
149
150
|
content?: Content[];
|
|
150
151
|
};
|
|
@@ -161,6 +162,12 @@ export type StreamOptions = {
|
|
|
161
162
|
formatStyle?: "raw" | "markdown" | "json";
|
|
162
163
|
includeHeaders?: boolean;
|
|
163
164
|
};
|
|
165
|
+
videoOptions?: {
|
|
166
|
+
frames?: number;
|
|
167
|
+
quality?: number;
|
|
168
|
+
format?: "jpeg" | "png";
|
|
169
|
+
transcribeAudio?: boolean;
|
|
170
|
+
};
|
|
164
171
|
provider?: AIProviderName | string;
|
|
165
172
|
model?: string;
|
|
166
173
|
region?: string;
|
|
@@ -65,4 +65,21 @@ export declare class CSVProcessor {
|
|
|
65
65
|
* Best for small datasets (<100 rows)
|
|
66
66
|
*/
|
|
67
67
|
private static toMarkdownTable;
|
|
68
|
+
/**
|
|
69
|
+
* Format sample data according to the specified format
|
|
70
|
+
*
|
|
71
|
+
* @param sampleRows - Array of sample row objects
|
|
72
|
+
* @param format - Output format for sample data
|
|
73
|
+
* @param includeHeaders - Whether to include headers in CSV/markdown formats
|
|
74
|
+
* @returns Formatted sample data as string or array
|
|
75
|
+
*/
|
|
76
|
+
private static formatSampleData;
|
|
77
|
+
/**
|
|
78
|
+
* Convert row objects to CSV string format
|
|
79
|
+
*
|
|
80
|
+
* @param rows - Array of row objects
|
|
81
|
+
* @param includeHeaders - Whether to include header row
|
|
82
|
+
* @returns CSV formatted string
|
|
83
|
+
*/
|
|
84
|
+
private static toCSVString;
|
|
68
85
|
}
|
|
@@ -62,7 +62,7 @@ export class CSVProcessor {
|
|
|
62
62
|
* @returns Formatted CSV data ready for LLM (JSON or Markdown)
|
|
63
63
|
*/
|
|
64
64
|
static async process(content, options) {
|
|
65
|
-
const { maxRows: rawMaxRows = 1000, formatStyle = "raw", includeHeaders = true, } = options || {};
|
|
65
|
+
const { maxRows: rawMaxRows = 1000, formatStyle = "raw", includeHeaders = true, sampleDataFormat = "json", } = options || {};
|
|
66
66
|
const maxRows = Math.max(1, Math.min(10000, rawMaxRows));
|
|
67
67
|
const csvString = content.toString("utf-8");
|
|
68
68
|
// For raw format, return original CSV with row limit (no parsing needed)
|
|
@@ -103,9 +103,7 @@ export class CSVProcessor {
|
|
|
103
103
|
const columnCount = columnNames.length;
|
|
104
104
|
const hasEmptyColumns = columnNames.some((col) => !col || col.trim() === "");
|
|
105
105
|
const sampleRows = rows.slice(0, 3);
|
|
106
|
-
const sampleData = sampleRows
|
|
107
|
-
? JSON.stringify(sampleRows, null, 2)
|
|
108
|
-
: "No data rows";
|
|
106
|
+
const sampleData = this.formatSampleData(sampleRows, sampleDataFormat, includeHeaders);
|
|
109
107
|
// Format parsed data
|
|
110
108
|
const formatted = this.formatForLLM(rows, formatStyle, includeHeaders);
|
|
111
109
|
logger.info(`[CSVProcessor] ${formatStyle} format: ${rowCount} rows × ${columnCount} columns → ${formatted.length} chars`, { rowCount, columnCount, columns: columnNames, hasEmptyColumns });
|
|
@@ -274,5 +272,59 @@ export class CSVProcessor {
|
|
|
274
272
|
});
|
|
275
273
|
return markdown;
|
|
276
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Format sample data according to the specified format
|
|
277
|
+
*
|
|
278
|
+
* @param sampleRows - Array of sample row objects
|
|
279
|
+
* @param format - Output format for sample data
|
|
280
|
+
* @param includeHeaders - Whether to include headers in CSV/markdown formats
|
|
281
|
+
* @returns Formatted sample data as string or array
|
|
282
|
+
*/
|
|
283
|
+
static formatSampleData(sampleRows, format, includeHeaders) {
|
|
284
|
+
if (sampleRows.length === 0) {
|
|
285
|
+
return format === "object" ? [] : "No data rows";
|
|
286
|
+
}
|
|
287
|
+
switch (format) {
|
|
288
|
+
case "object":
|
|
289
|
+
return sampleRows;
|
|
290
|
+
case "json":
|
|
291
|
+
return JSON.stringify(sampleRows, null, 2);
|
|
292
|
+
case "csv":
|
|
293
|
+
return this.toCSVString(sampleRows, includeHeaders);
|
|
294
|
+
case "markdown":
|
|
295
|
+
return this.toMarkdownTable(sampleRows, includeHeaders);
|
|
296
|
+
default:
|
|
297
|
+
return sampleRows;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Convert row objects to CSV string format
|
|
302
|
+
*
|
|
303
|
+
* @param rows - Array of row objects
|
|
304
|
+
* @param includeHeaders - Whether to include header row
|
|
305
|
+
* @returns CSV formatted string
|
|
306
|
+
*/
|
|
307
|
+
static toCSVString(rows, includeHeaders) {
|
|
308
|
+
if (rows.length === 0) {
|
|
309
|
+
return "";
|
|
310
|
+
}
|
|
311
|
+
const headers = Object.keys(rows[0]);
|
|
312
|
+
// Escape CSV values (wrap in quotes if contains comma, quote, or newline)
|
|
313
|
+
const escapeCSV = (value) => {
|
|
314
|
+
if (value.includes(",") || value.includes('"') || value.includes("\n")) {
|
|
315
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
316
|
+
}
|
|
317
|
+
return value;
|
|
318
|
+
};
|
|
319
|
+
const lines = [];
|
|
320
|
+
if (includeHeaders) {
|
|
321
|
+
lines.push(headers.map(escapeCSV).join(","));
|
|
322
|
+
}
|
|
323
|
+
rows.forEach((row) => {
|
|
324
|
+
const values = headers.map((h) => escapeCSV(String(row[h] ?? "")));
|
|
325
|
+
lines.push(values.join(","));
|
|
326
|
+
});
|
|
327
|
+
return lines.join("\n");
|
|
328
|
+
}
|
|
277
329
|
}
|
|
278
330
|
//# sourceMappingURL=csvProcessor.js.map
|