mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
Fixed bug
This commit is contained in:
parent
e2cfdfd73e
commit
4c5b162a71
17
app.py
17
app.py
@ -222,6 +222,15 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
"/reset", "reset", self.reset, methods=["GET"]
|
||||
)
|
||||
|
||||
self.add_endpoint(
|
||||
"/export_multiple_discussions", "export_multiple_discussions", self.export_multiple_discussions, methods=["POST"]
|
||||
)
|
||||
|
||||
def export_multiple_discussions(self):
|
||||
data = request.get_json()
|
||||
discussion_ids = data["discussion_ids"]
|
||||
return jsonify(self.db.export_discussions_to_json(discussion_ids))
|
||||
|
||||
|
||||
def reset(self):
|
||||
os.kill(os.getpid(), signal.SIGINT) # Send the interrupt signal to the current process
|
||||
@ -677,8 +686,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
self.backend = backend_
|
||||
self.config['model'] = models[0]
|
||||
# Build chatbot
|
||||
self.process.set_config(self.config)
|
||||
return jsonify({"status": "ok"})
|
||||
return jsonify(self.process.set_config(self.config))
|
||||
else:
|
||||
return jsonify({"status": "no_models_found"})
|
||||
|
||||
@ -690,9 +698,8 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
if self.config['model']!= model:
|
||||
print("set_model: New model selected")
|
||||
self.config['model'] = model
|
||||
# Build chatbot
|
||||
self.process.set_config(self.config)
|
||||
return jsonify({"status": "ok"})
|
||||
# Build chatbot
|
||||
return jsonify(self.process.set_config(self.config))
|
||||
|
||||
return jsonify({"status": "error"})
|
||||
|
||||
|
@ -185,6 +185,7 @@ class ModelProcess:
|
||||
|
||||
def _rebuild_model(self):
|
||||
try:
|
||||
self.reset_config_result()
|
||||
print(" ******************* Building Backend from generation Process *************************")
|
||||
self.backend = self.load_backend(self.config["backend"], install=True)
|
||||
print("Backend loaded successfully")
|
||||
@ -207,6 +208,8 @@ class ModelProcess:
|
||||
print(ex)
|
||||
self.backend = None
|
||||
self.model = None
|
||||
self._set_config_result['model_status'] ='failed'
|
||||
self._set_config_result['errors'].append(f"couldn't build model:{ex}")
|
||||
|
||||
def rebuild_personality(self):
|
||||
try:
|
||||
@ -224,6 +227,7 @@ class ModelProcess:
|
||||
|
||||
def _rebuild_personality(self):
|
||||
try:
|
||||
self.reset_config_result()
|
||||
print(f" ******************* Building Personality {self.config['personality']} from generation Process *************************")
|
||||
personality_path = f"personalities/{self.config['personality_language']}/{self.config['personality_category']}/{self.config['personality']}"
|
||||
self.personality = AIPersonality(personality_path)
|
||||
|
@ -250,6 +250,30 @@ class DiscussionsDB:
|
||||
return discussions
|
||||
|
||||
|
||||
def export_discussions_to_json(self, discussions_ids:list):
|
||||
# Convert the list of discussion IDs to a tuple
|
||||
discussions_ids_tuple = tuple(discussions_ids)
|
||||
db_discussions = self.select("SELECT * FROM discussion WHERE discussion_id IN ({})".format(
|
||||
','.join(['?'] * len(discussions_ids_tuple))
|
||||
))
|
||||
discussions = []
|
||||
for row in db_discussions:
|
||||
discussion_id = row[0]
|
||||
discussion_title = row[1]
|
||||
discussion = {"id": discussion_id, "title":discussion_title, "messages": []}
|
||||
rows = self.select(f"SELECT * FROM message WHERE discussion_id=?",(discussion_id,))
|
||||
for message_row in rows:
|
||||
sender = message_row[1]
|
||||
content = message_row[2]
|
||||
content_type = message_row[3]
|
||||
rank = message_row[4]
|
||||
parent = message_row[5]
|
||||
discussion["messages"].append(
|
||||
{"sender": sender, "content": content, "type": content_type, "rank": rank, "parent": parent}
|
||||
)
|
||||
discussions.append(discussion)
|
||||
return discussions
|
||||
|
||||
class Discussion:
|
||||
def __init__(self, discussion_id, discussions_db:DiscussionsDB):
|
||||
self.discussion_id = discussion_id
|
||||
|
Loading…
Reference in New Issue
Block a user