diff --git a/.flaskenv b/.flaskenv index 5630929..b538794 100644 --- a/.flaskenv +++ b/.flaskenv @@ -1 +1 @@ -FLASK_APP=apicalls.py +FLASK_APP=run.py diff --git a/__pycache__/apicalls.cpython-310.pyc b/__pycache__/apicalls.cpython-310.pyc index 68a56f2..076c689 100644 Binary files a/__pycache__/apicalls.cpython-310.pyc and b/__pycache__/apicalls.cpython-310.pyc differ diff --git a/__pycache__/config.cpython-310.pyc b/__pycache__/config.cpython-310.pyc index 2813d4b..3ed582d 100644 Binary files a/__pycache__/config.cpython-310.pyc and b/__pycache__/config.cpython-310.pyc differ diff --git a/__pycache__/run.cpython-310.pyc b/__pycache__/run.cpython-310.pyc new file mode 100644 index 0000000..4e7126b Binary files /dev/null and b/__pycache__/run.cpython-310.pyc differ diff --git a/application/__init__.py b/application/__init__.py index e3d8e33..6f5f887 100644 --- a/application/__init__.py +++ b/application/__init__.py @@ -2,13 +2,19 @@ from flask import Flask from config import Config from flask_sqlalchemy import SQLAlchemy from sqlalchemy.ext.declarative import declarative_base +from .utils import make_celery + +app = Flask(__name__) +# app.config.from_object(Config) +app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///words_prompts.db" +app.config["CELERY_CONFIG"] = {"broker_url": "redis://localhost"} +db = SQLAlchemy(app) + +celery = make_celery(app) +celery.set_default() Base = declarative_base() -app = Flask(__name__) -app.config.from_object(Config) -app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///words_prompts.db" -db = SQLAlchemy(app) class AllWords(Base, db.Model): word = db.Column(db.String, primary_key=True) @@ -16,6 +22,7 @@ class AllWords(Base, db.Model): def __init__(self, word): self.word = word + class Themes(Base, db.Model): themes = db.Column(db.String, primary_key=True) diff --git a/application/__pycache__/__init__.cpython-310.pyc b/application/__pycache__/__init__.cpython-310.pyc index df3ed9e..c0e3403 100644 Binary files a/application/__pycache__/__init__.cpython-310.pyc and b/application/__pycache__/__init__.cpython-310.pyc differ diff --git a/application/__pycache__/background_tasks.cpython-310.pyc b/application/__pycache__/background_tasks.cpython-310.pyc new file mode 100644 index 0000000..f7d4524 Binary files /dev/null and b/application/__pycache__/background_tasks.cpython-310.pyc differ diff --git a/application/__pycache__/routes.cpython-310.pyc b/application/__pycache__/routes.cpython-310.pyc index a6cecb2..fd41282 100644 Binary files a/application/__pycache__/routes.cpython-310.pyc and b/application/__pycache__/routes.cpython-310.pyc differ diff --git a/application/__pycache__/utils.cpython-310.pyc b/application/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000..657dcb4 Binary files /dev/null and b/application/__pycache__/utils.cpython-310.pyc differ diff --git a/application/background_tasks.py b/application/background_tasks.py new file mode 100644 index 0000000..8dbf327 --- /dev/null +++ b/application/background_tasks.py @@ -0,0 +1,83 @@ +from celery import shared_task +from redbeat import RedBeatSchedulerEntry +from celery import current_app as celery_app +from sqlalchemy.sql.expression import func, select, insert +from sqlalchemy.ext.automap import automap_base +from sqlalchemy import create_engine +from sqlalchemy.orm import Session +from gpt4all import GPT4All + +engine = create_engine("sqlite:///words_prompts.db", pool_pre_ping=True) + +Base = automap_base() +Base.prepare(engine, reflect=True) + +Words = Base.classes.words +Themes = Base.classes.themes + + +MODEL = GPT4All( + model_name="gpt4all-falcon-q4_0.gguf", + # model_path=(Path.home() / ".cache" / "gpt4all"), + allow_download=False, +) + + +@shared_task +def grab_word(): + while True: + with Session(engine) as word_session: + random_word = word_session.query(Words.words) + random_word = random_word.order_by(func.random()).first() + random_word = str(random_word)[4:-4] + # SYSTEM_TEMPLATE = "A single sentence based on a word." + # PROMPT_TEMPLATE = "### Instruction: {0} \n### Response: " + response = MODEL.generate( + f"Give me a writing prompt about {random_word}.", + temp=0.7, + callback=stop_on_token_callback, + ) + word_session.execute(insert(Themes).values(themes=response)) + word_session.commit() + + +def stop_on_token_callback(token_id, token_string): + """ + Function to limit return length of the + gpt4all response. Period indicates a sentence. + """ + if "." in token_string: + return False + return True + + +# def every(__seconds: float, func, *args, **kwargs): +# while True: +# func(*args, **kwargs) +# await asyncio.sleep(__seconds) +# +# +# def main(): +# asyncio.ensure_future(grab_word()) + + +# with app.app_context(): +# loop = asyncio.get_event_loop() +# loop.run_until_complete(grab_word()) +# loop.run_forever() + + +# async def get_theme(random_word): +# print("Get Theme function running.") +# # SYSTEM_TEMPLATE = "A single sentence based on a word." +# # PROMPT_TEMPLATE = "### Instruction: {0} \n### Response: " +# random_word = await random_word +# print(f"Theme Func, word: {random_word}") +# while True: +# response = MODEL.generate( +# f"Tell me about {random_word}.", temp=0.7, callback=stop_on_token_callback +# ) +# with Session(engine) as thm_session: +# print(f"Theme func, response: {response}") +# thm_session.add(response) +# thm_session.commit() diff --git a/application/routes.py b/application/routes.py index a160a88..2fe0cf7 100644 --- a/application/routes.py +++ b/application/routes.py @@ -3,30 +3,30 @@ Flask app that uses gpt4all to generate random song writing prompt. """ import os import string +from uuid import uuid4 import random -import asyncio from flask import ( render_template, session, request, ) -from gpt4all import GPT4All -from datetime import timedelta +from redbeat import RedBeatSchedulerEntry from application import app - -# , AllWords, Themes -from sqlalchemy.sql.expression import func, select +from sqlalchemy.sql.expression import func from sqlalchemy.ext.automap import automap_base from sqlalchemy.orm import Session from sqlalchemy import create_engine +from celery import current_app as celery_app +# from celery.schedules import schedule -# from werkzeug.middleware.profiler import ProfilerMiddleware +from werkzeug.middleware.profiler import ProfilerMiddleware -# app.wsgi_app = ProfilerMiddleware( -# app.wsgi_app, -# profile_dir="/Users/normrasmussen/Documents/Projects/gpt-song-prompt/flask-profiler/", -# ) +from .background_tasks import grab_word +app.wsgi_app = ProfilerMiddleware( + app.wsgi_app, + profile_dir="/Users/normrasmussen/Documents/Github/song-prompt-webapp/flask-profiler/", +) engine = create_engine("sqlite:///words_prompts.db", pool_pre_ping=True) Base = automap_base() @@ -36,13 +36,8 @@ Words = Base.classes.words Themes = Base.classes.themes app.config.update(SECRET_KEY=os.urandom(24)) -app.permanent_session_lifetime = timedelta(minutes=30) +# app.permanent_session_lifetime = timedelta(minutes=30) -MODEL = GPT4All( - model_name="gpt4all-falcon-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 @@ -52,82 +47,30 @@ SIGN = ["b", "#"] MINOR = string.ascii_letters[0:7] MAJOR = string.ascii_letters[26:33] -async def grab_word(): - print("Running Grab_word func") - await asyncio.sleep(1) - while True: - with Session(engine) as word_session: - random_word = word_session.query(Words.words) - random_word = random_word.order_by(func.random()).first() - random_word = str(random_word)[4:-4] - print(f"Word func, random word: {random_word}") - return random_word - -async def every(__seconds: float, func, *args, **kwargs): - while True: - func(*args, **kwargs) - await asyncio.sleep(__seconds) - - -async def main(): - asyncio.ensure_future(grab_word()) - -with app.app_context(): - loop = asyncio.get_event_loop() - loop.run_until_complete(grab_word()) - loop.run_forever() - - -async def get_theme(): - # SYSTEM_TEMPLATE = "A single sentence based on a word." - # PROMPT_TEMPLATE = "### Instruction: {0} \n### Response: " - WORD_PROMPT = await grab_word() - print(f"Theme Func, word: {WORD_PROMPT}") - while True: - response = MODEL.generate( - f"Tell me about {WORD_PROMPT}.", temp=0.7, callback=stop_on_token_callback) - with Session(engine) as thm_session: - print(f"Theme func, response: {response}") - thm_session.add(response) - thm_session.commit() - - -@app.route("/") -def main_prompt(): +@app.route("/", methods=["GET", "POST"]) +def prompt_all(): """ Main function that loads the prompt """ - return render_template("index.html", title="Home") - - -@app.route("/all", methods=["GET", "POST"]) -def prompt_all(): + schedule_id = str(uuid4()) + interval = celery_app.schedule(run_every=60) + entry = RedBeatSchedulerEntry( + schedule_id, "application.background_tasks.grab_word", interval + ) + entry.save() if request.method == "POST": message = "Results are here" session["output_key"] = random.choice(KEYS) + random.choice(SIGN) session["output_signature"] = random.choice(TIME_SIGNATURES) with Session(engine) as word_session: random_theme = word_session.query(Themes.themes) - session["output_theme"] = random_theme.order_by(func.random()).first() - - - # 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]) + theme = random_theme.order_by(func.random()).first() + session["output_theme"] = str(theme)[3:-3] 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_string): - """ - Function to limit return length of the gpt4all response. Period indicates a sentence. - """ - if "." in token_string: - return False - return True - - if __name__ == "__main__": app.run(debug=True) diff --git a/application/utils.py b/application/utils.py new file mode 100644 index 0000000..822bdd3 --- /dev/null +++ b/application/utils.py @@ -0,0 +1,13 @@ +from celery import Celery + +def make_celery(app): + celery = Celery(app.import_name) + celery.conf.update(app.config["CELERY_CONFIG"]) + + class ContextTask(celery.Task): + def __call__(self, *args, **kwargs): + with app.app_context(): + return self.run(*args, **kwargs) + + celery.Task = ContextTask + return celery diff --git a/application/dbmodels.py b/db.py similarity index 100% rename from application/dbmodels.py rename to db.py diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000..a001c4a Binary files /dev/null and b/dump.rdb differ diff --git a/flask-profiler/GET.root.32ms.1701889470.prof b/flask-profiler/GET.root.32ms.1701889470.prof new file mode 100644 index 0000000..cc9fbe4 Binary files /dev/null and b/flask-profiler/GET.root.32ms.1701889470.prof differ diff --git a/flask-profiler/GET.root.35ms.1701891183.prof b/flask-profiler/GET.root.35ms.1701891183.prof new file mode 100644 index 0000000..b4558bf Binary files /dev/null and b/flask-profiler/GET.root.35ms.1701891183.prof differ diff --git a/flask-profiler/GET.root.40ms.1701891103.prof b/flask-profiler/GET.root.40ms.1701891103.prof new file mode 100644 index 0000000..92872f3 Binary files /dev/null and b/flask-profiler/GET.root.40ms.1701891103.prof differ diff --git a/flask-profiler/GET.root.52ms.1701891150.prof b/flask-profiler/GET.root.52ms.1701891150.prof new file mode 100644 index 0000000..10335de Binary files /dev/null and b/flask-profiler/GET.root.52ms.1701891150.prof differ diff --git a/flask-profiler/GET.root.63ms.1701889603.prof b/flask-profiler/GET.root.63ms.1701889603.prof new file mode 100644 index 0000000..fc682b4 Binary files /dev/null and b/flask-profiler/GET.root.63ms.1701889603.prof differ diff --git a/flask-profiler/GET.root.65ms.1701890204.prof b/flask-profiler/GET.root.65ms.1701890204.prof new file mode 100644 index 0000000..884ebf8 Binary files /dev/null and b/flask-profiler/GET.root.65ms.1701890204.prof differ diff --git a/flask-profiler/GET.root.8ms.1701891202.prof b/flask-profiler/GET.root.8ms.1701891202.prof new file mode 100644 index 0000000..f205126 Binary files /dev/null and b/flask-profiler/GET.root.8ms.1701891202.prof differ diff --git a/flask-profiler/GET.root.90ms.1701963693.prof b/flask-profiler/GET.root.90ms.1701963693.prof new file mode 100644 index 0000000..ae6fa58 Binary files /dev/null and b/flask-profiler/GET.root.90ms.1701963693.prof differ diff --git a/flask-profiler/GET.static.styles.css.11ms.1701963696.prof b/flask-profiler/GET.static.styles.css.11ms.1701963696.prof new file mode 100644 index 0000000..fb992c2 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.11ms.1701963696.prof differ diff --git a/flask-profiler/GET.static.styles.css.13ms.1701889603.prof b/flask-profiler/GET.static.styles.css.13ms.1701889603.prof new file mode 100644 index 0000000..122b763 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.13ms.1701889603.prof differ diff --git a/flask-profiler/GET.static.styles.css.16ms.1701891103.prof b/flask-profiler/GET.static.styles.css.16ms.1701891103.prof new file mode 100644 index 0000000..891a0f3 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.16ms.1701891103.prof differ diff --git a/flask-profiler/GET.static.styles.css.1ms.1701890207.prof b/flask-profiler/GET.static.styles.css.1ms.1701890207.prof new file mode 100644 index 0000000..e801931 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.1ms.1701890207.prof differ diff --git a/flask-profiler/GET.static.styles.css.20ms.1701889470.prof b/flask-profiler/GET.static.styles.css.20ms.1701889470.prof new file mode 100644 index 0000000..0381a1a Binary files /dev/null and b/flask-profiler/GET.static.styles.css.20ms.1701889470.prof differ diff --git a/flask-profiler/GET.static.styles.css.21ms.1701963693.prof b/flask-profiler/GET.static.styles.css.21ms.1701963693.prof new file mode 100644 index 0000000..15182a0 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.21ms.1701963693.prof differ diff --git a/flask-profiler/GET.static.styles.css.25ms.1701891150.prof b/flask-profiler/GET.static.styles.css.25ms.1701891150.prof new file mode 100644 index 0000000..f611005 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.25ms.1701891150.prof differ diff --git a/flask-profiler/GET.static.styles.css.2ms.1701889475.prof b/flask-profiler/GET.static.styles.css.2ms.1701889475.prof new file mode 100644 index 0000000..96b9d55 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.2ms.1701889475.prof differ diff --git a/flask-profiler/GET.static.styles.css.2ms.1701891208.prof b/flask-profiler/GET.static.styles.css.2ms.1701891208.prof new file mode 100644 index 0000000..c44aabf Binary files /dev/null and b/flask-profiler/GET.static.styles.css.2ms.1701891208.prof differ diff --git a/flask-profiler/GET.static.styles.css.30ms.1701890204.prof b/flask-profiler/GET.static.styles.css.30ms.1701890204.prof new file mode 100644 index 0000000..e932ec4 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.30ms.1701890204.prof differ diff --git a/flask-profiler/GET.static.styles.css.34ms.1701891184.prof b/flask-profiler/GET.static.styles.css.34ms.1701891184.prof new file mode 100644 index 0000000..87d7337 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.34ms.1701891184.prof differ diff --git a/flask-profiler/GET.static.styles.css.3ms.1701891205.prof b/flask-profiler/GET.static.styles.css.3ms.1701891205.prof new file mode 100644 index 0000000..6d992bb Binary files /dev/null and b/flask-profiler/GET.static.styles.css.3ms.1701891205.prof differ diff --git a/flask-profiler/GET.static.styles.css.5ms.1701891152.prof b/flask-profiler/GET.static.styles.css.5ms.1701891152.prof new file mode 100644 index 0000000..ac14c88 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.5ms.1701891152.prof differ diff --git a/flask-profiler/GET.static.styles.css.6ms.1701891202.prof b/flask-profiler/GET.static.styles.css.6ms.1701891202.prof new file mode 100644 index 0000000..d0fca28 Binary files /dev/null and b/flask-profiler/GET.static.styles.css.6ms.1701891202.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.10ms.1701889603.prof b/flask-profiler/GET.static.tube-spinner.svg.10ms.1701889603.prof new file mode 100644 index 0000000..bfcc94d Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.10ms.1701889603.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.13ms.1701891103.prof b/flask-profiler/GET.static.tube-spinner.svg.13ms.1701891103.prof new file mode 100644 index 0000000..278466f Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.13ms.1701891103.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.16ms.1701963693.prof b/flask-profiler/GET.static.tube-spinner.svg.16ms.1701963693.prof new file mode 100644 index 0000000..e36d352 Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.16ms.1701963693.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.19ms.1701889470.prof b/flask-profiler/GET.static.tube-spinner.svg.19ms.1701889470.prof new file mode 100644 index 0000000..527a79c Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.19ms.1701889470.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.23ms.1701891184.prof b/flask-profiler/GET.static.tube-spinner.svg.23ms.1701891184.prof new file mode 100644 index 0000000..766b42b Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.23ms.1701891184.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.24ms.1701890204.prof b/flask-profiler/GET.static.tube-spinner.svg.24ms.1701890204.prof new file mode 100644 index 0000000..09354d3 Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.24ms.1701890204.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.2ms.1701889475.prof b/flask-profiler/GET.static.tube-spinner.svg.2ms.1701889475.prof new file mode 100644 index 0000000..020a71a Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.2ms.1701889475.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.2ms.1701890207.prof b/flask-profiler/GET.static.tube-spinner.svg.2ms.1701890207.prof new file mode 100644 index 0000000..9c628a0 Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.2ms.1701890207.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.2ms.1701891152.prof b/flask-profiler/GET.static.tube-spinner.svg.2ms.1701891152.prof new file mode 100644 index 0000000..8fa245b Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.2ms.1701891152.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.3ms.1701891208.prof b/flask-profiler/GET.static.tube-spinner.svg.3ms.1701891208.prof new file mode 100644 index 0000000..6245631 Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.3ms.1701891208.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.4ms.1701891202.prof b/flask-profiler/GET.static.tube-spinner.svg.4ms.1701891202.prof new file mode 100644 index 0000000..a94073e Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.4ms.1701891202.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.4ms.1701963696.prof b/flask-profiler/GET.static.tube-spinner.svg.4ms.1701963696.prof new file mode 100644 index 0000000..4d516dc Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.4ms.1701963696.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.6ms.1701891205.prof b/flask-profiler/GET.static.tube-spinner.svg.6ms.1701891205.prof new file mode 100644 index 0000000..aea5add Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.6ms.1701891205.prof differ diff --git a/flask-profiler/GET.static.tube-spinner.svg.9ms.1701891150.prof b/flask-profiler/GET.static.tube-spinner.svg.9ms.1701891150.prof new file mode 100644 index 0000000..f0008fd Binary files /dev/null and b/flask-profiler/GET.static.tube-spinner.svg.9ms.1701891150.prof differ diff --git a/flask-profiler/POST.root.24ms.1701891208.prof b/flask-profiler/POST.root.24ms.1701891208.prof new file mode 100644 index 0000000..5d3a6fb Binary files /dev/null and b/flask-profiler/POST.root.24ms.1701891208.prof differ diff --git a/flask-profiler/POST.root.27ms.1701891152.prof b/flask-profiler/POST.root.27ms.1701891152.prof new file mode 100644 index 0000000..48e7b01 Binary files /dev/null and b/flask-profiler/POST.root.27ms.1701891152.prof differ diff --git a/flask-profiler/POST.root.29ms.1701890207.prof b/flask-profiler/POST.root.29ms.1701890207.prof new file mode 100644 index 0000000..05285b8 Binary files /dev/null and b/flask-profiler/POST.root.29ms.1701890207.prof differ diff --git a/flask-profiler/POST.root.36ms.1701889475.prof b/flask-profiler/POST.root.36ms.1701889475.prof new file mode 100644 index 0000000..48ca71b Binary files /dev/null and b/flask-profiler/POST.root.36ms.1701889475.prof differ diff --git a/flask-profiler/POST.root.37ms.1701963696.prof b/flask-profiler/POST.root.37ms.1701963696.prof new file mode 100644 index 0000000..21894cd Binary files /dev/null and b/flask-profiler/POST.root.37ms.1701963696.prof differ diff --git a/flask-profiler/POST.root.43ms.1701891205.prof b/flask-profiler/POST.root.43ms.1701891205.prof new file mode 100644 index 0000000..9a8c24e Binary files /dev/null and b/flask-profiler/POST.root.43ms.1701891205.prof differ diff --git a/gpt4all_tst.py b/gpt4all_tst.py index e5163ad..dbe4495 100644 --- a/gpt4all_tst.py +++ b/gpt4all_tst.py @@ -13,14 +13,24 @@ def prompt(): WORD_PROMPT = str(requests.get("https://random-word-api.herokuapp.com/word").text)[ 2:-2 ] - SYSTEM_TEMPLATE = "A creative response about a word." - PROMPT_TEMPLATE = "### Instruction: {0} \n### Response: " + # SYSTEM_TEMPLATE = "A creative response about a word." + # PROMPT_TEMPLATE = "### Instruction: {0} \n### Response: " response = MODEL.generate( - f"Tell me something interesting about {WORD_PROMPT}.", - temp=0.7, + f"Give me a writing prompt where the writer has to write a song based on {WORD_PROMPT}.", + temp=1, callback=stop_on_token_callback, ) + response2 = MODEL.generate( + f"Give me a writing prompt about {WORD_PROMPT}.", + #"Tell me one-sentence about Jitteriest.", + temp=1, + callback=stop_on_token_callback, + ) + print("Make up a short story response:") print(response) + print("\n") + print("Tell me one-sentence story about.") + print(response2) # with MODEL.chat_session(SYSTEM_TEMPLATE, PROMPT_TEMPLATE): # response = MODEL.generate(f"A single sentence about {WORD_PROMPT}.", temp=0.7) @@ -30,8 +40,12 @@ def prompt(): def stop_on_token_callback(token_id, token_string): + # per_amt = token_string.count('.') + # while per_amt < 3: + # return True + # return False if "." in token_string: - return False + return False return True diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 0000000..d98a808 --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,4 @@ +{ + "venv" : "songprompt", + "venvPath" : "/Users/normrasmussen/.pyenv/versions" +} diff --git a/requirements.txt b/requirements.txt index 55be6b3..e7e0ebc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,23 +1,224 @@ +absl-py==1.4.0 +adafruit-nrfutil==0.5.3.post16 +aiohttp==3.8.4 +aiosignal==1.3.1 +albumentations==0.4.3 +altair==5.0.1 +amqp==5.2.0 +antlr4-python3-runtime==4.8 +anyio==3.7.0 asgiref==3.7.2 +async-timeout==4.0.2 asyncio==3.4.3 +attrs==23.1.0 +Automat==22.10.0 +beautifulsoup4==4.12.2 +billiard==4.2.0 +bitstring==4.0.2 blinker==1.7.0 +braceexpand==0.1.7 +bs4==0.0.1 +cachetools==5.3.1 +celery==5.3.6 +celery-redbeat==2.1.1 certifi==2023.11.17 +cffi==1.15.1 charset-normalizer==3.3.2 click==8.1.7 +click-didyoumean==0.3.0 +click-plugins==1.1.1 +click-repl==0.3.0 +coloredlogs==15.0.1 +constantly==15.1.0 +contourpy==1.1.0 +cryptography==41.0.1 +cssselect==1.2.0 +cycler==0.11.0 +decorator==5.1.1 +Deprecated==1.2.14 +dotmap==1.3.30 +ecdsa==0.18.0 +einops==0.3.0 +esptool==4.6.2 +exceptiongroup==1.1.1 +fastapi==0.98.0 +ffmpy==0.3.0 +filelock==3.12.2 Flask==3.0.0 Flask-SQLAlchemy==3.1.1 +flatbuffers==23.5.26 +fonttools==4.40.0 +frozenlist==1.3.3 +fsspec==2023.6.0 +ftfy==6.1.1 +future==0.18.3 +geocoder==1.38.1 gevent==23.9.1 +gitdb==4.0.10 +GitPython==3.1.31 +google-auth==2.20.0 +google-auth-oauthlib==1.0.0 gpt4all==2.0.2 +gradio==3.13.2 greenlet==3.0.1 +grpcio==1.56.0 +h11==0.14.0 +httpcore==0.17.2 +httpx==0.24.1 +huggingface-hub==0.15.1 +humanfriendly==10.0 +hyperlink==21.0.0 idna==3.6 +imageio==2.9.0 +imageio-ffmpeg==0.4.2 +imgaug==0.2.6 +importlib-metadata==6.7.0 +incremental==22.10.0 +iniconfig==2.0.0 +invisible-watermark==0.1.5 +itemadapter==0.8.0 +itemloaders==1.1.0 itsdangerous==2.1.2 Jinja2==3.1.2 +jmespath==1.0.1 +jsonschema==4.17.3 +kiwisolver==1.4.4 +kombu==5.3.4 +kornia==0.6.0 +lazy_loader==0.2 +linkify-it-py==2.0.2 +lxml==4.9.3 +Markdown==3.4.3 +markdown-it-py==3.0.0 MarkupSafe==2.1.3 +matplotlib==3.7.1 +mdit-py-plugins==0.4.0 +mdurl==0.1.2 +meshtastic==2.1.9 +mpmath==1.3.0 +multidict==6.0.4 +networkx==3.1 +numpy==1.25.0 +oauthlib==3.2.2 +omegaconf==2.1.1 +onnx==1.14.0 +onnxruntime==1.15.1 +open-clip-torch==2.7.0 +opencv-python==4.7.0.72 +opencv-python-headless==4.7.0.72 +orjson==3.9.1 +packaging==23.1 +pandas==2.0.2 +parsel==1.8.1 +pexpect==4.8.0 +Pillow==9.5.0 +playwright==1.38.0 +pluggy==1.3.0 +prompt-toolkit==3.0.41 +Protego==0.3.0 +protobuf==4.23.3 +psutil==5.9.5 +ptyprocess==0.7.0 +pudb==2019.2 +pyarrow==12.0.1 +pyasn1==0.5.0 +pyasn1-modules==0.3.0 +pycodestyle==2.11.0 +pycparser==2.21 +pycryptodome==3.18.0 +pydantic==1.10.9 +pydeck==0.8.1b0 +pyDeprecate==0.3.1 +PyDispatcher==2.0.7 +pydub==0.25.1 +pyee==9.0.4 +PyGithub==1.59.0 +Pygments==2.15.1 +PyJWT==2.7.0 +Pympler==1.0.1 +PyNaCl==1.5.0 +pyOpenSSL==23.2.0 +pyparsing==3.1.0 +Pypubsub==4.0.3 +PyQRCode==1.2.1 +pyrsistent==0.19.3 +pyserial==3.5 +PySide6==6.5.1.1 +PySide6-Addons==6.5.1.1 +PySide6-Essentials==6.5.1.1 +pytest==7.4.2 +pytest-base-url==2.0.0 +pytest-playwright==0.4.2 +python-dateutil==2.8.2 +python-dotenv==1.0.0 +python-multipart==0.0.6 +python-slugify==8.0.1 +pytorch-lightning==1.4.2 +pytz==2023.3 +pytz-deprecation-shim==0.1.0.post0 +PyWavelets==1.4.1 +PyYAML==6.0 +qt-material==2.14 +queuelib==1.6.2 +ratelim==0.1.6 +redis==5.0.1 +reedsolo==1.5.4 +regex==2023.6.3 requests==2.31.0 +requests-file==1.5.1 +requests-oauthlib==1.3.1 +rich==13.4.2 +rsa==4.9 +scikit-image==0.20.0 +scipy==1.10.1 +Scrapy==2.11.0 +service-identity==23.1.0 +shiboken6==6.5.1.1 +six==1.16.0 +smmap==5.0.0 +sniffio==1.3.0 +soupsieve==2.5 SQLAlchemy==2.0.23 +starlette==0.27.0 +streamlit==1.23.1 +streamlit-drawable-canvas==0.8.0 +sympy==1.12 +tabulate==0.9.0 +tenacity==8.2.2 +tensorboard==2.13.0 +tensorboard-data-server==0.7.1 +test-tube==0.7.5 +text-unidecode==1.3 +tifffile==2023.4.12 +timeago==1.0.16 +tldextract==3.6.0 +tokenizers==0.12.1 +toml==0.10.2 +tomli==2.0.1 +toolz==0.12.0 +torch==2.0.1 +torchmetrics==0.6.0 +torchvision==0.15.2 +tornado==6.3.2 tqdm==4.66.1 +transformers==4.19.2 +Twisted==22.10.0 typing_extensions==4.8.0 +tzdata==2023.3 +tzlocal==4.3.1 +uc-micro-py==1.0.2 urllib3==2.1.0 +urwid==2.1.2 +uvicorn==0.22.0 +validators==0.20.0 +vine==5.1.0 +w3lib==2.1.2 +wcwidth==0.2.6 +webdataset==0.2.5 +websockets==11.0.3 Werkzeug==3.0.1 +wrapt==1.15.0 +yarl==1.9.2 +zipp==3.15.0 zope.event==5.0 zope.interface==6.1 diff --git a/run.py b/run.py new file mode 100644 index 0000000..2668bbe --- /dev/null +++ b/run.py @@ -0,0 +1,2 @@ +from application import app + diff --git a/words_prompts.db b/words_prompts.db index 6d81a33..ed6e525 100644 Binary files a/words_prompts.db and b/words_prompts.db differ