mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Adding api endpoints
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import fastapi
|
||||
import fastapi.responses
|
||||
import pydantic
|
||||
|
||||
router = fastapi.APIRouter()
|
||||
|
||||
@@ -12,6 +13,38 @@ router = fastapi.APIRouter()
|
||||
def get_agents(
|
||||
featured: bool, top: bool, categories: str, page: int = 1, page_size: int = 20
|
||||
):
|
||||
"""
|
||||
This is needed for:
|
||||
- Home Page Featured Agents
|
||||
- Home Page Top Agents
|
||||
- Search Results
|
||||
- Agent Details - Other Agents By
|
||||
- Agent Details - Similar Agents
|
||||
- Creator Details - Agent By x
|
||||
|
||||
---
|
||||
To support all these different usecase we need a bunch of options:
|
||||
- featured: bool - Filteres the list to featured only
|
||||
- createdBy: username - Returns all agents by that user or group
|
||||
- sortedBy: [runs, stars] - For the Top agents
|
||||
- searchTerm: string - embedding similarity search based on Name, subheading and description
|
||||
- category: string - Filter by category
|
||||
|
||||
In addition we need:
|
||||
- page: int - for pagination
|
||||
- page_size: int - for pagination
|
||||
"""
|
||||
|
||||
class StoreAgent(pydantic.BaseModel):
|
||||
agentName: str
|
||||
agentImage: str
|
||||
creator: str
|
||||
creatorAvatar: str
|
||||
subHeading: str
|
||||
description: str
|
||||
runs: int
|
||||
stars: float
|
||||
|
||||
return fastapi.responses.JSONResponse(
|
||||
content=[
|
||||
{
|
||||
@@ -36,9 +69,27 @@ def get_agents(
|
||||
)
|
||||
|
||||
|
||||
@router.get("agents/{username}/{slug}")
|
||||
def get_agent(agent_id: str, agent_version: int):
|
||||
"""Gets the details of an agent"""
|
||||
@router.get("agents/{username}/{agent_name}")
|
||||
def get_agent(username: str, agent_name: int):
|
||||
"""
|
||||
This is only used on the AgentDetails Page
|
||||
|
||||
It returns the store listing agents details.
|
||||
"""
|
||||
|
||||
class StoreAgentDetails(pydantic.BaseModel):
|
||||
agentName: str
|
||||
agentVideo: str
|
||||
agentImage: list[str]
|
||||
creator: str
|
||||
creatorAvatar: str
|
||||
subHeading: str
|
||||
description: str
|
||||
categoires: list[str]
|
||||
runs: int
|
||||
stars: float
|
||||
verions: list[str]
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user