Initial commit with the basic bones of the app and webpage up. Need to fill in the functions and routing next.

This commit is contained in:
Norm Rasmussen
2023-11-27 17:11:56 -05:00
commit 10eb273b87
18 changed files with 271 additions and 0 deletions

1
.flaskenv Normal file
View File

@ -0,0 +1 @@
FLASK_APP=apicalls.py

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
apicalls.py Normal file
View File

@ -0,0 +1 @@
from application import app

7
application/__init__.py Normal file
View File

@ -0,0 +1,7 @@
from flask import Flask
from config import Config
app = Flask(__name__)
app.config.from_object(Config)
import application.routes

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

67
application/routes.py Normal file
View File

@ -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)

View File

@ -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;
}

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="shortcut icon" href="{{ url_for('static', filename='np-favicon.png') }}">
<title>Song Writing Prompt Machine</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename="styles.css") }}" />
</head>
<body>
{% block content %} {% endblock %}
</body>
</html>

View File

@ -0,0 +1,3 @@
<!DOCTYPE html>
<header class="header">
</header>

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
{% include 'head.html' %}
{% include 'header.html' %}
{% block content %}
<div class="main-container">
<h1> Get Inspired with a Song Writing Prompt! </h1>
<h3> Please select from below </h3>
<h2> {{ session.list_response }} </strong></h4>
<div class="prompt-questions">
<form class="prompt"
action="{{ url_for("prompt_influence")}}"
method="post">
<input id="fields" type="keywords" name="keyword-influence">
<input class="prompt-button"
id="fields" type="submit" value="Submit Prompt Only">
</form>
<form class="prompt"
action="{{ url_for("prompt_key")}}"
method="post">
<input class="prompt-button"
id="fields" type="submit" value="Submit Prompt Key Only">
</form>
<form class="prompt"
action="{{ url_for("prompt_timesig")}}"
method="post">
<input class="prompt-button"
id="fields" type="submit" value="Submit Prompt Time Signature Only">
</form>
<form class="prompt"
action="{{ url_for("prompt_instrument")}}"
method="post">
<input class="prompt-button"
id="fields" type="submit" value="Submit Prompt instrument Only">
</form>
<form class="prompt"
action="{{ url_for("prompt_all")}}"
method="post">
<input class="prompt-button"
id="fields" type="submit" value="Submit Prompt all Only">
</form>
</div>
</div>
{% endblock %}

4
config.py Normal file
View File

@ -0,0 +1,4 @@
import os
class Config(object):
SECRET_KEY = os.environ.get("SONGPROMPT") or "song-prompt"

59
requirements.txt Normal file
View File

@ -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