This commit is contained in:
Saifeddine ALOUI 2025-01-26 20:00:12 +01:00
parent b4c6fa22eb
commit 4e0638c906
12 changed files with 542 additions and 454 deletions

View File

@ -59,17 +59,17 @@ async def update_software():
## 3. Duplicate Endpoints ## 3. Duplicate Endpoints
There are two identical endpoints for `get_lollms_webui_version`. One of them is redundant and should be removed. There are two identical endpoints for `get_version_infos`. One of them is redundant and should be removed.
**Vulnerable Code Snippet:** **Vulnerable Code Snippet:**
```python ```python
@router.get("/get_versionID") @router.get("/get_versionID")
async def get_lollms_webui_version(): async def get_version_infos():
# ... # ...
@router.get("/get_lollms_webui_version") @router.get("/get_version_infos")
async def get_lollms_webui_version(): async def get_version_infos():
# ... # ...
``` ```
@ -78,8 +78,8 @@ async def get_lollms_webui_version():
Remove the redundant endpoint. Remove the redundant endpoint.
```python ```python
@router.get("/get_lollms_webui_version") @router.get("/get_version_infos")
async def get_lollms_webui_version(): async def get_version_infos():
# ... # ...
``` ```

0
endpoints/news/news.html Normal file
View File

@ -1 +1 @@
Subproject commit 8622524726726fe400d516a3977cf4bb7de33b9d Subproject commit 243ab392acae79bcc7c30e2536a60b1a2f18e006

View File

@ -75,7 +75,14 @@ def terminate_thread(thread):
) # The current version of the webui ) # The current version of the webui
lollms_webui_version = "v17 (codename Pulsar 💫)" lollms_webui_version = {
"version_main":18,
"version_secondary":0,
"version_type":"alpha",
"version_codename":"Matrix 💊"
}
class LOLLMSWebUI(LOLLMSElfServer): class LOLLMSWebUI(LOLLMSElfServer):

File diff suppressed because one or more lines are too long

17
web/dist/assets/index-CMnOu-iP.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
web/dist/index.html vendored
View File

