commit 10eb273b87fca230ffe168e54078566a03f44dfd Author: Norm Rasmussen Date: Mon Nov 27 17:11:56 2023 -0500 Initial commit with the basic bones of the app and webpage up. Need to fill in the functions and routing next. diff --git a/.flaskenv b/.flaskenv new file mode 100644 index 0000000..5630929 --- /dev/null +++ b/.flaskenv @@ -0,0 +1 @@ +FLASK_APP=apicalls.py diff --git a/__pycache__/apicalls.cpython-310.pyc b/__pycache__/apicalls.cpython-310.pyc new file mode 100644 index 0000000..2ef8c5b Binary files /dev/null and b/__pycache__/apicalls.cpython-310.pyc differ diff --git a/__pycache__/config.cpython-310.pyc b/__pycache__/config.cpython-310.pyc new file mode 100644 index 0000000..ffd1d48 Binary files /dev/null and b/__pycache__/config.cpython-310.pyc differ diff --git a/__pycache__/config.cpython-311.pyc b/__pycache__/config.cpython-311.pyc new file mode 100644 index 0000000..5b517fc Binary files /dev/null and b/__pycache__/config.cpython-311.pyc differ diff --git a/apicalls.py b/apicalls.py new file mode 100644 index 0000000..abba327 --- /dev/null +++ b/apicalls.py @@ -0,0 +1 @@ +from application import app diff --git a/application/__init__.py b/application/__init__.py new file mode 100644 index 0000000..36df6ff --- /dev/null +++ b/application/__init__.py @@ -0,0 +1,7 @@ +from flask import Flask +from config import Config + +app = Flask(__name__) +app.config.from_object(Config) + +import application.routes diff --git a/application/__pycache__/__init__.cpython-310.pyc b/application/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..37c43bb Binary files /dev/null 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 new file mode 100644 index 0000000..85e8119 Binary files /dev/null and b/application/__pycache__/__init__.cpython-311.pyc differ diff --git a/application/__pycache__/apicalls.cpython-311.pyc b/application/__pycache__/apicalls.cpython-311.pyc new file mode 100644 index 0000000..00cea2c Binary files /dev/null and b/application/__pycache__/apicalls.cpython-311.pyc differ diff --git a/application/__pycache__/routes.cpython-310.pyc b/application/__pycache__/routes.cpython-310.pyc new file mode 100644 index 0000000..ea6d952 Binary files /dev/null and b/application/__pycache__/routes.cpython-310.pyc differ diff --git a/application/__pycache__/routes.cpython-311.pyc b/application/__pycache__/routes.cpython-311.pyc new file mode 100644 index 0000000..02ffc15 Binary files /dev/null and b/application/__pycache__/routes.cpython-311.pyc differ diff --git a/application/routes.py b/application/routes.py new file mode 100644 index 0000000..0c07e61 --- /dev/null +++ b/application/routes.py @@ -0,0 +1,67 @@ +""" +Flask app that uses gpt4all to generate random song writing prompt. +""" +import os +import string +import random +from flask import ( + render_template, + session, +) +from gpt4all import GPT4All +from datetime import datetime, timezone, timedelta +from pathlib import Path +from application import app + +app.config.update(SECRET_KEY=os.urandom(24)) +app.permanent_session_lifetime = timedelta(minutes=30) + +MODEL = GPT4All( + model_name="orca-mini-3b-gguf2-q4_0.gguf", + 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"] + +# Need to decide between manually entering this list or using ascii_letters, below +KEYS = ["A", "B", "C", "D", "E", "F", "G"] +SIGN = ["b", "#"] +# Option 2 +MINOR = string.ascii_letters[0:7] +MAJOR = string.ascii_letters[26:33] +# and then use this: +# output = random.choice(KEYS)+random.choice(SIGN) + + +@app.route("/") +def main_prompt(): + """ + Main function that loads the prompt + """ + return render_template("index.html", title="Home") + +@app.route("/") +def prompt_instrument(): + pass + +@app.route("/") +def prompt_key(): + pass + +@app.route("/") +def prompt_timesig(): + pass + +@app.route("/") +def prompt_all(): + pass + +@app.route("/") +def prompt_influence(): + pass + response = MODEL.generate("The writing prompt is about the weather:", temp=0) + session["list_response"] = response.splitlines() + + +if __name__ == "__main__": + app.run(debug=True) diff --git a/application/static/styles.css b/application/static/styles.css new file mode 100644 index 0000000..5f659b6 --- /dev/null +++ b/application/static/styles.css @@ -0,0 +1,66 @@ +/* 1.0 - Foundational Styling */ + +:root { + --primary: #66C92D; + --text-light: #FFFFFF; + --text-dark: #101314; + --background: #667E8A; + --background-light: #E5E9EB; + height: 100%; +} + +*, +*::before, +*::after { + margin: 0; + padding: 0; + box-sizing: inherit; +} + +body { + background: linear-gradient( + 15deg, #ff97c0, #ffa964, #ffff8e, #00ffc8, #d26aff + ); + background-size: 700% 550%; + animation: gradient 7s ease-in-out infinite; + color: var(--text-dark); + font-family: 'Space Grotesk', sans-serif; + background-color: var(--background-light); + box-sizing: border-box; + text-align: center; + width: 100%; +} + +@keyframes gradient { + 0% { + background-position: 0% 79%; + } + 50% { + background-position: 100% 22%; + } + 100% { + background-position: 0% 79%; + } +} + +html { + display: flex; + justify-content: center; +} + +.prompt-button { + background-color: rgba(255, 255, 255, 0.5); + border-radius: 4px; + margin-right: 4px; + border: 1px solid black; + white-space: nowrap; + cursor: pointer; + font-size: 14px; + line-height: 16px; + padding: 8px 16px 8px 12px; + width: 300px +} + +.prompt { + padding: 5px; +} diff --git a/application/templates/head.html b/application/templates/head.html new file mode 100644 index 0000000..0b8b57c --- /dev/null +++ b/application/templates/head.html @@ -0,0 +1,19 @@ + + + + + + + + + Song Writing Prompt Machine + + + + + + +{% block content %} {% endblock %} + + diff --git a/application/templates/header.html b/application/templates/header.html new file mode 100644 index 0000000..20dc1ef --- /dev/null +++ b/application/templates/header.html @@ -0,0 +1,3 @@ + +
+
diff --git a/application/templates/index.html b/application/templates/index.html new file mode 100644 index 0000000..547f777 --- /dev/null +++ b/application/templates/index.html @@ -0,0 +1,44 @@ + +{% include 'head.html' %} +{% include 'header.html' %} +{% block content %} +
+

Get Inspired with a Song Writing Prompt!

+

Please select from below

+

{{ session.list_response }}

+
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +{% endblock %} diff --git a/config.py b/config.py new file mode 100644 index 0000000..86a5c75 --- /dev/null +++ b/config.py @@ -0,0 +1,4 @@ +import os + +class Config(object): + SECRET_KEY = os.environ.get("SONGPROMPT") or "song-prompt" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..084b819 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,59 @@ +async-generator==1.10 +attrs==23.1.0 +blinker==1.7.0 +cattrs==23.1.2 +certifi==2022.12.7 +charset-normalizer==3.2.0 +click==8.1.7 +coloredlogs==15.0.1 +exceptiongroup==1.1.1 +Flask==3.0.0 +gevent==23.9.1 +gitdb==4.0.10 +GitPython==3.1.31 +gpt4all==2.0.2 +greenlet==3.0.1 +h11==0.14.0 +humanfriendly==10.0 +idna==3.4 +itsdangerous==2.1.2 +Jinja2==3.1.2 +jupynium @ file:///Users/normrasmussen/.local/share/nvim/lazy/jupynium.nvim +lsprotocol==2023.0.0a3 +MarkupSafe==2.1.3 +msgpack==1.0.5 +numpy==1.26.2 +outcome==1.2.0 +packaging==23.1 +pandas==2.1.0 +persist-queue==0.8.0 +psutil==5.9.5 +pybind11==2.11.1 +pycairo @ file:///private/tmp/py3cairo-20231021-6574-xwz2b1/pycairo-1.25.1 +pygls==1.0.2 +pynvim==0.4.3 +PySocks==1.7.1 +python-dateutil==2.8.2 +python-dotenv==1.0.0 +pytz==2023.3.post1 +PyYAML @ file:///private/tmp/pyyaml-20231018-5610-1rdh755/PyYAML-6.0.1 +requests==2.31.0 +ruff==0.0.287 +ruff-lsp==0.0.38 +selenium==4.9.0 +six==1.16.0 +smmap==5.0.0 +sniffio==1.3.0 +sortedcontainers==2.4.0 +tqdm==4.66.1 +trio==0.22.0 +trio-websocket==0.10.2 +typeguard==3.0.2 +typing_extensions==4.7.1 +tzdata==2023.3 +urllib3==1.26.15 +verboselogs==1.7 +Werkzeug==3.0.1 +wsproto==1.2.0 +zope.event==5.0 +zope.interface==6.1