mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-03-03 20:30:31 +00:00
synced
This commit is contained in:
parent
b4c6fa22eb
commit
4e0638c906
@ -59,17 +59,17 @@ async def update_software():
|
||||
|
||||
## 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:**
|
||||
|
||||
```python
|
||||
@router.get("/get_versionID")
|
||||
async def get_lollms_webui_version():
|
||||
async def get_version_infos():
|
||||
# ...
|
||||
|
||||
@router.get("/get_lollms_webui_version")
|
||||
async def get_lollms_webui_version():
|
||||
@router.get("/get_version_infos")
|
||||
async def get_version_infos():
|
||||
# ...
|
||||
```
|
||||
|
||||
@ -78,8 +78,8 @@ async def get_lollms_webui_version():
|
||||
Remove the redundant endpoint.
|
||||
|
||||
```python
|
||||
@router.get("/get_lollms_webui_version")
|
||||
async def get_lollms_webui_version():
|
||||
@router.get("/get_version_infos")
|
||||
async def get_version_infos():
|
||||
# ...
|
||||
```
|
||||
|
||||
|
0
endpoints/news/news.html
Normal file
0
endpoints/news/news.html
Normal file
@ -1 +1 @@
|
||||
Subproject commit 8622524726726fe400d516a3977cf4bb7de33b9d
|
||||
Subproject commit 243ab392acae79bcc7c30e2536a60b1a2f18e006
|
@ -75,7 +75,14 @@ def terminate_thread(thread):
|
||||
) # 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):
|
||||
|
File diff suppressed because one or more lines are too long
17
web/dist/assets/index-CMnOu-iP.css
vendored
Normal file
17
web/dist/assets/index-CMnOu-iP.css
vendored
Normal file
File diff suppressed because one or more lines are too long
8
web/dist/assets/index-DnyQ-c-6.css
vendored
8
web/dist/assets/index-DnyQ-c-6.css
vendored
File diff suppressed because one or more lines are too long
4
web/dist/index.html
vendored
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
||||
<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">
|
||||
<title>LoLLMS WebUI</title>
|
||||
<script type="module" crossorigin src="/assets/index-9l1BDz4P.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DnyQ-c-6.css">
|
||||
<script type="module" crossorigin src="/assets/index-BVKy-umM.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CMnOu-iP.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -12,6 +12,11 @@
|
||||
:client_id="client_id"
|
||||
@update-code="updateCode(index, $event)"
|
||||
></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>
|
||||
</div>
|
||||
@ -30,6 +35,7 @@
|
||||
import 'highlight.js/styles/tokyo-night-dark.css';
|
||||
import attrs from 'markdown-it-attrs';
|
||||
import CodeBlock from './CodeBlock.vue';
|
||||
import ThinkingBlock from './ThinkingBlock.vue'
|
||||
import hljs from 'highlight.js';
|
||||
import mathjax from 'markdown-it-mathjax3';
|
||||
|
||||
@ -71,98 +77,158 @@
|
||||
},
|
||||
components: {
|
||||
CodeBlock,
|
||||
ThinkingBlock,
|
||||
},
|
||||
setup(props) {
|
||||
const md = new MarkdownIt({
|
||||
html: true,
|
||||
breaks: true, // Enable single line breaks
|
||||
highlight: (code, language) => {
|
||||
const validLanguage = language && hljs.getLanguage(language) ? language : 'plaintext';
|
||||
return hljs.highlight(validLanguage, code).value;
|
||||
},
|
||||
renderInline: false,
|
||||
})
|
||||
.use(emoji)
|
||||
.use(anchor)
|
||||
.use(implicitFigures, {
|
||||
figcaption: true,
|
||||
})
|
||||
.use(attrs)
|
||||
.use(MarkdownItMultimdTable, {
|
||||
enableRowspan: true,
|
||||
enableColspan: true,
|
||||
enableGridTables: true,
|
||||
enableGridTablesExtra: true,
|
||||
enableTableIndentation: true,
|
||||
tableCellPadding: ' ',
|
||||
tableCellJoiner: '|',
|
||||
multilineCellStartMarker: '|>',
|
||||
multilineCellEndMarker: '<|',
|
||||
multilineCellPadding: ' ',
|
||||
multilineCellJoiner: '\n',
|
||||
})
|
||||
.use(mathjax, {
|
||||
inlineOpen: ['$', '\\('],
|
||||
inlineClose: ['$', '\\)'],
|
||||
blockOpen: ['$$', '\\['],
|
||||
blockClose: ['$$', '\\]'],
|
||||
mode: 'tex',
|
||||
beforeMath: '',
|
||||
afterMath: ''
|
||||
});
|
||||
|
||||
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++) {
|
||||
if (tokens[i].type !== 'fence') {
|
||||
cumulated.push(tokens[i]);
|
||||
} else {
|
||||
if (cumulated.length > 0) {
|
||||
markdownItems.value.push({
|
||||
type: 'html',
|
||||
html: md.renderer.render(cumulated, md.options, {}),
|
||||
});
|
||||
cumulated = [];
|
||||
}
|
||||
// Custom rule for thinking blocks
|
||||
const thinkingRule = (state, startLine, endLine, silent) => {
|
||||
let start = state.bMarks[startLine] + state.tShift[startLine];
|
||||
let max = state.eMarks[startLine];
|
||||
|
||||
let line = state.src.slice(start, max);
|
||||
|
||||
if (!line.trim().startsWith('<thinking>')) return false;
|
||||
|
||||
let currentLine = startLine + 1;
|
||||
let content = [];
|
||||
let found = false;
|
||||
|
||||
// Search for closing tag
|
||||
while (currentLine < endLine) {
|
||||
let currentLineContent = state.src.slice(
|
||||
state.bMarks[currentLine],
|
||||
state.eMarks[currentLine]
|
||||
);
|
||||
|
||||
if (currentLineContent.trim() === '</thinking>') {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
content.push(currentLineContent);
|
||||
currentLine++;
|
||||
}
|
||||
|
||||
if (silent) return true;
|
||||
|
||||
// Create tokens
|
||||
let token = state.push('thinking_open', 'div', 1);
|
||||
token.markup = '<thinking>';
|
||||
token.block = true;
|
||||
token.is_done = found; // Add is_done status
|
||||
|
||||
token = state.push('thinking_content', '', 0);
|
||||
token.content = content.join('\n');
|
||||
token.is_done = found;
|
||||
|
||||
token = state.push('thinking_close', 'div', -1);
|
||||
token.markup = '</thinking>';
|
||||
token.block = true;
|
||||
token.is_done = found;
|
||||
|
||||
state.line = found ? currentLine + 1 : currentLine;
|
||||
return true;
|
||||
};
|
||||
|
||||
const md = new MarkdownIt({
|
||||
html: true,
|
||||
breaks: true,
|
||||
highlight: (code, language) => {
|
||||
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({
|
||||
type: 'code',
|
||||
language: escapeHtml(tokens[i].info),
|
||||
code: tokens[i].content,
|
||||
type: 'html',
|
||||
html: md.renderer.render(cumulated, md.options, {}),
|
||||
});
|
||||
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({
|
||||
type: 'html',
|
||||
html: md.renderer.render(cumulated, md.options, {}),
|
||||
type: 'code',
|
||||
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(() => {
|
||||
feather.replace();
|
||||
if (window.MathJax) {
|
||||
window.MathJax.typesetPromise(); // Ensure MathJax typesets after rendering
|
||||
window.MathJax.typesetPromise();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
} else {
|
||||
markdownItems.value = [];
|
||||
}
|
||||
};
|
||||
const updateCode = (index, newCode) => {
|
||||
markdownItems.value[index].code = newCode;
|
||||
};
|
||||
|
||||
|
||||
watch(() => props.markdownText, updateMarkdown);
|
||||
|
||||
onMounted(() => {
|
||||
updateMarkdown();
|
||||
});
|
||||
|
||||
return { markdownItems, updateCode };
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -277,7 +277,16 @@ export const store = createStore({
|
||||
try{
|
||||
let res = await axios.get('/get_lollms_webui_version', {});
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -989,23 +989,6 @@
|
||||
>
|
||||
</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>
|
||||
</Card>
|
||||
<Card title="Knowledge database" :is_subcard="true" class="pb-2 m-2">
|
||||
@ -4418,6 +4401,20 @@
|
||||
/>
|
||||
</template>
|
||||
<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 {
|
||||
@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
|
Loading…
x
Reference in New Issue
Block a user