This project serves as a proxy for the OpenAI API. Using bun
as runtime.
To get started with this project, you'll need to install the necessary dependencies. You can do this by running:
bun install
To start the development server, run:
bun dev
This will start the server and watch for changes in the src/index.ts
file.
This project includes a docker-compose.yml
file for running the application in a Docker container. This can be useful for development and testing, as well as for deploying the application in a production environment.
To use Docker Compose, you'll first need to install Docker and Docker Compose on your machine. Once you've done that, you can start the application with the following command:
docker-compose up
This will build the Docker image for the application (if it hasn't been built already) and start a new container. The application will be accessible at http://localhost:3000
.
This project uses environment variables for configuration. These are stored in the .env
file. You'll need to provide your own API_TOKEN
in this file.
In the Docker environment, these variables are set in the docker-compose.yml
file:
version: "3"
services:
openai-proxy:
build: .
container_name: openai-proxy
restart: always
ports:
- "3000:3000"
environment:
- API_TOKEN=sk-1234567890abcdef
- AGENT_ROLL_INTERVAL=60000
Please replace sk-1234567890abcdef
with your middleware API token. Default will be a random token each time container started if API_TOKEN
empty.
The main entry point for the application is src/index.ts
. This project also includes several utility functions and classes:
src/openai.ts
: Contains various utility functions for interacting with the OpenAI API.src/fetch.ts
: Defines theFetcher
class for making HTTP requests.src/agent.ts
: Defines theAgentManager
class for managing user agents.src/tools.ts
: Contains theAppLogger
class for logging.
Currently, this project does not have any tests defined.
Contributions are welcome! Please feel free to submit a pull request.
This project is licensed under the terms of the MIT license.
Special thanks to @PawanOsman for his wonderful project, which served as inspiration for this project.