Task 010 implement research manifest flow
This commit is contained in:
@@ -11,18 +11,20 @@ from src.application.plans import (
|
||||
get_plan,
|
||||
list_plans,
|
||||
request_plan_revision,
|
||||
start_research,
|
||||
)
|
||||
from src.application.research import list_research_runs, start_research_run
|
||||
from src.domain.auth import EDITOR_OR_ADMIN_ROLES
|
||||
from src.domain.contracts import (
|
||||
AgentJobListResponse,
|
||||
CurrentUser,
|
||||
PlanListResponse,
|
||||
PlanResponse,
|
||||
PlanRevisionRequest,
|
||||
PlanUpdateRequest,
|
||||
ResearchListResponse,
|
||||
ResearchStartResponse,
|
||||
ReviewActionResponse,
|
||||
)
|
||||
from src.infrastructure.object_storage import open_object_storage_client
|
||||
from src.infrastructure.repositories import BackendRepository
|
||||
from src.presentation.dependencies import get_repository, require_roles
|
||||
|
||||
@@ -143,17 +145,36 @@ def post_request_plan_revision(
|
||||
|
||||
@router.post(
|
||||
"/articles/{article_id}/research/start",
|
||||
response_model=AgentJobListResponse,
|
||||
status_code=status.HTTP_202_ACCEPTED,
|
||||
response_model=ResearchStartResponse,
|
||||
status_code=status.HTTP_201_CREATED,
|
||||
)
|
||||
def post_start_research(
|
||||
article_id: UUID,
|
||||
_: CurrentUser = Depends(require_roles(EDITOR_OR_ADMIN_ROLES)),
|
||||
repository: BackendRepository = Depends(get_repository),
|
||||
) -> AgentJobListResponse:
|
||||
) -> ResearchStartResponse:
|
||||
try:
|
||||
return start_research(repository, article_id=article_id)
|
||||
return start_research_run(
|
||||
repository,
|
||||
article_id=article_id,
|
||||
object_storage=open_object_storage_client(),
|
||||
)
|
||||
except LookupError as error:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not Found") from error
|
||||
except PermissionError as error:
|
||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=str(error)) from error
|
||||
|
||||
|
||||
@router.get(
|
||||
"/articles/{article_id}/research",
|
||||
response_model=ResearchListResponse,
|
||||
)
|
||||
def get_research(
|
||||
article_id: UUID,
|
||||
_: CurrentUser = Depends(require_roles(EDITOR_OR_ADMIN_ROLES)),
|
||||
repository: BackendRepository = Depends(get_repository),
|
||||
) -> ResearchListResponse:
|
||||
try:
|
||||
return list_research_runs(repository, article_id=article_id)
|
||||
except LookupError as error:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not Found") from error
|
||||
|
||||
Reference in New Issue
Block a user