v4.4.7-2 (#388)
This commit is contained in:
@@ -25,7 +25,7 @@ export const adaptBill = (bill: BillSchema): UserBillType => {
|
||||
};
|
||||
|
||||
export const gptMessage2ChatType = (messages: MessageItemType[]): ChatItemType[] => {
|
||||
const roleMap: Record<`${ChatCompletionRequestMessageRoleEnum}`, `${ChatRoleEnum}`> = {
|
||||
const roleMap = {
|
||||
[ChatCompletionRequestMessageRoleEnum.Assistant]: ChatRoleEnum.AI,
|
||||
[ChatCompletionRequestMessageRoleEnum.User]: ChatRoleEnum.Human,
|
||||
[ChatCompletionRequestMessageRoleEnum.System]: ChatRoleEnum.System,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
replace {{variable}} to value
|
||||
*/
|
||||
export function replaceVariable(text: string, obj: Record<string, string>) {
|
||||
export function replaceVariable(text: string, obj: Record<string, string | number>) {
|
||||
for (const key in obj) {
|
||||
const val = obj[key];
|
||||
if (typeof val !== 'string') continue;
|
||||
|
||||
@@ -11,7 +11,14 @@ export const splitText2Chunks = ({ text, maxLen }: { text: string; maxLen: numbe
|
||||
const overlapLen = Math.floor(maxLen * 0.25); // Overlap length
|
||||
|
||||
try {
|
||||
const splitTexts = text.split(/(?<=[。!?;.!?;\n])/g);
|
||||
const tempMarker = 'SPLIT_HERE';
|
||||
text = text.replace(/\n{3,}/g, '\n');
|
||||
text = text.replace(/\s/g, ' ');
|
||||
text = text.replace('\n\n', '');
|
||||
const splitTexts = text
|
||||
.replace(/([。!?;]|\.\s|!\s|\?\s|;\s|\n)/g, `$1${tempMarker}`)
|
||||
.split(tempMarker)
|
||||
.filter((part) => part);
|
||||
const chunks: string[] = [];
|
||||
|
||||
let preChunk = '';
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function chunksUpload({
|
||||
mode,
|
||||
chunks,
|
||||
prompt,
|
||||
rate = 50,
|
||||
rate = 150,
|
||||
onUploading
|
||||
}: {
|
||||
kbId: string;
|
||||
|
||||
Reference in New Issue
Block a user