Spaces:
Sleeping
Sleeping
title: Prompt Engine | |
emoji: 💻 | |
colorFrom: green | |
colorTo: green | |
sdk: docker | |
pinned: false | |
license: apache-2.0 | |
app_port: 8000 | |
## Overview | |
The **Prompt Engine** project is a take-home assignment for the SmartCat recruitment process. This project comprises two main components: | |
- **Backend**: A REST API that provides functionality to find similar prompts. | |
- **Frontend**: A user interface for interacting with the backend service. | |
### Service Description | |
The service retrieves and displays the 5 most similar prompts to a user’s query. This helps improve user queries by showing related examples from a database of well-curated prompts. | |
## Setup Instructions | |
### Prerequisites | |
Before you start, ensure you have the following tools installed: | |
- `Poetry` | |
- `Docker` | |
### Installation | |
1. **Install Dependencies**: | |
```bash | |
poetry install | |
``` | |
2. **Activate the Virtual Environment**: | |
```bash | |
poetry shell | |
``` | |
### Environment Variables | |
Environment variables are set in the .env file in the root of the repo. | |
### Backend Details | |
The backend API provides the following endpoint: | |
- **Endpoint**: POST /most_similar | |
- **Description**: Accepts a user query and the number of similar prompts to return. | |
### Docker | |
The repository includes a Dockerfile to build and run the backend service. To build the image: | |
```bash | |
poe build | |
``` | |
To start the backend service, run: | |
```bash | |
poe start-backend | |
``` | |
To run both use: | |
```bash | |
poe backend | |
``` | |
This command will build the Docker image and start the service. | |
Note: It takes some time for this service to start. | |
### Deployment | |
The project is integrated with HuggingFace Spaces. The solution is automatically deployed to HuggingFace with every push to the repository. | |
In case you want to set up your own HuggingFace Space, you must create a HF token and add it with: | |
``` | |
git remote set-url origin https://USERNAME:YOUR_ACCESS[email protected]/spaces/USERNAME/REPO_NAME.git | |
``` | |
Also, pay attention to the HF Space parameters at the beginning of this README.md. | |
### User Interface | |
The frontend UI is simple and includes: | |
- A text field for entering the user query. | |
- A slider to specify the number of similar prompts to retrieve | |
To start only the UI service you can run: | |
```bash | |
poe frontend | |
``` | |
Or you can do it with `https://lazarr19-prompt-engine.hf.space` if you prefer to hit the HF Space endpoint. | |