Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/articles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 5 additions & 3 deletions config.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
TURNSTILE_SITE_KEY = "" # cloudflare Turnstile site key
TURNSTILE_SECRET_KEY = "" # cloudflare Turnstile secret key
1 change: 1 addition & 0 deletions gmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 6 additions & 7 deletions gmt/views/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions requirements-github.txt

This file was deleted.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Loading