mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
enh: image tool response
This commit is contained in:
@@ -683,6 +683,31 @@ export const removeDetails = (content, types) => {
|
||||
return content;
|
||||
};
|
||||
|
||||
export const processDetails = (content) => {
|
||||
content = removeDetails(content, ['reasoning', 'code_interpreter']);
|
||||
|
||||
// This regex matches <details> tags with type="tool_calls" and captures their attributes to convert them to <tool_calls> tags
|
||||
const detailsRegex = /<details\s+type="tool_calls"([^>]*)>([\s\S]*?)<\/details>/gis;
|
||||
const matches = content.match(detailsRegex);
|
||||
if (matches) {
|
||||
for (const match of matches) {
|
||||
const attributesRegex = /(\w+)="([^"]*)"/g;
|
||||
const attributes = {};
|
||||
let attributeMatch;
|
||||
while ((attributeMatch = attributesRegex.exec(match)) !== null) {
|
||||
attributes[attributeMatch[1]] = attributeMatch[2];
|
||||
}
|
||||
|
||||
content = content.replace(
|
||||
match,
|
||||
`<tool_calls name="${attributes.name}" result="${attributes.result}"/>`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
// This regular expression matches code blocks marked by triple backticks
|
||||
const codeBlockRegex = /```[\s\S]*?```/g;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user