|
|
|
@ -319,31 +319,26 @@ class RunOrchestrator:
|
|
|
|
def _summarize_and_notify(self, summary: RunSummary, run_date: date) -> None:
|
|
|
|
def _summarize_and_notify(self, summary: RunSummary, run_date: date) -> None:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from gimme_job.db.engine import db_session
|
|
|
|
from gimme_job.db.engine import db_session
|
|
|
|
from gimme_job.db.repo import JobPostingRepo, SummaryRepo
|
|
|
|
from gimme_job.db.repo import JobPostingRepo
|
|
|
|
|
|
|
|
from gimme_job.runtime.notifier import NotificationDispatcher, build_listing_messages
|
|
|
|
|
|
|
|
from gimme_job.runtime.telegram import TelegramClient
|
|
|
|
|
|
|
|
|
|
|
|
with db_session() as session:
|
|
|
|
with db_session() as session:
|
|
|
|
postings = JobPostingRepo().get_today_new(session, run_date)
|
|
|
|
postings = JobPostingRepo().get_today_new(session, run_date)
|
|
|
|
|
|
|
|
|
|
|
|
if not postings:
|
|
|
|
if not postings:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
chunks = build_listing_messages(postings)
|
|
|
|
|
|
|
|
|
|
|
|
from gimme_job.runtime.summarizer import OllamaSummarizer
|
|
|
|
client = TelegramClient()
|
|
|
|
summarizer = OllamaSummarizer(
|
|
|
|
if client.is_configured():
|
|
|
|
base_url=self.cfg.summarization.ollama_base_url,
|
|
|
|
for chunk in chunks:
|
|
|
|
model=self.cfg.summarization.model,
|
|
|
|
client.send_message(chunk)
|
|
|
|
temperature=self.cfg.summarization.temperature,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
text = summarizer.summarize(postings)
|
|
|
|
|
|
|
|
summary.summary_text = text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with db_session() as session:
|
|
|
|
|
|
|
|
SummaryRepo().save_summary(session, run_date, text, self.cfg.summarization.model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from gimme_job.runtime.notifier import NotificationDispatcher
|
|
|
|
|
|
|
|
dispatcher = NotificationDispatcher(
|
|
|
|
dispatcher = NotificationDispatcher(
|
|
|
|
global_config=self.cfg, session_factory=self.session_factory
|
|
|
|
global_config=self.cfg, session_factory=self.session_factory
|
|
|
|
)
|
|
|
|
)
|
|
|
|
dispatcher.send(text, run_date)
|
|
|
|
full_text = "\n\n".join(chunks)
|
|
|
|
|
|
|
|
dispatcher.send_markdown_fallback(full_text, run_date)
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
logger.error(f"Summarize/notify failed: {e}")
|
|
|
|
logger.error(f"Summarize/notify failed: {e}")
|
|
|
|
|