forked from open-webui/open-webui
feat: prompt preset support
This commit is contained in:
parent
27aa1e964d
commit
69a037257e
4 changed files with 220 additions and 28 deletions
|
@ -111,3 +111,19 @@ export const checkVersion = (required, current) => {
|
|||
caseFirst: 'upper'
|
||||
}) < 0;
|
||||
};
|
||||
|
||||
export const findWordIndices = (text) => {
|
||||
const regex = /\[([^\]]+)\]/g;
|
||||
let matches = [];
|
||||
let match;
|
||||
|
||||
while ((match = regex.exec(text)) !== null) {
|
||||
matches.push({
|
||||
word: match[1],
|
||||
startIndex: match.index,
|
||||
endIndex: regex.lastIndex - 1
|
||||
});
|
||||
}
|
||||
|
||||
return matches;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue