From ecf65e993ab6882574e62d09b79f2e04a09d8e03 Mon Sep 17 00:00:00 2001 From: mike <219478+ilude@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:28:39 -0400 Subject: [PATCH] attempt to fix scheduler --- app/{ => archive}/docker_app.py | 0 app/models/scheduler.py | 17 ++++++++++------- app/processors/title_editor.py | 3 ++- app/templates/index.html | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) rename app/{ => archive}/docker_app.py (100%) diff --git a/app/docker_app.py b/app/archive/docker_app.py similarity index 100% rename from app/docker_app.py rename to app/archive/docker_app.py diff --git a/app/models/scheduler.py b/app/models/scheduler.py index c596e19..bc558aa 100644 --- a/app/models/scheduler.py +++ b/app/models/scheduler.py @@ -3,10 +3,6 @@ import logging -logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) - - class Scheduler: __scheduler = None @@ -20,13 +16,20 @@ def shutdown(): def clear_jobs(): Scheduler.getScheduler().remove_all_jobs() + @staticmethod + def start(): + Scheduler.__scheduler.start() + logging.info('Scheduler started!') + @staticmethod def getScheduler() -> BackgroundScheduler: if Scheduler.__scheduler == None: Scheduler.__scheduler = BackgroundScheduler() - if os.environ.get('WERKZEUG_RUN_MAIN') == 'true': - Scheduler.__scheduler.start() - logger.info('Scheduler started!') + if bool(os.environ.get("FLASK_ENV", "development") == "development"): + if bool(os.environ.get('WERKZEUG_RUN_MAIN')): + Scheduler.start() + elif not Scheduler.__scheduler.running: + Scheduler.start() return Scheduler.__scheduler diff --git a/app/processors/title_editor.py b/app/processors/title_editor.py index e307746..5a06c72 100644 --- a/app/processors/title_editor.py +++ b/app/processors/title_editor.py @@ -50,7 +50,8 @@ def __init__(self): user_prompt = HumanMessagePromptTemplate(prompt=prompt) chat_prompt = ChatPromptTemplate.from_messages([system_prompt, user_prompt]) - model_name = "dolphin-mistral" + #model_name = "dolphin-mistral" + model_name = "dolphin-llama3" model_temp = 0.2 model = Ollama(base_url=self.ollama_url, model=model_name, keep_alive=5, temperature=model_temp) self.chain = chat_prompt | model | parser diff --git a/app/templates/index.html b/app/templates/index.html index 92f4295..4d71a07 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -7,13 +7,13 @@