Skip to content

Commit

Permalink
Fix thoughts extraction regex for multiline content handling (#687)
Browse files Browse the repository at this point in the history
# PR Checklist
- [x] Did you check if it works normally in all models? *ignore this
when it dosen't uses models*
- [x] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions?
- [ ] Did you added a type def?

# Description

This PR updates the regex used for extracting <Thoughts> content to
handle multiline cases reliably. The previous regex (.+?) had
limitations when processing text spanning multiple lines, as it could
not match content with line breaks.
  • Loading branch information
kwaroran authored Dec 24, 2024
2 parents 29c9f0a + 6d182a8 commit 98ca173
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ts/process/index.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
}
}
let thoughts:string[] = []
formatedChat = formatedChat.replace(/<Thoughts>(.+?)<\/Thoughts>/gm, (match, p1) => {
formatedChat = formatedChat.replace(/<Thoughts>([\s\S]+?)<\/Thoughts>/g, (match, p1) => {
thoughts.push(p1)
return ''
})
Expand Down

0 comments on commit 98ca173

Please sign in to comment.