-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* perf: plan tip * perf: upload size controller * feat: add image ttl index * feat: new upload file ux * remove file * feat: support read pptx * feat: support xlsx * fix: rerank docker flie
- Loading branch information
Showing
90 changed files
with
2,703 additions
and
1,674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { connectionMongo, type Model } from '../../mongo'; | ||
const { Schema, model, models } = connectionMongo; | ||
import { RawTextBufferSchemaType } from './type'; | ||
|
||
export const collectionName = 'buffer.rawText'; | ||
|
||
const RawTextBufferSchema = new Schema({ | ||
sourceId: { | ||
type: String, | ||
required: true | ||
}, | ||
rawText: { | ||
type: String, | ||
default: '' | ||
}, | ||
createTime: { | ||
type: Date, | ||
default: () => new Date() | ||
}, | ||
metadata: Object | ||
}); | ||
|
||
try { | ||
RawTextBufferSchema.index({ sourceId: 1 }); | ||
// 20 minutes | ||
RawTextBufferSchema.index({ createTime: 1 }, { expireAfterSeconds: 20 * 60 }); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
export const MongoRwaTextBuffer: Model<RawTextBufferSchemaType> = | ||
models[collectionName] || model(collectionName, RawTextBufferSchema); | ||
MongoRwaTextBuffer.syncIndexes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type RawTextBufferSchemaType = { | ||
sourceId: string; | ||
rawText: string; | ||
createTime: Date; | ||
metadata?: { | ||
filename: string; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Papa from 'papaparse'; | ||
import { ReadFileByBufferParams, ReadFileResponse } from './type.d'; | ||
import { readFileRawText } from './rawText'; | ||
|
||
// 加载源文件内容 | ||
export const readCsvRawText = async (params: ReadFileByBufferParams): Promise<ReadFileResponse> => { | ||
const { rawText } = readFileRawText(params); | ||
|
||
const csvArr = Papa.parse(rawText).data as string[][]; | ||
|
||
const header = csvArr[0]; | ||
|
||
const formatText = header | ||
? csvArr.map((item) => item.map((item, i) => `${header[i]}:${item}`).join('\n')).join('\n') | ||
: ''; | ||
|
||
return { | ||
rawText, | ||
formatText | ||
}; | ||
}; |
Oops, something went wrong.