@@ -191,7 +191,7 @@ class GetEventGraphResult(common.BaseModel):
191
191
192
192
def get_fast_api_app (
193
193
* ,
194
- agent_dir : str ,
194
+ agents_dir : str ,
195
195
session_db_url : str = "" ,
196
196
allow_origins : Optional [list [str ]] = None ,
197
197
web : bool ,
@@ -210,7 +210,7 @@ def get_fast_api_app(
210
210
memory_exporter = InMemoryExporter (session_trace_dict )
211
211
provider .add_span_processor (export .SimpleSpanProcessor (memory_exporter ))
212
212
if trace_to_cloud :
213
- envs .load_dotenv_for_agent ("" , agent_dir )
213
+ envs .load_dotenv_for_agent ("" , agents_dir )
214
214
if project_id := os .environ .get ("GOOGLE_CLOUD_PROJECT" , None ):
215
215
processor = export .BatchSpanProcessor (
216
216
CloudTraceSpanExporter (project_id = project_id )
@@ -249,8 +249,8 @@ async def internal_lifespan(app: FastAPI):
249
249
allow_headers = ["*" ],
250
250
)
251
251
252
- if agent_dir not in sys .path :
253
- sys .path .append (agent_dir )
252
+ if agents_dir not in sys .path :
253
+ sys .path .append (agents_dir )
254
254
255
255
runner_dict = {}
256
256
root_agent_dict = {}
@@ -259,8 +259,8 @@ async def internal_lifespan(app: FastAPI):
259
259
artifact_service = InMemoryArtifactService ()
260
260
memory_service = InMemoryMemoryService ()
261
261
262
- eval_sets_manager = LocalEvalSetsManager (agent_dir = agent_dir )
263
- eval_set_results_manager = LocalEvalSetResultsManager (agent_dir = agent_dir )
262
+ eval_sets_manager = LocalEvalSetsManager (agents_dir = agents_dir )
263
+ eval_set_results_manager = LocalEvalSetResultsManager (agents_dir = agents_dir )
264
264
265
265
# Build the Session service
266
266
agent_engine_id = ""
@@ -270,7 +270,7 @@ async def internal_lifespan(app: FastAPI):
270
270
agent_engine_id = session_db_url .split ("://" )[1 ]
271
271
if not agent_engine_id :
272
272
raise click .ClickException ("Agent engine id can not be empty." )
273
- envs .load_dotenv_for_agent ("" , agent_dir )
273
+ envs .load_dotenv_for_agent ("" , agents_dir )
274
274
session_service = VertexAiSessionService (
275
275
os .environ ["GOOGLE_CLOUD_PROJECT" ],
276
276
os .environ ["GOOGLE_CLOUD_LOCATION" ],
@@ -282,7 +282,7 @@ async def internal_lifespan(app: FastAPI):
282
282
283
283
@app .get ("/list-apps" )
284
284
def list_apps () -> list [str ]:
285
- base_path = Path .cwd () / agent_dir
285
+ base_path = Path .cwd () / agents_dir
286
286
if not base_path .exists ():
287
287
raise HTTPException (status_code = 404 , detail = "Path not found" )
288
288
if not base_path .is_dir ():
@@ -398,9 +398,9 @@ async def create_session(
398
398
app_name = app_name , user_id = user_id , state = state
399
399
)
400
400
401
- def _get_eval_set_file_path (app_name , agent_dir , eval_set_id ) -> str :
401
+ def _get_eval_set_file_path (app_name , agents_dir , eval_set_id ) -> str :
402
402
return os .path .join (
403
- agent_dir ,
403
+ agents_dir ,
404
404
app_name ,
405
405
eval_set_id + _EVAL_SET_FILE_EXTENSION ,
406
406
)
@@ -490,7 +490,7 @@ async def run_eval(
490
490
491
491
# Create a mapping from eval set file to all the evals that needed to be
492
492
# run.
493
- envs .load_dotenv_for_agent (os .path .basename (app_name ), agent_dir )
493
+ envs .load_dotenv_for_agent (os .path .basename (app_name ), agents_dir )
494
494
495
495
eval_set = eval_sets_manager .get_eval_set (app_name , eval_set_id )
496
496
@@ -663,9 +663,9 @@ async def delete_artifact(
663
663
@app .post ("/run" , response_model_exclude_none = True )
664
664
async def agent_run (req : AgentRunRequest ) -> list [Event ]:
665
665
# Connect to managed session if agent_engine_id is set.
666
- app_id = agent_engine_id if agent_engine_id else req .app_name
666
+ app_name = agent_engine_id if agent_engine_id else req .app_name
667
667
session = await session_service .get_session (
668
- app_name = app_id , user_id = req .user_id , session_id = req .session_id
668
+ app_name = app_name , user_id = req .user_id , session_id = req .session_id
669
669
)
670
670
if not session :
671
671
raise HTTPException (status_code = 404 , detail = "Session not found" )
@@ -684,10 +684,10 @@ async def agent_run(req: AgentRunRequest) -> list[Event]:
684
684
@app .post ("/run_sse" )
685
685
async def agent_run_sse (req : AgentRunRequest ) -> StreamingResponse :
686
686
# Connect to managed session if agent_engine_id is set.
687
- app_id = agent_engine_id if agent_engine_id else req .app_name
687
+ app_name = agent_engine_id if agent_engine_id else req .app_name
688
688
# SSE endpoint
689
689
session = await session_service .get_session (
690
- app_name = app_id , user_id = req .user_id , session_id = req .session_id
690
+ app_name = app_name , user_id = req .user_id , session_id = req .session_id
691
691
)
692
692
if not session :
693
693
raise HTTPException (status_code = 404 , detail = "Session not found" )
@@ -726,9 +726,9 @@ async def get_event_graph(
726
726
app_name : str , user_id : str , session_id : str , event_id : str
727
727
):
728
728
# Connect to managed session if agent_engine_id is set.
729
- app_id = agent_engine_id if agent_engine_id else app_name
729
+ app_name = agent_engine_id if agent_engine_id else app_name
730
730
session = await session_service .get_session (
731
- app_name = app_id , user_id = user_id , session_id = session_id
731
+ app_name = app_name , user_id = user_id , session_id = session_id
732
732
)
733
733
session_events = session .events if session else []
734
734
event = next ((x for x in session_events if x .id == event_id ), None )
@@ -783,9 +783,9 @@ async def agent_live_run(
783
783
await websocket .accept ()
784
784
785
785
# Connect to managed session if agent_engine_id is set.
786
- app_id = agent_engine_id if agent_engine_id else app_name
786
+ app_name = agent_engine_id if agent_engine_id else app_name
787
787
session = await session_service .get_session (
788
- app_name = app_id , user_id = user_id , session_id = session_id
788
+ app_name = app_name , user_id = user_id , session_id = session_id
789
789
)
790
790
if not session :
791
791
# Accept first so that the client is aware of connection establishment,
@@ -855,7 +855,7 @@ async def _get_root_agent_async(app_name: str) -> Agent:
855
855
856
856
async def _get_runner_async (app_name : str ) -> Runner :
857
857
"""Returns the runner for the given app."""
858
- envs .load_dotenv_for_agent (os .path .basename (app_name ), agent_dir )
858
+ envs .load_dotenv_for_agent (os .path .basename (app_name ), agents_dir )
859
859
if app_name in runner_dict :
860
860
return runner_dict [app_name ]
861
861
root_agent = await _get_root_agent_async (app_name )
0 commit comments