This project is a language model gateway that provides an OpenAI compatible API for language models. It is built using FastAPI and GraphQL.
- Docker
- Docker Compose
- Make
To run the project locally, follow these steps:
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create
docker.env
file in the root of the project based on thedocker.env.example
. Update the keys for the functionality/providers you're planning on using.AWS_CREDENTIALS_PROFILE
is the only one that is absolutely required to get going. Set this to the AWS profile you're part of e.g.,admin_dev
. -
Set up the development environment:
make devsetup
-
Start the Docker containers:
make down; make up
The project is structured into several main components:
- API: Built using FastAPI, it provides endpoints for interacting with the language models.
- GraphQL: Used for querying and mutating data.
- Routers: Define the routes for different functionalities like chat completions, image generation, etc.
- Managers: Handle the business logic for different functionalities.
- Utilities: Helper functions and classes used across the project.
- Tools: AI Agents that perform specific tasks like querying databases, calling APIs, etc.
The main libraries and tools used in this project are:
- FastAPI
- GraphQL
- Docker
- Docker Compose
- Make
- Pipenv
- Uvicorn
- Datadog
Here are some sample API requests and responses:
Request:
curl -X POST "http://localhost:5050/api/v1/chat/completions" -H "Content-Type: application/json" -d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello, how are you?"}]
}'
Response:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-3.5-turbo",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I am fine, thank you!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 7,
"total_tokens": 16
}
}
Just run the following commands to run OpenWebUI without OAuth:
make down; make up; make up-open-webui
Since the OpenWebUI uses Keycloak on both server side and browser side, you need to create a host mapping for keycloak
.
On Macs, this can be done by adding an entry to /etc/hosts
:
127.0.0.1 keycloak
Then run:
make down; make up; make up-open-webui-auth
We welcome contributions to the project! To contribute, follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and commit them with a clear message.
- Push your changes to your fork.
- Create a pull request to the main repository.
If you encounter any issues, please report them by creating a new issue in the repository's issue tracker.
Create a docker.env
file in the root of the project based on the docker.env.example
file. Update the keys for the functionality/providers you're planning on using.
You can run the tests using the following command:
make tests
Refer to the add_new_agent.md file for detailed instructions on how to add a new AI Agent.
- If you encounter issues with Docker, try restarting the Docker service.
- Ensure that all environment variables are set correctly.
- Check the logs for any error messages and stack traces.