改用Grok联网搜索并保留每轮信号
This commit is contained in:
+19
-1
@@ -2,11 +2,12 @@ from __future__ import annotations
|
||||
|
||||
from typing import Literal, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends
|
||||
from fastapi.responses import HTMLResponse
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.agent.scheduler import run_scheduled_job
|
||||
from app.core.config import Settings, get_settings
|
||||
from app.db.models import AgentRun, Report, Signal, Topic
|
||||
from app.db.session import get_db
|
||||
@@ -14,6 +15,7 @@ from app.schemas.agent import (
|
||||
DashboardRead,
|
||||
ReportRead,
|
||||
RunRead,
|
||||
RunTriggerRead,
|
||||
SignalRead,
|
||||
TopicCreate,
|
||||
TopicRead,
|
||||
@@ -41,6 +43,22 @@ def list_runs(db: Session = Depends(get_db)) -> list[AgentRun]:
|
||||
return list(db.scalars(select(AgentRun).order_by(AgentRun.id.desc()).limit(20)).all())
|
||||
|
||||
|
||||
@router.post("/agent/runs/daily", response_model=RunTriggerRead)
|
||||
def trigger_daily_run(
|
||||
background_tasks: BackgroundTasks,
|
||||
settings: Settings = Depends(get_settings),
|
||||
db: Session = Depends(get_db),
|
||||
) -> RunTriggerRead:
|
||||
# 手动搜索复用定时任务入口,避免测试按钮和自动调度走出两套采集逻辑。
|
||||
running = db.scalar(
|
||||
select(AgentRun).where(AgentRun.status == "running").order_by(AgentRun.id.desc()).limit(1)
|
||||
)
|
||||
if running is not None:
|
||||
return RunTriggerRead(status="running", run_id=running.id)
|
||||
background_tasks.add_task(run_scheduled_job, settings)
|
||||
return RunTriggerRead(status="started")
|
||||
|
||||
|
||||
@router.get("/signals", response_model=list[SignalRead])
|
||||
def list_signals(
|
||||
limit: int = 100,
|
||||
|
||||
Reference in New Issue
Block a user