|
83 | 83 | logging.info("Added health check middleware") |
84 | 84 |
|
85 | 85 |
|
86 | | -@app.post("/input_task") |
| 86 | +@app.post("/api/input_task") |
87 | 87 | async def input_task_endpoint(input_task: InputTask, request: Request): |
88 | 88 | """ |
89 | 89 | Receive the initial input task from the user. |
@@ -175,7 +175,7 @@ async def input_task_endpoint(input_task: InputTask, request: Request): |
175 | 175 | raise HTTPException(status_code=400, detail="Error creating plan") |
176 | 176 |
|
177 | 177 |
|
178 | | -@app.post("/human_feedback") |
| 178 | +@app.post("/api/human_feedback") |
179 | 179 | async def human_feedback_endpoint(human_feedback: HumanFeedback, request: Request): |
180 | 180 |
|
181 | 181 | """ |
@@ -268,7 +268,7 @@ async def human_feedback_endpoint(human_feedback: HumanFeedback, request: Reques |
268 | 268 | } |
269 | 269 |
|
270 | 270 |
|
271 | | -@app.post("/human_clarification_on_plan") |
| 271 | +@app.post("/api/human_clarification_on_plan") |
272 | 272 | async def human_clarification_endpoint( |
273 | 273 | human_clarification: HumanClarification, request: Request |
274 | 274 | ): |
@@ -349,7 +349,7 @@ async def human_clarification_endpoint( |
349 | 349 | } |
350 | 350 |
|
351 | 351 |
|
352 | | -@app.post("/approve_step_or_steps") |
| 352 | +@app.post("/api/approve_step_or_steps") |
353 | 353 | async def approve_step_endpoint( |
354 | 354 | human_feedback: HumanFeedback, request: Request |
355 | 355 | ) -> Dict[str, str]: |
@@ -453,7 +453,7 @@ async def approve_step_endpoint( |
453 | 453 | return {"status": "All steps approved"} |
454 | 454 |
|
455 | 455 |
|
456 | | -@app.get("/plans", response_model=List[PlanWithSteps]) |
| 456 | +@app.get("/api/plans", response_model=List[PlanWithSteps]) |
457 | 457 | async def get_plans( |
458 | 458 | request: Request, session_id: Optional[str] = Query(None) |
459 | 459 | ) -> List[PlanWithSteps]: |
@@ -553,7 +553,7 @@ async def get_plans( |
553 | 553 | return list_of_plans_with_steps |
554 | 554 |
|
555 | 555 |
|
556 | | -@app.get("/steps/{plan_id}", response_model=List[Step]) |
| 556 | +@app.get("/api/steps/{plan_id}", response_model=List[Step]) |
557 | 557 | async def get_steps_by_plan(plan_id: str, request: Request) -> List[Step]: |
558 | 558 | """ |
559 | 559 | Retrieve steps for a specific plan. |
@@ -616,7 +616,7 @@ async def get_steps_by_plan(plan_id: str, request: Request) -> List[Step]: |
616 | 616 | return steps |
617 | 617 |
|
618 | 618 |
|
619 | | -@app.get("/agent_messages/{session_id}", response_model=List[AgentMessage]) |
| 619 | +@app.get("/api/agent_messages/{session_id}", response_model=List[AgentMessage]) |
620 | 620 | async def get_agent_messages(session_id: str, request: Request) -> List[AgentMessage]: |
621 | 621 | """ |
622 | 622 | Retrieve agent messages for a specific session. |
@@ -680,7 +680,7 @@ async def get_agent_messages(session_id: str, request: Request) -> List[AgentMes |
680 | 680 | return agent_messages |
681 | 681 |
|
682 | 682 |
|
683 | | -@app.delete("/messages") |
| 683 | +@app.delete("/api/messages") |
684 | 684 | async def delete_all_messages(request: Request) -> Dict[str, str]: |
685 | 685 | """ |
686 | 686 | Delete all messages across sessions. |
@@ -723,7 +723,7 @@ async def delete_all_messages(request: Request) -> Dict[str, str]: |
723 | 723 | return {"status": "All messages deleted"} |
724 | 724 |
|
725 | 725 |
|
726 | | -@app.get("/messages") |
| 726 | +@app.get("/api/messages") |
727 | 727 | async def get_all_messages(request: Request): |
728 | 728 | """ |
729 | 729 | Retrieve all messages across sessions. |
@@ -804,39 +804,6 @@ async def get_agent_tools(): |
804 | 804 | return [] |
805 | 805 |
|
806 | 806 |
|
807 | | -# Initialize the application when it starts |
808 | | -@app.on_event("startup") |
809 | | -async def startup_event(): |
810 | | - """Initialize the application on startup. |
811 | | - |
812 | | - This function runs when the FastAPI application starts up. |
813 | | - It sets up the agent types and tool loaders so the first request is faster. |
814 | | - """ |
815 | | - # Log startup |
816 | | - logging.info("Application starting up. Initializing agent factory...") |
817 | | - |
818 | | - try: |
819 | | - # Create a temporary session and user ID to pre-initialize agents |
820 | | - # This ensures tools are loaded into the factory on startup |
821 | | - temp_session_id = "startup-session" |
822 | | - temp_user_id = "startup-user" |
823 | | - |
824 | | - # Create a test agent to initialize the tool loading system |
825 | | - # This will pre-load tool configurations into memory |
826 | | - test_agent = await AgentFactory.create_agent( |
827 | | - agent_type=AgentType.GENERIC, |
828 | | - session_id=temp_session_id, |
829 | | - user_id=temp_user_id |
830 | | - ) |
831 | | - |
832 | | - # Clean up initialization resources |
833 | | - AgentFactory.clear_cache(temp_session_id) |
834 | | - logging.info("Agent factory successfully initialized") |
835 | | - |
836 | | - except Exception as e: |
837 | | - # Don't fail startup, but log the error |
838 | | - logging.error(f"Error initializing agent factory: {e}") |
839 | | - |
840 | 807 |
|
841 | 808 | # Run the app |
842 | 809 | if __name__ == "__main__": |
|
0 commit comments