This project is a RESTful, OpenAI-compatible API built using Rust. It's designed to integrate with any Large Language Model (LLM) from OpenAI you input into it, providing flexibility. The application utilizes Docker and Docker Compose for easy deployment and scalability. It also features SerpApi for web scraping to enhance the context provided to the language model. The design prioritizes scalability and ease of deployment.
online_llm/
├── Cargo.lock
├── Cargo.toml
├── Dockerfile
├── Rocket.toml
├── docker-compose.yml
├── .env
├── src/
│ ├── api.rs
│ ├── config.rs
│ ├── main.rs
│ ├── models.rs
│ ├── openai_client.rs
│ └── serpapi_client.rs
├── tests/
│ └── integration_tests.rs
└── README.md
Create the .env
file:
touch .env
Add the following lines to the .env
file with your API keys:
OPENAI_API_KEY=your_openai_api_key_here
SERPAPI_API_KEY=your_serpapi_api_key_here
Build and run the application:
docker-compose build
docker-compose up
When running the application with docker-compose up, the health check endpoint is hit every 30 seconds. You should see the OK log in the terminal in which you launched the app.
Verify the application is running:
docker-compose logs
Rocket has launched from http://0.0.0.0:8000
.If you want to run the application without Docker Compose, you can use the run.sh script that is included in the repository. To do this, simply run the following command:
./run.sh
The application includes a health check endpoint to monitor its status. The health check endpoint is /health
and can be used to verify that the application is running correctly.
curl http://localhost:8000/health
This should return OK
if the application is running correctly.
To ensure the application is functioning as expected, you can run the tests included in the project. The tests are located in the tests/integration_tests.rs
file.
Run the tests using the following command:
cargo test
This repository includes a script for deploying the application to Heroku using the Heroku Container Registry. The script is named deploy.sh
.
Before running the script, you need to set the following environment variables:
HEROKU_API_KEY
: Your Heroku API key. You can get this from your Heroku account settings.HEROKU_APP_NAME
: The name of your Heroku app. This is the name you chose when you created the app on Heroku.You can set these environment variables in your shell like this:
export HEROKU_API_KEY=your_heroku_api_key_here
export HEROKU_APP_NAME=your_heroku_app_name_here
./deploy.sh
This project is licensed under the MIT License. See the LICENSE
file for more details.