@ -6,8 +6,8 @@
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script> <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI</title> <title>LoLLMS WebUI</title>
<script type="module" crossorigin src="/assets/index-9l1BDz4P.js"></script> <script type="module" crossorigin src="/assets/index-BVKy-umM.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DnyQ-c-6.css"> <link rel="stylesheet" crossorigin href="/assets/index-CMnOu-iP.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@ -12,6 +12,11 @@
:client_id="client_id" :client_id="client_id"
@update-code="updateCode(index, $event)" @update-code="updateCode(index, $event)"
></code-block> ></code-block>
<thinking-block
v-if="item.type === 'thinking'"
:content="item.content"
:is-done="item.is_done"
></thinking-block>
<div v-else v-html="item.html"></div> <div v-else v-html="item.html"></div>
</div> </div>
</div> </div>
@ -30,6 +35,7 @@
import 'highlight.js/styles/tokyo-night-dark.css'; import 'highlight.js/styles/tokyo-night-dark.css';
import attrs from 'markdown-it-attrs'; import attrs from 'markdown-it-attrs';
import CodeBlock from './CodeBlock.vue'; import CodeBlock from './CodeBlock.vue';
import ThinkingBlock from './ThinkingBlock.vue'
import hljs from 'highlight.js'; import hljs from 'highlight.js';
import mathjax from 'markdown-it-mathjax3'; import mathjax from 'markdown-it-mathjax3';
@ -71,98 +77,158 @@
}, },
components: { components: {
CodeBlock, CodeBlock,
ThinkingBlock,
}, },
setup(props) { setup(props) {
const md = new MarkdownIt({ // Custom rule for thinking blocks
html: true, const thinkingRule = (state, startLine, endLine, silent) => {
breaks: true, // Enable single line breaks let start = state.bMarks[startLine] + state.tShift[startLine];
highlight: (code, language) => { let max = state.eMarks[startLine];
const validLanguage = language && hljs.getLanguage(language) ? language : 'plaintext';
return hljs.highlight(validLanguage, code).value; let line = state.src.slice(start, max);
},
renderInline: false, if (!line.trim().startsWith('<thinking>')) return false;
})
.use(emoji) let currentLine = startLine + 1;
.use(anchor) let content = [];
.use(implicitFigures, { let found = false;
figcaption: true,
}) // Search for closing tag
.use(attrs) while (currentLine < endLine) {
.use(MarkdownItMultimdTable, { let currentLineContent = state.src.slice(
enableRowspan: true, state.bMarks[currentLine],
enableColspan: true, state.eMarks[currentLine]
enableGridTables: true, );
enableGridTablesExtra: true,
enableTableIndentation: true, if (currentLineContent.trim() === '</thinking>') {
tableCellPadding: ' ', found = true;
tableCellJoiner: '|', break;
multilineCellStartMarker: '|>', }
multilineCellEndMarker: '<|', content.push(currentLineContent);
multilineCellPadding: ' ', currentLine++;
multilineCellJoiner: '\n', }
})
.use(mathjax, { if (silent) return true;
inlineOpen: ['$', '\\('],
inlineClose: ['$', '\\)'], // Create tokens
blockOpen: ['$$', '\\['], let token = state.push('thinking_open', 'div', 1);
blockClose: ['$$', '\\]'], token.markup = '<thinking>';
mode: 'tex', token.block = true;
beforeMath: '', token.is_done = found; // Add is_done status
afterMath: ''
}); token = state.push('thinking_content', '', 0);
token.content = content.join('\n');
const markdownItems = ref([]); token.is_done = found;
const updateMarkdown = () => {
if (props.markdownText) { token = state.push('thinking_close', 'div', -1);
let tokens = md.parse(props.markdownText, {}); token.markup = '</thinking>';
let cumulated = []; token.block = true;
markdownItems.value = []; token.is_done = found;
for (let i = 0; i < tokens.length; i++) {
if (tokens[i].type !== 'fence') { state.line = found ? currentLine + 1 : currentLine;
cumulated.push(tokens[i]); return true;
} else { };
if (cumulated.length > 0) {
markdownItems.value.push({ const md = new MarkdownIt({
type: 'html', html: true,
html: md.renderer.render(cumulated, md.options, {}), breaks: true,
}); highlight: (code, language) => {
cumulated = []; const validLanguage = language && hljs.getLanguage(language) ? language : 'plaintext';
} return hljs.highlight(validLanguage, code).value;
},
})
.use(emoji)
.use(anchor)
.use(implicitFigures, {
figcaption: true,
})
.use(attrs);
// Add renderer rules
md.renderer.rules.thinking_open = () => '<div class="thinking-block">';
md.renderer.rules.thinking_content = (tokens, idx) => {
return `<div class="thinking-content">${md.utils.escapeHtml(tokens[idx].content)}</div>`;
};
md.renderer.rules.thinking_close = () => '</div>';
// Add the rule
md.block.ruler.before('fence', 'thinking', thinkingRule);
const markdownItems = ref([]);
const updateMarkdown = () => {
if (props.markdownText) {
let tokens = md.parse(props.markdownText, {});
let cumulated = [];
markdownItems.value = [];
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
if (token.type === 'thinking_open') {
if (cumulated.length > 0) {
markdownItems.value.push({ markdownItems.value.push({
type: 'code', type: 'html',
language: escapeHtml(tokens[i].info), html: md.renderer.render(cumulated, md.options, {}),
code: tokens[i].content, });
cumulated = [];
}
const contentToken = tokens[i + 1];
if (contentToken && contentToken.type === 'thinking_content') {
markdownItems.value.push({
type: 'thinking',
content: contentToken.content,
is_done: contentToken.is_done // Add is_done status
}); });
} }
}
if (cumulated.length > 0) { i += 2;
} else if (token.type === 'fence') {
if (cumulated.length > 0) {
markdownItems.value.push({
type: 'html',
html: md.renderer.render(cumulated, md.options, {}),
});
cumulated = [];
}
markdownItems.value.push({ markdownItems.value.push({
type: 'html', type: 'code',
html: md.renderer.render(cumulated, md.options, {}), language: escapeHtml(token.info),
code: token.content,
}); });
cumulated = []; } else {
cumulated.push(token);
} }
} else {
markdownItems.value = [];
} }
if (cumulated.length > 0) {
markdownItems.value.push({
type: 'html',
html: md.renderer.render(cumulated, md.options, {}),
});
}
nextTick(() => { nextTick(() => {
feather.replace(); feather.replace();
if (window.MathJax) { if (window.MathJax) {
window.MathJax.typesetPromise(); // Ensure MathJax typesets after rendering window.MathJax.typesetPromise();
} }
}); });
}; } else {
markdownItems.value = [];
}
};
const updateCode = (index, newCode) => { const updateCode = (index, newCode) => {
markdownItems.value[index].code = newCode; markdownItems.value[index].code = newCode;
}; };
watch(() => props.markdownText, updateMarkdown); watch(() => props.markdownText, updateMarkdown);
onMounted(() => { onMounted(() => {
updateMarkdown(); updateMarkdown();
}); });
return { markdownItems, updateCode }; return { markdownItems, updateCode };
}, }
}; };
</script> </script>

