aboutsummaryrefslogtreecommitdiff
path: root/autogpt/core/runner/cli_web_app/server/api.py
blob: 01c50b06d187c29eeda0825561eb333e16d266ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import uuid

from fastapi import APIRouter, FastAPI, Request

from autogpt.core.runner.cli_web_app.server.schema import InteractRequestBody

router = APIRouter()


@router.post("/agents")
async def create_agent(request: Request):
    """Create a new agent."""
    agent_id = uuid.uuid4().hex
    return {"agent_id": agent_id}


@router.post("/agents/{agent_id}")
async def interact(request: Request, agent_id: str, body: InteractRequestBody):
    """Interact with an agent."""

    # check headers

    # check if agent_id exists

    # get agent object from somewhere, e.g. a database/disk/global dict

    # continue agent interaction with user input

    return {
        "thoughts": {
            "thoughts": {
                "text": "text",
                "reasoning": "reasoning",
                "plan": "plan",
                "criticism": "criticism",
                "speak": "speak",
            },
            "commands": {
                "name": "name",
                "args": {"arg_1": "value_1", "arg_2": "value_2"},
            },
        },
        "messages": ["message1", agent_id],
    }


app = FastAPI()
app.include_router(router, prefix="/api/v1")