File size: 1,366 Bytes
16d282e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## 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.