改用Grok联网搜索并保留每轮信号

This commit is contained in:
Codex
2026-07-09 00:14:20 +08:00
parent 4f50de8def
commit e02d5db495
14 changed files with 465 additions and 110 deletions
+35 -2
View File
@@ -13,7 +13,7 @@ from app.db.repository import AgentRepository
from app.integrations.github_client import GitHubHotProjectClient
from app.integrations.news_search_client import NewsSearchClient
from app.llm.grok_client import GrokIntelligenceClient
from app.schemas.agent import RunResponse
from app.schemas.agent import RunResponse, SignalItem
logger = logging.getLogger(__name__)
@@ -49,7 +49,12 @@ class AgentRunner:
github_projects=github_projects,
run_date=current_date,
)
signals = self.repo.save_signals(run=run, items=result.signals)
signal_items = self._compose_run_signals(
news_candidates=news_candidates,
github_projects=github_projects,
model_signals=result.signals,
)
signals = self.repo.save_signals(run=run, items=signal_items)
report_path = self.writer.write_daily_report(current_date, result.report_markdown)
self.repo.save_report(
run=run,
@@ -64,6 +69,8 @@ class AgentRunner:
"topic_count": len(topics),
"news_candidate_count": len(news_candidates),
"github_project_count": len(github_projects),
"model_signal_count": len(result.signals),
"saved_signal_count": len(signal_items),
"model": self.grok.settings.llm_model,
"model_response": result.raw_response,
},
@@ -81,3 +88,29 @@ class AgentRunner:
self.db.commit()
logger.exception("agent_run_failed run_id=%s error=%s", run.id, exc)
raise
def _compose_run_signals(
self,
news_candidates: list[SignalItem],
github_projects: list[SignalItem],
model_signals: list[SignalItem],
) -> list[SignalItem]:
# 入库清单以采集候选为准,模型同链接结果只增强摘要和重要度,避免日报模型漏选导致信号消失。
model_by_url = {item.source_url: item for item in model_signals}
composed = []
for candidate in [*news_candidates, *github_projects]:
model_item = model_by_url.get(candidate.source_url)
if model_item is None:
composed.append(candidate)
continue
composed.append(
candidate.model_copy(
update={
"topic": model_item.topic,
"summary": model_item.summary,
"importance": model_item.importance,
"entities": model_item.entities or candidate.entities,
}
)
)
return composed