|
## README for `Content Base Filtering` Feature |
|
|
|
### Overview |
|
This FastAPI application performs content-based filtering using embeddings from a serialized dataset. |
|
|
|
### Requirements |
|
To run this application, you need to install the dependencies listed in `requirements.txt`. Use the following command: |
|
```bash |
|
pip install -r requirements.txt |
|
``` |
|
|
|
### Data |
|
The application uses a serialized dataset stored in `data_compressed.pkl`. This file contains embeddings and IDs. To deserialize this file, use the `joblib` library as shown in the code: |
|
```python |
|
embd_id = joblib.load('data_compressed.pkl') |
|
``` |
|
|
|
### API |
|
The application exposes a single endpoint `/search` that accepts a JSON body with a `user_search_query` field. |
|
|
|
**Input:** |
|
```json |
|
{ |
|
"user_search_query": "user search query here" |
|
} |
|
``` |
|
|
|
**Output:** |
|
A list of original IDs of the listings that match the search query. |
|
|
|
### Running the Application |
|
To run the application, use the following command: |
|
```bash |
|
uvicorn content_base_filtering:app --host 0.0.0.0 --port 8000 |
|
``` |
|
|
|
### Usage |
|
1. Send a POST request to `http://localhost:8000/search` with a JSON body containing your search query. |
|
2. The application will return a list of original IDs of the listings that match the search query. |
|
|
|
Note: Make sure to replace the `openai.api_key` and `openai.api_base` variables with your actual OpenAI API credentials. |