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