Skip to content

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Apr 25, 2023
1 parent 4205116 commit b557d4d
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions examples/babyagi/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# JS Agent BabyAGI
# JS Agent BabyAGI (Server)

JS Agent implementation of [BabyAGI](https://github.com/yoheinakajima/babyagi) by [@yoheinakajima](https://twitter.com/yoheinakajima).
JS Agent server implementation of [BabyAGI](https://github.com/yoheinakajima/babyagi) by [@yoheinakajima](https://twitter.com/yoheinakajima).

It is implemented as a single planner step and does not use memory or actions. The main loop that executes the top task from a task list and then updates the task list was extracted into "UpdateTasksLoop".

**⚠️ The BabyAGI implementation is currently being reworked into a server. The documentation is out of date.**

## JS Agent features used

- Agent server with HTTP API
- expose run as log
- calculate cost
- OpenAI text completion model (`text-davinci-003`)
- Custom console output with AgentRunObserver
- `UpdateTasksLoop` planning loop
- Creating typed LLM functions with prompt and output processor using `$.text.generate`

Expand All @@ -32,26 +32,36 @@ pnpm nx run-many --target=build
pnpm build
```

3. Start the server:
3. Start the server. It runs on port `30800` by default. You can set the `--host` and `--port` params to change the host and port the server runs on.

```sh
pnpm start
```

4. Create an agent run. The response contains the `runId`:
4. Create an agent run using a `POST` request to `/agent/babyagi`. The response contains the `runId`:

```bash
curl -X POST -H "Content-Type: application/json" -d '{"objective":"solve world hunger"}' http://127.0.0.1:30800/agent/babyagi
{"runId":"bsFcdSuvQQONvG5zxf1G_g-0"}%
```

5. Start the run (with the run id):
5. Use the run id to access the current run state in the browser.

`http://localhost:30800/agent/babyagi/run/bsFcdSuvQQONvG5zxf1G_g-0`

6. Start the run (with the run id):

```bash
❯ curl -X POST http://127.0.0.1:30800/agent/babyagi/run/bsFcdSuvQQONvG5zxf1G_g-0/start
{"runId":"bsFcdSuvQQONvG5zxf1G_g-0"}%
```

6. Use the run id to access the current run state in the browser.
7. You can cancel the run with a call to the cancel route (with the run id):

`http://localhost:30800/agent/babyagi/run/bsFcdSuvQQONvG5zxf1G_g-0`
```bash
❯ curl -X POST -H "Content-Type: application/json" -d '{"reason": "need to shut down computer"}' http://127.0.0.1:30800/agent/babyagi/run/bxynsv4USkGoawtCYhte-w-0/cancel
```

## Source Code

See `agent/babyagi/agent.ts`.

0 comments on commit b557d4d

Please sign in to comment.