Added serving personality assets

This commit is contained in:
saloui 2023-05-05 15:01:38 +02:00
parent af53cf395a
commit f7ff5a777d

9
app.py
View File

@ -99,6 +99,8 @@ class Gpt4AllWebUI(GPT4AllAPI):
self.add_endpoint("/", "", self.index, methods=["GET"])
self.add_endpoint("/<path:filename>", "serve_static", self.serve_static, methods=["GET"])
self.add_endpoint("/personalities/<path:filename>", "serve_personalities", self.serve_personalities, methods=["GET"])
self.add_endpoint("/export_discussion", "export_discussion", self.export_discussion, methods=["GET"])
self.add_endpoint("/export", "export", self.export, methods=["GET"])
@ -368,6 +370,13 @@ class Gpt4AllWebUI(GPT4AllAPI):
fn = filename.split("/")[-1]
return send_from_directory(path, fn)
def serve_personalities(self, filename):
root_dir = os.getcwd()
path = os.path.join(root_dir, 'personalities/')+"/".join(filename.split("/")[:-1])
fn = filename.split("/")[-1]
return send_from_directory(path, fn)
def format_message(self, message):
# Look for a code block within the message