Skip to content

Commit

Permalink
more!
Browse files Browse the repository at this point in the history
  • Loading branch information
ilude committed Apr 18, 2024
1 parent 2216527 commit 4160632
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/models/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def __init__(self, widget) -> None:
self._last_updated = datetime.fromtimestamp(os.path.getmtime(self.cache_path))

logger.debug(f"creating cron job for {self.name}")
self.scheduler.add_job(self.update, 'cron', name=f'{self.id} - {self.name} - cron', hour='*', jitter=20, max_instances=1)
job = self.scheduler.add_job(self.update, 'cron', name=f'{self.id} - {self.name} - cron', hour='*', jitter=20, max_instances=1)

if self.needs_update or self.old_cache_path.exists() or self.name == "Instapundit":
# schedule job to run right now
logging.debug(f"{self.name} scheduled {self.name} for immediate update now!")
self.scheduler.add_job(self.update, 'date', name=f'{self.id} - {self.name} - update', run_date=datetime.now(), max_instances=1)
job.modify(next_run_time=datetime.now())
#else:
# logger.debug(f"scheduled for {self.name} immediate processing now")
# self.scheduler.add_job(self.process, 'date', name=f'{self.id} - {self.name} - process', run_date=datetime.now(), max_instances=1)
Expand Down
10 changes: 5 additions & 5 deletions app/processors/title_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self):
# format chat prompt
system_prompt = SystemMessage(content=("""
You are an expert news article title editor.
Use the provided title and summary to write a concise and accurate title that is concise, informative and avoids sounding like clickbait.
Use the provided title and summary to write a concise and accurate title that is informative and avoids sounding like clickbait.
Do not include links or urls in the title.
Title should be as short as possible, aim to be less that 70 characters long.
Title should have an absolute minimum of punctuation and use at most one all capitalized word at the start of the title.
Expand All @@ -57,10 +57,10 @@ def process(self, articles: list[FeedArticle]) -> list[FeedArticle]:
total = len(needs_processed)
for count, article in enumerate(needs_processed, start=1):
try:
result = self.chain.invoke({"title": article.original_title, "summary": article.description})
article.title = result['title']
article.processed = self.script_hash
logger.debug(f"{count}/{total}: {article.processed != self.script_hash} current hash: {self.script_hash} processed hash: {article.processed}")
logger.debug(f"{count}/{total}: {article.processed != self.script_hash} current hash: {self.script_hash} processed hash: {article.processed}")
result = self.chain.invoke({"title": article.original_title, "summary": article.description})
article.title = result['title']
article.processed = self.script_hash
except Exception as ex:
print(f"Error: {ex} for {article.original_title}")
needs_processed.remove(article)
Expand Down

0 comments on commit 4160632

Please sign in to comment.