Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
Latest commit
38 lines (30 loc) · 1.02 KB
/
Copy pathutils.ts
File metadata and controls
38 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import{IMessage,IPart}from"./types";
exportfunctionremToPx(rem: number): number{
constrootFontSize=parseFloat(getComputedStyle(document.documentElement).fontSize);
returnrem*rootFontSize;
}
exportfunctionpxToRem(px: number): number{
constrootFontSize=parseFloat(getComputedStyle(document.documentElement).fontSize);
returnpx/rootFontSize;
}
exportfunctiongetMessageParts(message: IMessage): IPart[]{
returnmessage.parts?.length
? message.parts
: [{text: '',type: 'reasoning',state: 'streaming'}];
}
functionaddNewLineBeforeTitles(text: string): string{
returntext.replace(/(\*\*[^*]+\*\*)/g,'\n\n$1');
}
exportfunctionextractTitleAndTextFromReasoning(reasoningText: string): {title: string|null;body: string}{
constmatch=reasoningText.match(/^\*\*(.*?)\*\*(.*)$/s);
if(!match){
return{
title: null,
body: addNewLineBeforeTitles(reasoningText)
};
}
return{
title: match[1].trim(),
body: addNewLineBeforeTitles(match[2].trim())
};
}