diff --git a/__pycache__/apicalls.cpython-310.pyc b/__pycache__/apicalls.cpython-310.pyc index 770f67a..68a56f2 100644 Binary files a/__pycache__/apicalls.cpython-310.pyc and b/__pycache__/apicalls.cpython-310.pyc differ diff --git a/__pycache__/apicalls.cpython-311.pyc b/__pycache__/apicalls.cpython-311.pyc index 9baf873..f917080 100644 Binary files a/__pycache__/apicalls.cpython-311.pyc and b/__pycache__/apicalls.cpython-311.pyc differ diff --git a/__pycache__/config.cpython-310.pyc b/__pycache__/config.cpython-310.pyc index e0f91f7..2813d4b 100644 Binary files a/__pycache__/config.cpython-310.pyc and b/__pycache__/config.cpython-310.pyc differ diff --git a/__pycache__/wsgi.cpython-311.pyc b/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000..e2ea169 Binary files /dev/null and b/__pycache__/wsgi.cpython-311.pyc differ diff --git a/application/__pycache__/__init__.cpython-310.pyc b/application/__pycache__/__init__.cpython-310.pyc index 4e5e0f0..df3ed9e 100644 Binary files a/application/__pycache__/__init__.cpython-310.pyc and b/application/__pycache__/__init__.cpython-310.pyc differ diff --git a/application/__pycache__/__init__.cpython-311.pyc b/application/__pycache__/__init__.cpython-311.pyc index ae68705..781aa63 100644 Binary files a/application/__pycache__/__init__.cpython-311.pyc and b/application/__pycache__/__init__.cpython-311.pyc differ diff --git a/application/__pycache__/routes.cpython-310.pyc b/application/__pycache__/routes.cpython-310.pyc index 1088fbd..a6cecb2 100644 Binary files a/application/__pycache__/routes.cpython-310.pyc and b/application/__pycache__/routes.cpython-310.pyc differ diff --git a/application/__pycache__/wsgi.cpython-311.pyc b/application/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000..e544db9 Binary files /dev/null and b/application/__pycache__/wsgi.cpython-311.pyc differ diff --git a/application/routes.py b/application/routes.py index 50aa3a2..042082a 100644 --- a/application/routes.py +++ b/application/routes.py @@ -14,14 +14,17 @@ from gpt4all import GPT4All from datetime import datetime, timezone, timedelta from pathlib import Path from application import app +from werkzeug.middleware.profiler import ProfilerMiddleware + +app.wsgi_app = ProfilerMiddleware(app.wsgi_app, profile_dir="/root/flask-profiler/") app.config.update(SECRET_KEY=os.urandom(24)) app.permanent_session_lifetime = timedelta(minutes=30) MODEL = GPT4All( model_name="gpt4all-falcon-q4_0.gguf", - model_path=(Path.home() / ".cache" / "gpt4all"), - allow_download=True, +# model_path=(Path.home() / ".cache" / "gpt4all"), + allow_download=False, ) TIME_SIGNATURES = ["2/4", "3/4", "4/4", "2/2", "6/8", "9/8", "12/8"] @@ -45,6 +48,7 @@ def main_prompt(): @app.route("/all", methods=["GET", "POST"]) def prompt_all(): + print("Running Prompt_all func") WORD_PROMPT = str(requests.get("https://random-word-api.herokuapp.com/word").text)[ 2:-2 ] @@ -55,10 +59,12 @@ def prompt_all(): session["output_key"] = random.choice(KEYS) + random.choice(SIGN) session["output_signature"] = random.choice(TIME_SIGNATURES) session["word_prompt"] = WORD_PROMPT - with MODEL.chat_session(SYSTEM_TEMPLATE, PROMPT_TEMPLATE): - response = MODEL.generate(f"A single sentence about {WORD_PROMPT}.", temp=0.7) - session["output_theme"] = str(response.splitlines()[0]) + # with MODEL.chat_session(SYSTEM_TEMPLATE, PROMPT_TEMPLATE): + # response = MODEL.generate(f"A single sentence about {WORD_PROMPT}.", temp=0.7) + # session["output_theme"] = str(response.splitlines()[0]) + response = MODEL.generate(f"Tell me about {WORD_PROMPT}.", temp=0.7, callback=stop_on_token_callback) + session["output_theme"] = response # numresp = len(response)- 1 # if numresp <= 1: @@ -68,6 +74,11 @@ def prompt_all(): return render_template("single-button.html", title="Results", message=message) return render_template("single-button.html", title="Single Option") +def stop_on_token_callback(token_id, token_string): + if '.' in token_string: + return False + else: + return True @app.route("/") def prompt_instrument(): diff --git a/application/static/loading-vector.gif b/application/static/loading-vector.gif new file mode 100644 index 0000000..091a542 Binary files /dev/null and b/application/static/loading-vector.gif differ diff --git a/application/static/styles.css b/application/static/styles.css index c2c8a77..7cb6be1 100644 --- a/application/static/styles.css +++ b/application/static/styles.css @@ -174,3 +174,7 @@ header { line-height: 40px; } } + +.loading { + url('data:image/svg+xml,') +} diff --git a/application/static/tube-spinner.svg b/application/static/tube-spinner.svg new file mode 100644 index 0000000..e155f11 --- /dev/null +++ b/application/static/tube-spinner.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/application/templates/head.html b/application/templates/head.html index 0b8b57c..dc0b1e1 100644 --- a/application/templates/head.html +++ b/application/templates/head.html @@ -12,6 +12,7 @@ +
{% block content %} {% endblock %} diff --git a/application/templates/modal_results.html b/application/templates/modal_results.html index 4fdc1b5..daed44a 100644 --- a/application/templates/modal_results.html +++ b/application/templates/modal_results.html @@ -28,3 +28,9 @@ + diff --git a/application/templates/single-button.html b/application/templates/single-button.html index 16ad1c6..7f5c055 100644 --- a/application/templates/single-button.html +++ b/application/templates/single-button.html @@ -13,8 +13,13 @@ action="{{ url_for("prompt_all")}}" method="post"> + id="fields" type="submit" value="Click for Inspiration" + onclick="$('#loading').show();"> + diff --git a/gpt4all_tst.py b/gpt4all_tst.py index 4581222..5dd99e8 100644 --- a/gpt4all_tst.py +++ b/gpt4all_tst.py @@ -4,7 +4,8 @@ from pathlib import Path MODEL = GPT4All( model_name="gpt4all-falcon-q4_0.gguf", - model_path=(Path.home() / ".cache" / "gpt4all"), +# model_path=(Path.home() / ".cache" / "gpt4all"), +# /root/.pyenv/versions/gpt-song-prompt/lib/python3.10/site-packages/gpt4all allow_download=True, ) WORD_PROMPT = str(requests.get("https://random-word-api.herokuapp.com/word").text)[2:-2]