View File

@ -277,7 +277,16 @@ export const store = createStore({
try{ try{
let res = await axios.get('/get_lollms_webui_version', {}); let res = await axios.get('/get_lollms_webui_version', {});
if (res) { if (res) {
this.state.version = res.data console.log("getting version")
console.log(res.data.version_main)
res = res.data
if(res.version_type!=""){
this.state.version = `${res.version_main}.${res.version_secondary} ${res.version_type} (${res.version_codename})`
}
else{
this.state.version = `${res.version_main}.${res.version_secondary} (${res.version_codename})`
}
console.log(this.state.version)
} }
} }

View File

@ -989,23 +989,6 @@
> >
</div> </div>
</div> </div>
<style scoped>
.toggle-checkbox {
@apply appearance-none w-9 h-5 rounded-full bg-gray-300 dark:bg-gray-600
checked:bg-blue-500 transition-colors duration-200 relative cursor-pointer;
}
.toggle-checkbox:before {
content: '';
@apply absolute w-4 h-4 bg-white rounded-full left-0.5 top-0.5
transform transition-transform duration-200;
}
.toggle-checkbox:checked:before {
@apply translate-x-4;
}
</style>
</div> </div>
</Card> </Card>
<Card title="Knowledge database" :is_subcard="true" class="pb-2 m-2"> <Card title="Knowledge database" :is_subcard="true" class="pb-2 m-2">
@ -4418,6 +4401,20 @@
/> />
</template> </template>
<style scoped> <style scoped>
.toggle-checkbox {
@apply appearance-none w-9 h-5 rounded-full bg-gray-300 dark:bg-gray-600
checked:bg-blue-500 transition-colors duration-200 relative cursor-pointer;
}
.toggle-checkbox:before {
content: '';
@apply absolute w-4 h-4 bg-white rounded-full left-0.5 top-0.5
transform transition-transform duration-200;
}
.toggle-checkbox:checked:before {
@apply translate-x-4;
}
.input-field { .input-field {
@apply w-full px-3 py-2 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:text-white transition-colors duration-200; @apply w-full px-3 py-2 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:text-white transition-colors duration-200;
} }

@ -1 +1 @@
Subproject commit 9607b5a4a2de3947fe4ac0f504b487400c0c429f Subproject commit 61797ac0ab24e1dd7376c3c3dbc2c2d81bdf99fe