mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-21 05:13:10 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
9f891f6b33
10
app.py
10
app.py
@ -484,7 +484,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
|
||||
elif setting_name== "model_name":
|
||||
self.config["model_name"]=data['setting_value']
|
||||
try:
|
||||
self.binding.build_model()
|
||||
self.model = self.binding.build_model()
|
||||
except Exception as ex:
|
||||
print(f"Couldn't load model: [{ex}]")
|
||||
return jsonify({ "status":False, 'error':str(ex)})
|
||||
@ -497,16 +497,10 @@ class LoLLMsWebUI(LoLLMsAPPI):
|
||||
self.config["binding_name"]=data['setting_value']
|
||||
try:
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths)
|
||||
try:
|
||||
self.binding.build_model()
|
||||
except Exception as ex:
|
||||
print(f"Couldn't load model: [{ex}]")
|
||||
return jsonify({ "status":False, 'error':str(ex)})
|
||||
self.model = None
|
||||
except Exception as ex:
|
||||
print(f"Couldn't build binding: [{ex}]")
|
||||
return jsonify({"status":False, 'error':str(ex)})
|
||||
|
||||
|
||||
else:
|
||||
if self.config["debug"]:
|
||||
print(f"Configuration {data['setting_name']} set to {data['setting_value']}")
|
||||
|
BIN
images/default_model.png
Normal file
BIN
images/default_model.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 245 KiB |
107
web/dist/assets/index-39127af6.js
vendored
107
web/dist/assets/index-39127af6.js
vendored
File diff suppressed because one or more lines are too long
1
web/dist/assets/index-952f715f.css
vendored
1
web/dist/assets/index-952f715f.css
vendored
File diff suppressed because one or more lines are too long
125
web/dist/assets/index-d3ac3109.js
vendored
Normal file
125
web/dist/assets/index-d3ac3109.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
web/dist/assets/index-f4372a0b.css
vendored
Normal file
8
web/dist/assets/index-f4372a0b.css
vendored
Normal file
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 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LoLLMS WebUI - Welcome</title>
|
||||
<script type="module" crossorigin src="/assets/index-39127af6.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-952f715f.css">
|
||||
<script type="module" crossorigin src="/assets/index-d3ac3109.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-f4372a0b.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
21
web/package-lock.json
generated
21
web/package-lock.json
generated
@ -14,8 +14,10 @@
|
||||
"flowbite-vue": "^0.0.10",
|
||||
"highlight.js": "^11.8.0",
|
||||
"markdown-it": "^13.0.1",
|
||||
"markdown-it-attrs": "^4.1.6",
|
||||
"markdown-it-emoji": "^2.0.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"prismjs": "^1.29.0",
|
||||
"socket.io-client": "^4.6.1",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.1.6",
|
||||
@ -2142,6 +2144,17 @@
|
||||
"markdown-it": "bin/markdown-it.js"
|
||||
}
|
||||
},
|
||||
"node_modules/markdown-it-attrs": {
|
||||
"version": "4.1.6",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.1.6.tgz",
|
||||
"integrity": "sha512-O7PDKZlN8RFMyDX13JnctQompwrrILuz2y43pW2GagcwpIIElkAdfeek+erHfxUOlXWPsjFeWmZ8ch1xtRLWpA==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"markdown-it": ">= 9.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/markdown-it-emoji": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it-emoji/-/markdown-it-emoji-2.0.2.tgz",
|
||||
@ -2594,6 +2607,14 @@
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.29.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
|
||||
"integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
|
@ -16,8 +16,10 @@
|
||||
"flowbite-vue": "^0.0.10",
|
||||
"highlight.js": "^11.8.0",
|
||||
"markdown-it": "^13.0.1",
|
||||
"markdown-it-attrs": "^4.1.6",
|
||||
"markdown-it-emoji": "^2.0.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"prismjs": "^1.29.0",
|
||||
"socket.io-client": "^4.6.1",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.1.6",
|
||||
|
@ -1,19 +1,24 @@
|
||||
<template>
|
||||
<div class=" break-all ">
|
||||
<div class="break-all">
|
||||
<div v-html="renderedMarkdown" class=""></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { nextTick } from 'vue'
|
||||
import feather from 'feather-icons'
|
||||
import { nextTick } from 'vue';
|
||||
import feather from 'feather-icons';
|
||||
import MarkdownIt from 'markdown-it';
|
||||
import emoji from 'markdown-it-emoji';
|
||||
//import 'highlight.js/styles/tomorrow-night-blue.css'
|
||||
//import 'highlight.js/styles/tokyo-night-dark.css'
|
||||
import hljs from 'highlight.js';
|
||||
|
||||
import hljs from 'highlight.js/lib/core';
|
||||
import 'highlight.js/styles/tomorrow-night-blue.css';
|
||||
import 'highlight.js/styles/tokyo-night-dark.css';
|
||||
import attrs from 'markdown-it-attrs';
|
||||
|
||||
function generateUniqueId() {
|
||||
const timestamp = Date.now().toString();
|
||||
const randomSuffix = Math.floor(Math.random() * 1000).toString();
|
||||
return timestamp + randomSuffix;
|
||||
}
|
||||
|
||||
const markdownIt = new MarkdownIt('commonmark', {
|
||||
html: false,
|
||||
@ -22,92 +27,124 @@ const markdownIt = new MarkdownIt('commonmark', {
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
highlight: (str, lang) => {
|
||||
const language = hljs.highlight(str, { language: lang }).language
|
||||
|
||||
const languageCapital = language.charAt(0).toUpperCase() + language.slice(1);
|
||||
|
||||
|
||||
if (lang && hljs.getLanguage(lang)) {
|
||||
try {
|
||||
|
||||
|
||||
const highlightedCode = hljs.highlight(lang, str).value;
|
||||
return (
|
||||
'<div class="bg-bg-light-tone-panel dark:bg-bg-dark-tone-panel p-2 rounded-lg shadow-sm ">' +
|
||||
languageCapital +
|
||||
|
||||
'<pre class=" hljs p-1 rounded-md break-all grid grid-cols-1 ">' +
|
||||
|
||||
'<code class="overflow-x-auto break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary ">' +
|
||||
hljs.highlightAuto(str).value +
|
||||
'</code></pre>' + '</div>'
|
||||
'<div class="bg-bg-light-tone-panel dark:bg-bg-dark-tone-panel p-2 rounded-lg shadow-sm">' +
|
||||
lang +
|
||||
'<button class="px-2 py-1 ml-10 mb-2 text-left p-2 text-sm font-medium bg-bg-dark-tone-panel dark:bg-bg-dark-tone rounded-lg hover:bg-primary dark:hover:bg-primary text-white text-xs transition-colors duration-200">' +
|
||||
'<span class="mr-1" id="copy-btn" onclick="copyContentToClipboard(' +
|
||||
id +
|
||||
')">Copy</span>' +
|
||||
'<span class="hidden text-xs text-green-500" id="copyed-btn_' +
|
||||
id +
|
||||
'" onclick="copyContentToClipboard(' +
|
||||
id +
|
||||
')">Copied!</span>' +
|
||||
'</button>' +
|
||||
'<pre class="hljs p-1 rounded-md break-all grid grid-cols-1">' +
|
||||
'<code id="code_' +
|
||||
id +
|
||||
'" class="overflow-x-auto break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
||||
highlightedCode +
|
||||
'</code>' +
|
||||
'</pre>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
} catch (__) { }
|
||||
} catch (error) {
|
||||
console.error(`Syntax highlighting failed for language '${lang}':`, error);
|
||||
}
|
||||
|
||||
return (
|
||||
'<div class="bg-bg-light-tone-panel dark:bg-bg-dark-tone-panel p-2 rounded-lg shadow-sm ">' +
|
||||
languageCapital +
|
||||
|
||||
'<pre class=" hljs p-1 rounded-md break-all grid grid-cols-1 ">' +
|
||||
|
||||
'<code class="overflow-x-auto break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary ">' +
|
||||
}
|
||||
let id = generateUniqueId();
|
||||
let codeString =
|
||||
'<div class="bg-bg-light-tone-panel dark:bg-bg-dark-tone-panel p-2 rounded-lg shadow-sm">' +
|
||||
lang +
|
||||
'<button class="px-2 py-1 ml-10 mb-2 text-left p-2 text-sm font-medium bg-bg-dark-tone-panel dark:bg-bg-dark-tone rounded-lg hover:bg-primary dark:hover:bg-primary text-white text-xs transition-colors duration-200">' +
|
||||
'<span class="mr-1" id="copy-btn_' +
|
||||
id +
|
||||
'" onclick="copyContentToClipboard(' +
|
||||
id +
|
||||
')">Copy</span>' +
|
||||
'<span class="hidden text-xs text-green-500" id="copyed-btn_' +
|
||||
id +
|
||||
'" onclick="copyContentToClipboard(' +
|
||||
id +
|
||||
')">Copied!</span>' +
|
||||
'</button>' +
|
||||
'<pre class="hljs p-1 rounded-md break-all grid grid-cols-1">' +
|
||||
'<code id="code_' +
|
||||
id +
|
||||
'" class="overflow-x-auto break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
||||
markdownIt.utils.escapeHtml(str) +
|
||||
'</code></pre>' + '</div>'
|
||||
);
|
||||
|
||||
}
|
||||
}).use(emoji);
|
||||
'</code>' +
|
||||
'</pre>' +
|
||||
'</div>';
|
||||
return codeString;
|
||||
},
|
||||
}).use(emoji).use(attrs); // Add attrs plugin for adding attributes to elements
|
||||
|
||||
export default {
|
||||
name: 'MarkdownRenderer',
|
||||
props: {
|
||||
markdownText: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
renderedMarkdown: '',
|
||||
|
||||
isCopied: false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
||||
mounted() {
|
||||
const script = document.createElement('script');
|
||||
script.textContent = `
|
||||
// Your inline script code here
|
||||
console.log('Inline script executed!');
|
||||
|
||||
function copyContentToClipboard(id) {
|
||||
console.log("copied");
|
||||
const codeElement = document.getElementById('code_' + id);
|
||||
const copybtnElement = document.getElementById('copy-btn_' + id);
|
||||
const copyedbtnElement = document.getElementById('copyed-btn_' + id);
|
||||
copybtnElement.classList.add('hidden');
|
||||
copyedbtnElement.classList.remove('hidden');
|
||||
const range = document.createRange();
|
||||
range.selectNode(codeElement);
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
document.execCommand('copy');
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
this.isCopied = true;
|
||||
|
||||
setTimeout(() => {
|
||||
this.isCopied = false;
|
||||
}, 1500);
|
||||
}
|
||||
`;
|
||||
script.async = true; // Set to true if the script should be loaded asynchronously
|
||||
document.body.appendChild(script);
|
||||
this.renderedMarkdown = markdownIt.render(this.markdownText);
|
||||
nextTick(() => {
|
||||
feather.replace()
|
||||
|
||||
})
|
||||
},
|
||||
created() {
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
copyContentToClipboard() {
|
||||
|
||||
navigator.clipboard.writeText(theCode);
|
||||
},
|
||||
|
||||
feather.replace();
|
||||
});
|
||||
},
|
||||
methods: {},
|
||||
watch: {
|
||||
markdownText(newText) {
|
||||
|
||||
this.renderedMarkdown = markdownIt.render(newText);
|
||||
nextTick(() => {
|
||||
feather.replace()
|
||||
|
||||
})
|
||||
feather.replace();
|
||||
});
|
||||
},
|
||||
|
||||
},
|
||||
computed: {
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style type='text/css'></style>
|
||||
<style>
|
||||
/* Include any additional styles you need */
|
||||
</style>
|
||||
|
@ -377,8 +377,8 @@ export default {
|
||||
|
||||
async stop_gen() {
|
||||
try {
|
||||
socket.emit('cancel_generation', {});
|
||||
const res = await axios.get('/stop_gen')
|
||||
socket.emit('cancel_generation');
|
||||
//const res = await axios.get('/stop_gen')
|
||||
|
||||
if (res) {
|
||||
return res.data
|
||||
|
Loading…
Reference in New Issue
Block a user