pyllamacpp version 2.1.1

This commit is contained in:
saloui 2023-05-02 14:16:10 +02:00
parent 221f270763
commit 42da16a0ca
8 changed files with 79 additions and 76 deletions

5
.gitignore vendored
View File

@ -158,3 +158,8 @@ databases/*
# extensions
extensions/
!extensions/.keep
# backends
backends/
!backends/llama_cpp
!backends/__init__.py

1
app.py
View File

@ -337,6 +337,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
print()
print("## Done ##")
print()
self.cancel_gen = False
return ""

View File

@ -30,19 +30,19 @@ personality_description: |
# The conditionning instructions sent to eh model at the start of the discussion
personality_conditioning: |
##Instructions:GPT4All is a smart and helpful Assistant built by Nomic-AI. It can discuss with humans and assist them.
##Instructions:\nGPT4All is a smart and helpful Assistant built by Nomic-AI. It can discuss with humans and assist them.
#Welcome message to be sent to the user when a new discussion is started
welcome_message: "Welcome! I am GPT4All A free and open assistant. What can I do for you today?"
# This prefix is added at the beginning of any message input by the user
user_message_prefix: "##Human:"
user_message_prefix: "##Human:\n"
# A text to put between user and chatbot messages
link_text: "\n"
# This prefix is added at the beginning of any message output by the ai
ai_message_prefix: "##Assistant:"
ai_message_prefix: "##Assistant:\n"
# Here is the list of extensions this personality requires
dependencies: []

View File

@ -181,6 +181,7 @@ class GPT4AllAPI():
self.socketio.emit('message', {'data': self.bot_says});
if self.cancel_gen:
print("Generation canceled")
self.cancel_gen = False
return False
else:
return True

View File

@ -90,9 +90,7 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) {
globals.user_msg = undefined
// scroll to bottom of chat window
chatWindow.scrollTop = chatWindow.scrollHeight;
send_message('generate_msg_from',{prompt: message, id: messageElement.id})
entry_counter = 0;
send_message('generate_msg_from',{prompt: message, id: messageElement.id})
});

View File

@ -1,71 +1,3 @@
var globals={
is_generating:false,
chatWindow:undefined,
chatForm:undefined,
userInput:undefined,
stopGeneration:undefined,
sendbtn:undefined,
waitAnimation:undefined
}
function send_message(service_name, parameters){
var socket = io.connect('http://' + document.domain + ':' + location.port);
globals.socket = socket
globals.is_generating = false
socket.on('connect', function() {
entry_counter = 0;
if(globals.is_generating){
globals.socket.disconnect()
}
else{
globals.socket.emit(service_name, parameters);
globals.is_generating = true
}
});
socket.on('disconnect', function() {
console.log("disconnected")
entry_counter = 0;
console.log("Disconnected")
globals.sendbtn.style.display="block";
globals.waitAnimation.style.display="none";
globals.stopGeneration.style.display = "none";
});
socket.on('infos', function(msg) {
if(globals.user_msg){
globals.user_msg.setSender(msg.user);
globals.user_msg.setMessage(msg.message);
globals.user_msg.setID(msg.id);
}
globals.bot_msg.setSender(msg.bot);
globals.bot_msg.setID(msg.response_id);
globals.bot_msg.messageTextElement.innerHTML = `Generating answer. Please stand by...`;
});
socket.on('waiter', function(msg) {
globals.bot_msg.messageTextElement.innerHTML = `Generating answer. Please stand by...`;
});
socket.on('message', function(msg) {
text = msg.data;
// For the other enrtries, these are just the text of the chatbot
globals.bot_msg.messageTextElement.innerHTML = marked.marked(text);
// scroll to bottom of chat window
globals.chatWindow.scrollTop = globals.chatWindow.scrollHeight;
});
socket.on('final',function(msg){
text = msg.data;
globals.bot_msg.hiddenElement.innerHTML = text
globals.bot_msg.messageTextElement.innerHTML = marked.marked(text)
socket.disconnect()
});
}
function update_main(){
globals.chatWindow = document.getElementById('chat-window');
globals.chatForm = document.getElementById('chat-form');
@ -81,7 +13,7 @@ function update_main(){
.then(response => response.json())
.then(data => {
console.log(data);
socket.disconnect()
globals.is_generating = true
});
})
@ -103,7 +35,6 @@ function update_main(){
// scroll to bottom of chat window
globals.chatWindow.scrollTop = globals.chatWindow.scrollHeight;
entry_counter = 0;
send_message('generate_msg',{prompt: message})

66
static/js/websocket.js Normal file
View File

@ -0,0 +1,66 @@
// Project : GPT4ALL-ui
// Author : ParisNeo
// Description :
// All websocket stuff can be found here.
var globals={
is_generating:false,
chatWindow:undefined,
chatForm:undefined,
userInput:undefined,
stopGeneration:undefined,
sendbtn:undefined,
waitAnimation:undefined
}
var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('connect', function() {
});
socket.on('disconnect', function() {
console.log("Disconnected")
});
socket.on('infos', function(msg) {
if(globals.user_msg){
globals.user_msg.setSender(msg.user);
globals.user_msg.setMessage(msg.message);
globals.user_msg.setID(msg.id);
}
globals.bot_msg.setSender(msg.bot);
globals.bot_msg.setID(msg.response_id);
globals.bot_msg.messageTextElement.innerHTML = `Generating answer. Please stand by...`;
});
socket.on('waiter', function(msg) {
globals.bot_msg.messageTextElement.innerHTML = `Generating answer. Please stand by...`;
});
socket.on('message', function(msg) {
text = msg.data;
// For the other enrtries, these are just the text of the chatbot
globals.bot_msg.messageTextElement.innerHTML = marked.marked(text);
// scroll to bottom of chat window
globals.chatWindow.scrollTop = globals.chatWindow.scrollHeight;
});
socket.on('final',function(msg){
text = msg.data;
globals.bot_msg.hiddenElement.innerHTML = text
globals.bot_msg.messageTextElement.innerHTML = marked.marked(text)
globals.sendbtn.style.display="block";
globals.waitAnimation.style.display="none";
globals.stopGeneration.style.display = "none";
globals.is_generating = false
});
globals.socket = socket
globals.is_generating = false
function send_message(service_name, parameters){
if(!globals.is_generating){
globals.socket.emit(service_name, parameters);
globals.is_generating = true
}
}

View File

@ -56,6 +56,7 @@
<footer class="border-t border-accent flex">
</footer>
<script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
<script src="{{ url_for('static', filename='js/websocket.js') }}"></script>
<script src="{{ url_for('static', filename='js/chat.js') }}"></script>
<script src="{{ url_for('static', filename='js/marked.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/discussions.js') }}"></script>