@lobehub/chat 1.36.22 → 1.36.23
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 +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/src/libs/langchain/loaders/csv/__tests__/__snapshots__/index.test.ts.snap +422 -0
- package/src/libs/langchain/loaders/csv/__tests__/demo.csv +33 -0
- package/src/libs/langchain/loaders/csv/__tests__/index.test.ts +18 -0
- package/src/libs/langchain/loaders/csv/index.ts +7 -0
- package/src/libs/langchain/loaders/index.ts +9 -0
- package/src/libs/langchain/types.ts +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.36.23](https://github.com/lobehub/lobe-chat/compare/v1.36.22...v1.36.23)
|
6
|
+
|
7
|
+
<sup>Released on **2024-12-13**</sup>
|
8
|
+
|
9
|
+
#### 💄 Styles
|
10
|
+
|
11
|
+
- **misc**: Support csv chunking.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Styles
|
19
|
+
|
20
|
+
- **misc**: Support csv chunking, closes [#4123](https://github.com/lobehub/lobe-chat/issues/4123) ([1b993a8](https://github.com/lobehub/lobe-chat/commit/1b993a8))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.36.22](https://github.com/lobehub/lobe-chat/compare/v1.36.21...v1.36.22)
|
6
31
|
|
7
32
|
<sup>Released on **2024-12-13**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.36.
|
3
|
+
"version": "1.36.23",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -0,0 +1,422 @@
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
2
|
+
|
3
|
+
exports[`CSVLoader > should run 1`] = `
|
4
|
+
[
|
5
|
+
Document {
|
6
|
+
"id": undefined,
|
7
|
+
"metadata": {
|
8
|
+
"blobType": "",
|
9
|
+
"line": 1,
|
10
|
+
"source": "blob",
|
11
|
+
},
|
12
|
+
"pageContent": ": 1
|
13
|
+
Hair: Black
|
14
|
+
Eye: Brown
|
15
|
+
Sex: Male
|
16
|
+
Freq: 32",
|
17
|
+
},
|
18
|
+
Document {
|
19
|
+
"id": undefined,
|
20
|
+
"metadata": {
|
21
|
+
"blobType": "",
|
22
|
+
"line": 2,
|
23
|
+
"source": "blob",
|
24
|
+
},
|
25
|
+
"pageContent": ": 2
|
26
|
+
Hair: Brown
|
27
|
+
Eye: Brown
|
28
|
+
Sex: Male
|
29
|
+
Freq: 53",
|
30
|
+
},
|
31
|
+
Document {
|
32
|
+
"id": undefined,
|
33
|
+
"metadata": {
|
34
|
+
"blobType": "",
|
35
|
+
"line": 3,
|
36
|
+
"source": "blob",
|
37
|
+
},
|
38
|
+
"pageContent": ": 3
|
39
|
+
Hair: Red
|
40
|
+
Eye: Brown
|
41
|
+
Sex: Male
|
42
|
+
Freq: 10",
|
43
|
+
},
|
44
|
+
Document {
|
45
|
+
"id": undefined,
|
46
|
+
"metadata": {
|
47
|
+
"blobType": "",
|
48
|
+
"line": 4,
|
49
|
+
"source": "blob",
|
50
|
+
},
|
51
|
+
"pageContent": ": 4
|
52
|
+
Hair: Blond
|
53
|
+
Eye: Brown
|
54
|
+
Sex: Male
|
55
|
+
Freq: 3",
|
56
|
+
},
|
57
|
+
Document {
|
58
|
+
"id": undefined,
|
59
|
+
"metadata": {
|
60
|
+
"blobType": "",
|
61
|
+
"line": 5,
|
62
|
+
"source": "blob",
|
63
|
+
},
|
64
|
+
"pageContent": ": 5
|
65
|
+
Hair: Black
|
66
|
+
Eye: Blue
|
67
|
+
Sex: Male
|
68
|
+
Freq: 11",
|
69
|
+
},
|
70
|
+
Document {
|
71
|
+
"id": undefined,
|
72
|
+
"metadata": {
|
73
|
+
"blobType": "",
|
74
|
+
"line": 6,
|
75
|
+
"source": "blob",
|
76
|
+
},
|
77
|
+
"pageContent": ": 6
|
78
|
+
Hair: Brown
|
79
|
+
Eye: Blue
|
80
|
+
Sex: Male
|
81
|
+
Freq: 50",
|
82
|
+
},
|
83
|
+
Document {
|
84
|
+
"id": undefined,
|
85
|
+
"metadata": {
|
86
|
+
"blobType": "",
|
87
|
+
"line": 7,
|
88
|
+
"source": "blob",
|
89
|
+
},
|
90
|
+
"pageContent": ": 7
|
91
|
+
Hair: Red
|
92
|
+
Eye: Blue
|
93
|
+
Sex: Male
|
94
|
+
Freq: 10",
|
95
|
+
},
|
96
|
+
Document {
|
97
|
+
"id": undefined,
|
98
|
+
"metadata": {
|
99
|
+
"blobType": "",
|
100
|
+
"line": 8,
|
101
|
+
"source": "blob",
|
102
|
+
},
|
103
|
+
"pageContent": ": 8
|
104
|
+
Hair: Blond
|
105
|
+
Eye: Blue
|
106
|
+
Sex: Male
|
107
|
+
Freq: 30",
|
108
|
+
},
|
109
|
+
Document {
|
110
|
+
"id": undefined,
|
111
|
+
"metadata": {
|
112
|
+
"blobType": "",
|
113
|
+
"line": 9,
|
114
|
+
"source": "blob",
|
115
|
+
},
|
116
|
+
"pageContent": ": 9
|
117
|
+
Hair: Black
|
118
|
+
Eye: Hazel
|
119
|
+
Sex: Male
|
120
|
+
Freq: 10",
|
121
|
+
},
|
122
|
+
Document {
|
123
|
+
"id": undefined,
|
124
|
+
"metadata": {
|
125
|
+
"blobType": "",
|
126
|
+
"line": 10,
|
127
|
+
"source": "blob",
|
128
|
+
},
|
129
|
+
"pageContent": ": 10
|
130
|
+
Hair: Brown
|
131
|
+
Eye: Hazel
|
132
|
+
Sex: Male
|
133
|
+
Freq: 25",
|
134
|
+
},
|
135
|
+
Document {
|
136
|
+
"id": undefined,
|
137
|
+
"metadata": {
|
138
|
+
"blobType": "",
|
139
|
+
"line": 11,
|
140
|
+
"source": "blob",
|
141
|
+
},
|
142
|
+
"pageContent": ": 11
|
143
|
+
Hair: Red
|
144
|
+
Eye: Hazel
|
145
|
+
Sex: Male
|
146
|
+
Freq: 7",
|
147
|
+
},
|
148
|
+
Document {
|
149
|
+
"id": undefined,
|
150
|
+
"metadata": {
|
151
|
+
"blobType": "",
|
152
|
+
"line": 12,
|
153
|
+
"source": "blob",
|
154
|
+
},
|
155
|
+
"pageContent": ": 12
|
156
|
+
Hair: Blond
|
157
|
+
Eye: Hazel
|
158
|
+
Sex: Male
|
159
|
+
Freq: 5",
|
160
|
+
},
|
161
|
+
Document {
|
162
|
+
"id": undefined,
|
163
|
+
"metadata": {
|
164
|
+
"blobType": "",
|
165
|
+
"line": 13,
|
166
|
+
"source": "blob",
|
167
|
+
},
|
168
|
+
"pageContent": ": 13
|
169
|
+
Hair: Black
|
170
|
+
Eye: Green
|
171
|
+
Sex: Male
|
172
|
+
Freq: 3",
|
173
|
+
},
|
174
|
+
Document {
|
175
|
+
"id": undefined,
|
176
|
+
"metadata": {
|
177
|
+
"blobType": "",
|
178
|
+
"line": 14,
|
179
|
+
"source": "blob",
|
180
|
+
},
|
181
|
+
"pageContent": ": 14
|
182
|
+
Hair: Brown
|
183
|
+
Eye: Green
|
184
|
+
Sex: Male
|
185
|
+
Freq: 15",
|
186
|
+
},
|
187
|
+
Document {
|
188
|
+
"id": undefined,
|
189
|
+
"metadata": {
|
190
|
+
"blobType": "",
|
191
|
+
"line": 15,
|
192
|
+
"source": "blob",
|
193
|
+
},
|
194
|
+
"pageContent": ": 15
|
195
|
+
Hair: Red
|
196
|
+
Eye: Green
|
197
|
+
Sex: Male
|
198
|
+
Freq: 7",
|
199
|
+
},
|
200
|
+
Document {
|
201
|
+
"id": undefined,
|
202
|
+
"metadata": {
|
203
|
+
"blobType": "",
|
204
|
+
"line": 16,
|
205
|
+
"source": "blob",
|
206
|
+
},
|
207
|
+
"pageContent": ": 16
|
208
|
+
Hair: Blond
|
209
|
+
Eye: Green
|
210
|
+
Sex: Male
|
211
|
+
Freq: 8",
|
212
|
+
},
|
213
|
+
Document {
|
214
|
+
"id": undefined,
|
215
|
+
"metadata": {
|
216
|
+
"blobType": "",
|
217
|
+
"line": 17,
|
218
|
+
"source": "blob",
|
219
|
+
},
|
220
|
+
"pageContent": ": 17
|
221
|
+
Hair: Black
|
222
|
+
Eye: Brown
|
223
|
+
Sex: Female
|
224
|
+
Freq: 36",
|
225
|
+
},
|
226
|
+
Document {
|
227
|
+
"id": undefined,
|
228
|
+
"metadata": {
|
229
|
+
"blobType": "",
|
230
|
+
"line": 18,
|
231
|
+
"source": "blob",
|
232
|
+
},
|
233
|
+
"pageContent": ": 18
|
234
|
+
Hair: Brown
|
235
|
+
Eye: Brown
|
236
|
+
Sex: Female
|
237
|
+
Freq: 66",
|
238
|
+
},
|
239
|
+
Document {
|
240
|
+
"id": undefined,
|
241
|
+
"metadata": {
|
242
|
+
"blobType": "",
|
243
|
+
"line": 19,
|
244
|
+
"source": "blob",
|
245
|
+
},
|
246
|
+
"pageContent": ": 19
|
247
|
+
Hair: Red
|
248
|
+
Eye: Brown
|
249
|
+
Sex: Female
|
250
|
+
Freq: 16",
|
251
|
+
},
|
252
|
+
Document {
|
253
|
+
"id": undefined,
|
254
|
+
"metadata": {
|
255
|
+
"blobType": "",
|
256
|
+
"line": 20,
|
257
|
+
"source": "blob",
|
258
|
+
},
|
259
|
+
"pageContent": ": 20
|
260
|
+
Hair: Blond
|
261
|
+
Eye: Brown
|
262
|
+
Sex: Female
|
263
|
+
Freq: 4",
|
264
|
+
},
|
265
|
+
Document {
|
266
|
+
"id": undefined,
|
267
|
+
"metadata": {
|
268
|
+
"blobType": "",
|
269
|
+
"line": 21,
|
270
|
+
"source": "blob",
|
271
|
+
},
|
272
|
+
"pageContent": ": 21
|
273
|
+
Hair: Black
|
274
|
+
Eye: Blue
|
275
|
+
Sex: Female
|
276
|
+
Freq: 9",
|
277
|
+
},
|
278
|
+
Document {
|
279
|
+
"id": undefined,
|
280
|
+
"metadata": {
|
281
|
+
"blobType": "",
|
282
|
+
"line": 22,
|
283
|
+
"source": "blob",
|
284
|
+
},
|
285
|
+
"pageContent": ": 22
|
286
|
+
Hair: Brown
|
287
|
+
Eye: Blue
|
288
|
+
Sex: Female
|
289
|
+
Freq: 34",
|
290
|
+
},
|
291
|
+
Document {
|
292
|
+
"id": undefined,
|
293
|
+
"metadata": {
|
294
|
+
"blobType": "",
|
295
|
+
"line": 23,
|
296
|
+
"source": "blob",
|
297
|
+
},
|
298
|
+
"pageContent": ": 23
|
299
|
+
Hair: Red
|
300
|
+
Eye: Blue
|
301
|
+
Sex: Female
|
302
|
+
Freq: 7",
|
303
|
+
},
|
304
|
+
Document {
|
305
|
+
"id": undefined,
|
306
|
+
"metadata": {
|
307
|
+
"blobType": "",
|
308
|
+
"line": 24,
|
309
|
+
"source": "blob",
|
310
|
+
},
|
311
|
+
"pageContent": ": 24
|
312
|
+
Hair: Blond
|
313
|
+
Eye: Blue
|
314
|
+
Sex: Female
|
315
|
+
Freq: 64",
|
316
|
+
},
|
317
|
+
Document {
|
318
|
+
"id": undefined,
|
319
|
+
"metadata": {
|
320
|
+
"blobType": "",
|
321
|
+
"line": 25,
|
322
|
+
"source": "blob",
|
323
|
+
},
|
324
|
+
"pageContent": ": 25
|
325
|
+
Hair: Black
|
326
|
+
Eye: Hazel
|
327
|
+
Sex: Female
|
328
|
+
Freq: 5",
|
329
|
+
},
|
330
|
+
Document {
|
331
|
+
"id": undefined,
|
332
|
+
"metadata": {
|
333
|
+
"blobType": "",
|
334
|
+
"line": 26,
|
335
|
+
"source": "blob",
|
336
|
+
},
|
337
|
+
"pageContent": ": 26
|
338
|
+
Hair: Brown
|
339
|
+
Eye: Hazel
|
340
|
+
Sex: Female
|
341
|
+
Freq: 29",
|
342
|
+
},
|
343
|
+
Document {
|
344
|
+
"id": undefined,
|
345
|
+
"metadata": {
|
346
|
+
"blobType": "",
|
347
|
+
"line": 27,
|
348
|
+
"source": "blob",
|
349
|
+
},
|
350
|
+
"pageContent": ": 27
|
351
|
+
Hair: Red
|
352
|
+
Eye: Hazel
|
353
|
+
Sex: Female
|
354
|
+
Freq: 7",
|
355
|
+
},
|
356
|
+
Document {
|
357
|
+
"id": undefined,
|
358
|
+
"metadata": {
|
359
|
+
"blobType": "",
|
360
|
+
"line": 28,
|
361
|
+
"source": "blob",
|
362
|
+
},
|
363
|
+
"pageContent": ": 28
|
364
|
+
Hair: Blond
|
365
|
+
Eye: Hazel
|
366
|
+
Sex: Female
|
367
|
+
Freq: 5",
|
368
|
+
},
|
369
|
+
Document {
|
370
|
+
"id": undefined,
|
371
|
+
"metadata": {
|
372
|
+
"blobType": "",
|
373
|
+
"line": 29,
|
374
|
+
"source": "blob",
|
375
|
+
},
|
376
|
+
"pageContent": ": 29
|
377
|
+
Hair: Black
|
378
|
+
Eye: Green
|
379
|
+
Sex: Female
|
380
|
+
Freq: 2",
|
381
|
+
},
|
382
|
+
Document {
|
383
|
+
"id": undefined,
|
384
|
+
"metadata": {
|
385
|
+
"blobType": "",
|
386
|
+
"line": 30,
|
387
|
+
"source": "blob",
|
388
|
+
},
|
389
|
+
"pageContent": ": 30
|
390
|
+
Hair: Brown
|
391
|
+
Eye: Green
|
392
|
+
Sex: Female
|
393
|
+
Freq: 14",
|
394
|
+
},
|
395
|
+
Document {
|
396
|
+
"id": undefined,
|
397
|
+
"metadata": {
|
398
|
+
"blobType": "",
|
399
|
+
"line": 31,
|
400
|
+
"source": "blob",
|
401
|
+
},
|
402
|
+
"pageContent": ": 31
|
403
|
+
Hair: Red
|
404
|
+
Eye: Green
|
405
|
+
Sex: Female
|
406
|
+
Freq: 7",
|
407
|
+
},
|
408
|
+
Document {
|
409
|
+
"id": undefined,
|
410
|
+
"metadata": {
|
411
|
+
"blobType": "",
|
412
|
+
"line": 32,
|
413
|
+
"source": "blob",
|
414
|
+
},
|
415
|
+
"pageContent": ": 32
|
416
|
+
Hair: Blond
|
417
|
+
Eye: Green
|
418
|
+
Sex: Female
|
419
|
+
Freq: 8",
|
420
|
+
},
|
421
|
+
]
|
422
|
+
`;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"","Hair","Eye","Sex","Freq"
|
2
|
+
"1","Black","Brown","Male",32
|
3
|
+
"2","Brown","Brown","Male",53
|
4
|
+
"3","Red","Brown","Male",10
|
5
|
+
"4","Blond","Brown","Male",3
|
6
|
+
"5","Black","Blue","Male",11
|
7
|
+
"6","Brown","Blue","Male",50
|
8
|
+
"7","Red","Blue","Male",10
|
9
|
+
"8","Blond","Blue","Male",30
|
10
|
+
"9","Black","Hazel","Male",10
|
11
|
+
"10","Brown","Hazel","Male",25
|
12
|
+
"11","Red","Hazel","Male",7
|
13
|
+
"12","Blond","Hazel","Male",5
|
14
|
+
"13","Black","Green","Male",3
|
15
|
+
"14","Brown","Green","Male",15
|
16
|
+
"15","Red","Green","Male",7
|
17
|
+
"16","Blond","Green","Male",8
|
18
|
+
"17","Black","Brown","Female",36
|
19
|
+
"18","Brown","Brown","Female",66
|
20
|
+
"19","Red","Brown","Female",16
|
21
|
+
"20","Blond","Brown","Female",4
|
22
|
+
"21","Black","Blue","Female",9
|
23
|
+
"22","Brown","Blue","Female",34
|
24
|
+
"23","Red","Blue","Female",7
|
25
|
+
"24","Blond","Blue","Female",64
|
26
|
+
"25","Black","Hazel","Female",5
|
27
|
+
"26","Brown","Hazel","Female",29
|
28
|
+
"27","Red","Hazel","Female",7
|
29
|
+
"28","Blond","Hazel","Female",5
|
30
|
+
"29","Black","Green","Female",2
|
31
|
+
"30","Brown","Green","Female",14
|
32
|
+
"31","Red","Green","Female",7
|
33
|
+
"32","Blond","Green","Female",8
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// @vitest-environment node
|
2
|
+
import * as fs from 'node:fs';
|
3
|
+
import { join } from 'node:path';
|
4
|
+
import { expect } from 'vitest';
|
5
|
+
|
6
|
+
import { CsVLoader } from '../index';
|
7
|
+
|
8
|
+
describe('CSVLoader', () => {
|
9
|
+
it('should run', async () => {
|
10
|
+
const content = fs.readFileSync(join(__dirname, `./demo.csv`), 'utf-8');
|
11
|
+
|
12
|
+
const fileBlob = new Blob([Buffer.from(content)]);
|
13
|
+
|
14
|
+
const data = await CsVLoader(fileBlob);
|
15
|
+
|
16
|
+
expect(data).toMatchSnapshot();
|
17
|
+
});
|
18
|
+
});
|
@@ -13,6 +13,7 @@ import { MarkdownLoader } from './markdown';
|
|
13
13
|
import { PdfLoader } from './pdf';
|
14
14
|
import { PPTXLoader } from './pptx';
|
15
15
|
import { TextLoader } from './txt';
|
16
|
+
import { CsVLoader} from './csv';
|
16
17
|
|
17
18
|
class LangChainError extends Error {
|
18
19
|
constructor(message: string) {
|
@@ -59,6 +60,10 @@ export class ChunkingLoader {
|
|
59
60
|
return await TextLoader(txt);
|
60
61
|
}
|
61
62
|
|
63
|
+
case 'csv': {
|
64
|
+
return await CsVLoader(fileBlob);
|
65
|
+
}
|
66
|
+
|
62
67
|
default: {
|
63
68
|
throw new Error(
|
64
69
|
`Unsupported file type [${type}], please check your file is supported, or create report issue here: https://github.com/lobehub/lobe-chat/discussions/3550`,
|
@@ -91,6 +96,10 @@ export class ChunkingLoader {
|
|
91
96
|
return 'markdown';
|
92
97
|
}
|
93
98
|
|
99
|
+
if (filename.endsWith('csv') ) {
|
100
|
+
return 'csv';
|
101
|
+
}
|
102
|
+
|
94
103
|
const ext = filename.split('.').pop();
|
95
104
|
|
96
105
|
if (ext && SupportedTextSplitterLanguages.includes(ext as SupportedTextSplitterLanguage)) {
|
@@ -1 +1 @@
|
|
1
|
-
export type LangChainLoaderType = 'code' | 'ppt' | 'pdf' | 'markdown' | 'doc' | 'text' | 'latex';
|
1
|
+
export type LangChainLoaderType = 'code' | 'ppt' | 'pdf' | 'markdown' | 'doc' | 'text' | 'latex' | 'csv';
|