NeerajCodz commited on
Commit
e497b8a
·
1 Parent(s): bf7d25d

fix: add list_providers method and agents list endpoint

Browse files
backend/app/api/routes/agents.py CHANGED
@@ -105,6 +105,46 @@ class AgentState(BaseModel):
105
  _agent_states: dict[str, AgentState] = {}
106
 
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  @router.post(
109
  "/run",
110
  response_model=AgentRunResponse,
 
105
  _agent_states: dict[str, AgentState] = {}
106
 
107
 
108
+ @router.get(
109
+ "/list",
110
+ status_code=status.HTTP_200_OK,
111
+ summary="List all agents",
112
+ description="Get list of all available agents and their status",
113
+ )
114
+ async def list_agents() -> dict[str, Any]:
115
+ """
116
+ List all available agents and their current states.
117
+
118
+ Returns:
119
+ Dictionary with agent types and their states.
120
+ """
121
+ agent_types = [
122
+ {
123
+ "type": at.value,
124
+ "name": at.name.title(),
125
+ "description": f"{at.name.title()} agent for web scraping tasks",
126
+ }
127
+ for at in AgentType
128
+ ]
129
+
130
+ active_agents = [
131
+ {
132
+ "agent_id": agent_id,
133
+ "type": state.agent_type,
134
+ "status": state.status,
135
+ "episode_id": state.episode_id,
136
+ }
137
+ for agent_id, state in _agent_states.items()
138
+ ]
139
+
140
+ return {
141
+ "agent_types": agent_types,
142
+ "active_agents": active_agents,
143
+ "total_types": len(AgentType),
144
+ "active_count": len(_agent_states),
145
+ }
146
+
147
+
148
  @router.post(
149
  "/run",
150
  response_model=AgentRunResponse,
backend/app/models/router.py CHANGED
@@ -260,6 +260,10 @@ class SmartModelRouter:
260
  self.providers.clear()
261
  self._initialized = False
262
 
 
 
 
 
263
  def get_available_models(self) -> list[ModelInfo]:
264
  """Get all available models across providers."""
265
  models = []
 
260
  self.providers.clear()
261
  self._initialized = False
262
 
263
+ def list_providers(self) -> list[str]:
264
+ """Get list of initialized provider names."""
265
+ return list(self.providers.keys())
266
+
267
  def get_available_models(self) -> list[ModelInfo]:
268
  """Get all available models across providers."""
269
  models = []