1+ from collections .abc import Generator
12from datetime import datetime
3+ from typing import Any
24
35from fastapi import (
46 APIRouter ,
2426@router .post ("/verify" )
2527async def verify (
2628 info : LLMInfo , secrets : InMemorySecrets = Depends (get_in_memory_secrets )
27- ):
29+ ) -> dict [ str , int | str | float ] :
2830 spec = LLMSpec .from_string (info .spec )
2931 try :
3032 r = await spec .verify ()
@@ -42,7 +44,7 @@ async def verify(
4244 )
4345
4446
45- def streaming_response_generator (scan_parameters : Scan ):
47+ def streaming_response_generator (scan_parameters : Scan ) -> Generator [ str , Any , None ] :
4648 request_factory = LLMSpec .from_string (scan_parameters .llmSpec )
4749 set_current_run (request_factory )
4850
@@ -63,15 +65,15 @@ async def scan(
6365 scan_parameters : Scan ,
6466 background_tasks : BackgroundTasks ,
6567 secrets : InMemorySecrets = Depends (get_in_memory_secrets ),
66- ):
68+ ) -> StreamingResponse :
6769 scan_parameters .with_secrets (secrets )
6870 return StreamingResponse (
6971 streaming_response_generator (scan_parameters ), media_type = "application/json"
7072 )
7173
7274
7375@router .post ("/stop" )
74- async def stop_scan ():
76+ async def stop_scan () -> dict [ str , str ] :
7577 get_stop_event ().set ()
7678 return {"status" : "Scan stopped" }
7779
@@ -85,7 +87,7 @@ async def scan_csv(
8587 maxBudget : int = Query (10_000 ),
8688 enableMultiStepAttack : bool = Query (False ),
8789 secrets : InMemorySecrets = Depends (get_in_memory_secrets ),
88- ):
90+ ) -> StreamingResponse :
8991 # TODO: content dataset to fuzzer
9092 content = await file .read () # noqa
9193 llm_spec = await llmSpec .read ()
0 commit comments