mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-01-31 00:23:52 +00:00
enhanced ui
This commit is contained in:
parent
2e99b38571
commit
c69adacf68
@ -426,6 +426,7 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
@socketio.on('load_discussion')
|
@socketio.on('load_discussion')
|
||||||
def load_discussion(data):
|
def load_discussion(data):
|
||||||
client_id = request.sid
|
client_id = request.sid
|
||||||
|
ASCIIColors.yellow(f"Loading discussion for client {client_id}")
|
||||||
if "id" in data:
|
if "id" in data:
|
||||||
discussion_id = data["id"]
|
discussion_id = data["id"]
|
||||||
self.connections[client_id]["current_discussion"] = Discussion(discussion_id, self.db)
|
self.connections[client_id]["current_discussion"] = Discussion(discussion_id, self.db)
|
||||||
@ -533,7 +534,7 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
parent_message_id=self.message_id
|
parent_message_id=self.message_id
|
||||||
)
|
)
|
||||||
|
|
||||||
ASCIIColors.green("Starting message generation by"+self.personality.name)
|
ASCIIColors.green("Starting message generation by "+self.personality.name)
|
||||||
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message.id, client_id))
|
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message.id, client_id))
|
||||||
self.connections[client_id]['generation_thread'].start()
|
self.connections[client_id]['generation_thread'].start()
|
||||||
|
|
||||||
@ -548,10 +549,14 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
def generate_msg_from(data):
|
def generate_msg_from(data):
|
||||||
client_id = request.sid
|
client_id = request.sid
|
||||||
if self.connections[client_id]["current_discussion"] is None:
|
if self.connections[client_id]["current_discussion"] is None:
|
||||||
self.notify("Please select a discussion", False, client_id)
|
ASCIIColors.warning("Please select a discussion")
|
||||||
|
self.notify("Please select a discussion first", False, client_id)
|
||||||
return
|
return
|
||||||
id_ = data['id']
|
id_ = data['id']
|
||||||
message = self.connections[client_id]["current_discussion"].select_message(id_)
|
if id_==-1:
|
||||||
|
message = self.connections[client_id]["current_discussion"].current_message
|
||||||
|
else:
|
||||||
|
message = self.connections[client_id]["current_discussion"].select_message(id_)
|
||||||
if message is None:
|
if message is None:
|
||||||
return
|
return
|
||||||
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message.id, client_id))
|
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message.id, client_id))
|
||||||
@ -567,10 +572,14 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
def handle_connection(data):
|
def handle_connection(data):
|
||||||
client_id = request.sid
|
client_id = request.sid
|
||||||
if self.connections[client_id]["current_discussion"] is None:
|
if self.connections[client_id]["current_discussion"] is None:
|
||||||
|
ASCIIColors.yellow("Please select a discussion")
|
||||||
self.notify("Please select a discussion", False, client_id)
|
self.notify("Please select a discussion", False, client_id)
|
||||||
return
|
return
|
||||||
id_ = data['id']
|
id_ = data['id']
|
||||||
message = self.connections[client_id]["current_discussion"].select_message(id_)
|
if id_==-1:
|
||||||
|
message = self.connections[client_id]["current_discussion"].current_message
|
||||||
|
else:
|
||||||
|
message = self.connections[client_id]["current_discussion"].select_message(id_)
|
||||||
|
|
||||||
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message.id, client_id, True))
|
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message.id, client_id, True))
|
||||||
self.connections[client_id]['generation_thread'].start()
|
self.connections[client_id]['generation_thread'].start()
|
||||||
@ -1014,7 +1023,7 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
# First we need to send the new message ID to the client
|
# First we need to send the new message ID to the client
|
||||||
if is_continue:
|
if is_continue:
|
||||||
self.connections[client_id]["current_discussion"].load_message(message_id)
|
self.connections[client_id]["current_discussion"].load_message(message_id)
|
||||||
self.connections[client_id]["generated_text"] = self.connections[client_id]["current_discussion"].current_message.content
|
self.connections[client_id]["generated_text"] = message.content
|
||||||
else:
|
else:
|
||||||
self.new_message(client_id, self.personality.name, "✍ please stand by ...")
|
self.new_message(client_id, self.personality.name, "✍ please stand by ...")
|
||||||
self.socketio.sleep(0.01)
|
self.socketio.sleep(0.01)
|
||||||
|
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
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
<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 - Welcome</title>
|
<title>LoLLMS WebUI - Welcome</title>
|
||||||
<script type="module" crossorigin src="/assets/index-303b1fab.js"></script>
|
<script type="module" crossorigin src="/assets/index-c75baf49.js"></script>
|
||||||
<link rel="stylesheet" href="/assets/index-1c8c1547.css">
|
<link rel="stylesheet" href="/assets/index-9c82748a.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
@ -10,12 +10,6 @@ import io from 'socket.io-client';
|
|||||||
const URL = process.env.NODE_ENV === "production" ? undefined : (import.meta.env.VITE_LOLLMS_API);
|
const URL = process.env.NODE_ENV === "production" ? undefined : (import.meta.env.VITE_LOLLMS_API);
|
||||||
const socket = new io(URL);
|
const socket = new io(URL);
|
||||||
|
|
||||||
|
|
||||||
socket.onerror = (error) => {
|
|
||||||
console.error('WebSocket error:', error);
|
|
||||||
socket.disconnect()
|
|
||||||
};
|
|
||||||
|
|
||||||
// const app = createApp(/* your root component */);
|
// const app = createApp(/* your root component */);
|
||||||
|
|
||||||
// app.config.globalProperties.$socket = socket;
|
// app.config.globalProperties.$socket = socket;
|
||||||
|
@ -855,12 +855,12 @@ export default {
|
|||||||
},
|
},
|
||||||
socketIOConnected() {
|
socketIOConnected() {
|
||||||
console.log("socketIOConnected")
|
console.log("socketIOConnected")
|
||||||
this.$store.dispatch('setIsConnected',true);
|
this.$store.state.isConnected=true;
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
socketIODisconnected() {
|
socketIODisconnected() {
|
||||||
console.log("socketIOConnected")
|
console.log("socketIOConnected")
|
||||||
this.$store.dispatch('setIsConnected',false);
|
this.$store.state.isConnected=false;
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
new_message(msgObj) {
|
new_message(msgObj) {
|
||||||
@ -908,7 +908,28 @@ export default {
|
|||||||
}*/
|
}*/
|
||||||
},
|
},
|
||||||
talk(pers){
|
talk(pers){
|
||||||
|
this.isGenerating = true;
|
||||||
|
this.setDiscussionLoading(this.currentDiscussion.id, this.isGenerating);
|
||||||
|
axios.get('/get_generation_status', {}).then((res) => {
|
||||||
|
if (res) {
|
||||||
|
//console.log(res.data.status);
|
||||||
|
if (!res.data.status) {
|
||||||
|
console.log('Generating message from ',res.data.status);
|
||||||
|
socket.emit('generate_msg_from', { id: -1 });
|
||||||
|
// Temp data
|
||||||
|
let lastmsgid =0
|
||||||
|
if(this.discussionArr.length>0){
|
||||||
|
lastmsgid= Number(this.discussionArr[this.discussionArr.length - 1].id) + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("Already generating");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log("Error: Could not get generation status", error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
sendMsg(msg) {
|
sendMsg(msg) {
|
||||||
@ -1518,6 +1539,7 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
|
this.$store.state.isConnected=false;
|
||||||
axios.get('/get_lollms_webui_version', {}).then((res) => {
|
axios.get('/get_lollms_webui_version', {}).then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
this.version = res.data.version
|
this.version = res.data.version
|
||||||
@ -1528,6 +1550,21 @@ export default {
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
feather.replace();
|
feather.replace();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.onclose = (event) => {
|
||||||
|
console.log('WebSocket connection closed:', event.code, event.reason);
|
||||||
|
this.socketIODisconnected();
|
||||||
|
};
|
||||||
|
socket.onerror = (event) => {
|
||||||
|
console.log('WebSocket connection error:', event.code, event.reason);
|
||||||
|
this.socketIODisconnected();
|
||||||
|
socket.disconnect();
|
||||||
|
};
|
||||||
|
socket.on('connected',this.socketIOConnected)
|
||||||
|
socket.on('disconnected',this.socketIODisconnected)
|
||||||
|
console.log("Added events")
|
||||||
|
|
||||||
|
|
||||||
console.log("Waiting to be ready")
|
console.log("Waiting to be ready")
|
||||||
while (this.$store.state.ready === false) {
|
while (this.$store.state.ready === false) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
|
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
|
||||||
@ -1548,19 +1585,23 @@ export default {
|
|||||||
socket.on('update_message', this.streamMessageContent)
|
socket.on('update_message', this.streamMessageContent)
|
||||||
socket.on('close_message', this.finalMsgEvent)
|
socket.on('close_message', this.finalMsgEvent)
|
||||||
|
|
||||||
|
console.log("Setting events")
|
||||||
socket.onopen = () => {
|
socket.onopen = () => {
|
||||||
console.log('WebSocket connection established.');
|
console.log('WebSocket connection established.');
|
||||||
this.socketIOConnected();
|
if (this.currentDiscussion!=null){
|
||||||
|
this.setPageTitle(item)
|
||||||
|
localStorage.setItem('selected_discussion', this.currentDiscussion.id)
|
||||||
|
this.load_discussion(item.id, ()=>{
|
||||||
|
if (this.discussionArr.length > 1) {
|
||||||
|
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
|
||||||
|
this.changeTitleUsingUserMSG(this.currentDiscussion.id, this.discussionArr[1].content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onclose = (event) => {
|
|
||||||
console.log('WebSocket connection closed:', event.code, event.reason);
|
|
||||||
this.socketIODisconnected();
|
|
||||||
};
|
|
||||||
socket.on('connected',this.socketIOConnected)
|
|
||||||
socket.on('disconnected',this.socketIODisconnected)
|
|
||||||
console.log("Added events")
|
|
||||||
|
|
||||||
this.isCreated = true
|
this.isCreated = true
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user