A robust backend service designed for the management and versioning of LLM Prompt Templates.
573
PromptLib API is a specialized backend service designed to streamline the management of LLM prompt templates. It provides a centralized repository for creating, versioning, and retrieving prompts, allowing developers to decouple prompt engineering from core application logic.
The repository uses a containerized multi-service architecture:
promptlib_api): The core engine that handles prompt logic, variable injection, and template distribution. It connects to MongoDB using the credentials defined in the environment.promptlib_mongodb): A MongoDB instance that provides persistent storage for all your prompt templates.Create a file named .env in your root directory and paste the following configuration:
# MongoDB Configuration
MONGODB_USER=admin
MONGODB_PASSWORD=password123
MONGODB_DATABASE=promptlib
MONGODB_LOCAL_PORT=27018
# API Configuration
DATABASE_HOST=mongodb
FRONTEND_URL=http://localhost:3001
Ensure your docker-compose.yml is set up to consume these variables:
version: '3.8'
services:
mongodb:
image: mongo:latest
container_name: promptlib_mongodb
restart: always
ports:
- "${MONGODB_LOCAL_PORT:-27018}:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGODB_DATABASE}
volumes:
- mongodb_data:/data/db
networks:
- prompt_network
api:
image: thuanvu301103/promptlib-api:latest
container_name: promptlib_api
restart: always
ports:
- "3000:3000"
environment:
DATABASE_HOST: ${DATABASE_HOST}
MONGODB_USER: ${MONGODB_USER}
MONGODB_PASSWORD: ${MONGODB_PASSWORD}
MONGODB_DATABASE: ${MONGODB_DATABASE}
FRONTEND_URL: ${FRONTEND_URL}
depends_on:
- mongodb
networks:
- prompt_network
networks:
prompt_network:
driver: bridge
volumes:
mongodb_data:
To build and start the entire stack:
# Build and start in detached mode
docker-compose up --build -d
http://localhost:3000.http://localhost:3000/api.docker logs -f promptlib_api to see real-time interaction between the API and MongoDB.mongodb_data volume. It will survive a docker-compose down, but will be deleted if you use docker-compose down -v.FRONTEND_URL environment variable is used to configure CORS in the FastAPI app, allowing your frontend (on port 3001) to communicate with this API.MONGODB_PASSWORD for any environment beyond local development.Content type
Image
Digest
sha256:aeaafe648…
Size
89.3 MB
Last updated
7 months ago
docker pull thuanvu301103/promptlib-api