diff --git a/.github/workflows/articles.yaml b/.github/workflows/articles.yaml index f01527bc..c068939c 100644 --- a/.github/workflows/articles.yaml +++ b/.github/workflows/articles.yaml @@ -35,7 +35,6 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install -r requirements-github.txt - name: Summarize Articles run: | diff --git a/config.template.py b/config.template.py index f2aafa77..1d158fe1 100644 --- a/config.template.py +++ b/config.template.py @@ -13,9 +13,11 @@ FTP_PASSWORD = "password" ADMIN_USER_EMAILS = ["email@email.com"] # Users who will have access to the admin panel API_NINJA_KEY = "" # API key for API Ninja, Get it from https://api-ninjas.com/ required for surprise function in email -MISTRAL_API_KEY = "" # API key for Mistral AI, Get it from https://mistral.ai/ required for summaries +MISTRAL_API_KEY = ( + "" # API key for Mistral AI, Get it from https://mistral.ai/ required for summaries +) FORM_WEBHOOK = None WRITER_WEBHOOK = None # Webhook where we will get notified on a new application CRON_JOB_WEBHOOK = None # Webhook where we will get notified when running cron jobs -TURNSTILE_SITE_KEY = "" # cloudflare Turnstile site key -TURNSTILE_SECRET_KEY = "" # cloudflare Turnstile secret key \ No newline at end of file +TURNSTILE_SITE_KEY = "" # cloudflare Turnstile site key +TURNSTILE_SECRET_KEY = "" # cloudflare Turnstile secret key diff --git a/gmt/__init__.py b/gmt/__init__.py index 9017fc74..a833db4b 100644 --- a/gmt/__init__.py +++ b/gmt/__init__.py @@ -16,6 +16,7 @@ except ImportError: # @crontab.job(minute="*/30") create dummy cron job, to be crontab, FOR LOCAL DEVELOPMENT print("Crontab not installed, using dummy crontab") + class Crontab: def job(self, **kwargs): def decorator(func): diff --git a/gmt/views/commands.py b/gmt/views/commands.py index d1850caa..ec4da09a 100644 --- a/gmt/views/commands.py +++ b/gmt/views/commands.py @@ -32,13 +32,12 @@ def query(content): """Query the Mistral API with the given content string.""" try: - client = Mistral(api_key=current_app.config['MISTRAL_API_KEY']) - + client = Mistral(api_key=current_app.config["MISTRAL_API_KEY"]) + chat_response = client.chat.complete( - model=MISTRAL_MODEL, - messages=[{"role": "user", "content": content}] + model=MISTRAL_MODEL, messages=[{"role": "user", "content": content}] ) - + return chat_response.choices[0].message.content except Exception as e: print(f"Error querying Mistral API: {e}") @@ -253,7 +252,7 @@ def summarize_news(): prompt = f"Summarize the following text, clean it up and remove spam, keep it between 200 and 300 characters: {description}" summary = query(prompt) print(f"Generated summary: {len(summary)} chars") - + if not summary: raise Exception("No text returned") @@ -284,7 +283,7 @@ def summarize_news(): summarized_news_collection.append(summarized_news) news_amount += 1 print("Summarized") - + # Add a small sleep between article summaries to avoid rate limiting sleep(1) diff --git a/requirements-dev.txt b/requirements-dev.txt index 3a8ce878..c5ea065e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ black==24.4.2 -djlint==1.34.1 -pre-commit==3.8.0 +djlint==1.36.4 +pre-commit==4.2.0 isort==5.13.2 diff --git a/requirements-github.txt b/requirements-github.txt deleted file mode 100644 index c24e15d2..00000000 --- a/requirements-github.txt +++ /dev/null @@ -1,2 +0,0 @@ -transformers==4.48.0 -tensorflow==2.15.0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1d71da4a..7a6d5395 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ Flask-Mail==0.10.0 Flask-PyMongo==2.3.0 Flask-WTF==1.2.1 Flask==2.3.2 -WTForms==3.1.2 +WTForms==3.2.1 beautifulsoup4==4.12.3 email-validator==2.1.1 feedparser==6.0.11 @@ -15,9 +15,9 @@ Flask-mde==1.2.1 Flask-login==0.6.3 arrow==1.3.0 pytz==2022.7.1 -lxml==4.9.3 +lxml==5.3.1 Flask-Admin==1.6.1 flask-crontab==0.1.2 -gunicorn==22.0.0 +gunicorn==23.0.0 flask-turnstile==0.1.1 mistralai==1.5.1 \ No newline at end of file