https://github.com/i-am-bee/bee-api
API backend for Bee
https://github.com/i-am-bee/bee-api
agents ai api assistants-api bee-agent-framework fastify
Last synced: about 1 month ago
JSON representation
API backend for Bee
- Host: GitHub
- URL: https://github.com/i-am-bee/bee-api
- Owner: i-am-bee
- License: apache-2.0
- Created: 2024-10-16T14:49:14.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-29T09:49:57.000Z (6 months ago)
- Last Synced: 2024-10-29T10:02:17.420Z (6 months ago)
- Topics: agents, ai, api, assistants-api, bee-agent-framework, fastify
- Language: TypeScript
- Homepage:
- Size: 553 KB
- Stars: 16
- Watchers: 4
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
![]()
Bee API
OpenAI-compatible Assistants API backed by Bee Agent Framework
## Getting started
> [!TIP]
>
> 🚀 The fastest way to setup Bee (UI + API) is through [Bee Stack](https://github.com/i-am-bee/bee-stack).1. Create `.env` (from `.env.example`) and fill in values.
2. Run `pnpm install` to install dependencies.
3. Start the server with `pnpm start:dev`## Technologies
- [Fastify](https://fastify.dev/) as the web framework
- [MikroORM](https://mikro-orm.io/) backed by [MongoDB](https://www.mongodb.com/) as the database layer
- [BullMQ](https://docs.bullmq.io/guide/jobs) backed by [Redis](https://redis.io/) as the job executor
- [Bee Agent Framework](https://github.com/i-am-bee/bee-agent-framework) as the agent execution engine## Architecture overview
The Assistants API consists mostly of CRUDL endpoints for managing API resources like assistants, threads, runs and more. Furthermore, some resources are asynchronous in a sense that they contain `status` changing over time as the background execution progresses. Clients use polling or streaming to watch for status updates of such resources.
### Infrastructure
The infrastructure consists of:
- REST API server
- MongoDB
- RedisThe REST API server stores resources in MongoDB database. Redis is used by BullMQ, rate limiter and as pub/sub broker for event streaming. Agent execution is performed by the Bee Agent Framework using various adapters for inference and embeddings.
### Server
The codebase contains several types of modules:
- `*.modules.ts` containing endpoint handlers
- `*.services.ts` containing services for the handlers
- `dtos/*.ts` containing JSON schema definitions for resources
- `*.entity.ts` containing ORM definitions for database entities
- `*.queue.ts` containing BullMQ queues and workers for asynchronous executionThese modules are connected in the following manner
```
module ---> dto
---> service ---> entity
---> queue ---> entity
```OpenAPI schema is auto-generated from the `dtos` and exposed on the `/docs` endpoint.
## Starting the bee-api infrastructure
The easiest way to run all the dependencies for the bee-api is to:
- Clone the bee-stack repository https://github.com/i-am-bee/bee-stack
- Navigate to the bee-stack directory.
- Run the infrastructure:```
./bee-stack.sh clean
./bee-stack.sh start:infra
```- Then navigate back to the bee-api repository.
- Install packages:```
pnpm install
```- When running for the first time seed the database:
```
pnpm mikro-orm seeder:run
```- copy .env.example to .env
```
cp .env.example .env
```- Add values the env vars: CRYPTO_CIPHER_KEY, AI_BACKEND and API key for which ever provider you have chosen.
- Run the bee-api:
```
pnpm start:dev
```