mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
c2b5200663
commit
8b998420fe
2 changed files with 7 additions and 5 deletions
|
|
@ -44,7 +44,8 @@
|
|||
extractSentencesForAudio,
|
||||
promptTemplate,
|
||||
splitStream,
|
||||
sleep
|
||||
sleep,
|
||||
removeDetailsWithReasoning
|
||||
} from '$lib/utils';
|
||||
|
||||
import { generateChatCompletion } from '$lib/apis/ollama';
|
||||
|
|
@ -1486,10 +1487,6 @@
|
|||
params?.stream_response ??
|
||||
true;
|
||||
|
||||
const removeDetailsWithReasoning = (content) => {
|
||||
return content.replace(/<details\s+type="reasoning"[^>]*>.*?<\/details>/gis, '').trim();
|
||||
};
|
||||
|
||||
const messages = [
|
||||
params?.system || $settings.system || (responseMessage?.userContext ?? null)
|
||||
? {
|
||||
|
|
|
|||
|
|
@ -666,6 +666,10 @@ export const cleanText = (content: string) => {
|
|||
return removeFormattings(removeEmojis(content.trim()));
|
||||
};
|
||||
|
||||
export const removeDetailsWithReasoning = (content) => {
|
||||
return content.replace(/<details\s+type="reasoning"[^>]*>.*?<\/details>/gis, '').trim();
|
||||
};
|
||||
|
||||
// This regular expression matches code blocks marked by triple backticks
|
||||
const codeBlockRegex = /```[\s\S]*?```/g;
|
||||
|
||||
|
|
@ -735,6 +739,7 @@ export const extractSentencesForAudio = (text: string) => {
|
|||
};
|
||||
|
||||
export const getMessageContentParts = (content: string, split_on: string = 'punctuation') => {
|
||||
content = removeDetailsWithReasoning(content);
|
||||
const messageContentParts: string[] = [];
|
||||
|
||||
switch (split_on) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue