This demo will be presented at Google I/O Extended Surabaya 2024
This code requires Python >= 3.9.
pip install -r requirements.txt
Create a file named .env and add the following lines, replacing placeholders with your actual values:
MONGODB_URI=
EMBEDDING_MODEL=
DB_NAME=
DB_COLLECTION=
GEMINI_KEY=
- MONGODB_URI: URI of your MongoDB Atlas instance.
- EMBEDDING_MODEL: Name of the embedding model you're using for text embedding.
- DB_NAME: Name of the database in your MongoDB Atlas.
- DB_COLLECTION: Name of the collection within the database.
- GEMINI_KEY: Your key to access the Gemini API.
Sample data here
Make sure you create a Vector Search Index. Follow this video.
In the serve.py file, you can see that we used the prompt like this. This prompt was enhanced by adding information about your products to it.
Become a sales consultant for a phone store. Customer's question: {query}\nAnswer the question based on the following product information: {source_information}.
- query: Query from the user.
- source_information: Information we get from our database.
The full prompt will look like this:
Become a sales consultant for a phone store. Customer's question: Could you provide more detailed information about the Tracfone Samsung A15 4G?
Answer the question based on the following product information:
1) Name: Tracfone Samsung A15 4G , 128 GB, LTE, 6GB RAM, Black - Prepaid Smartpone [Locked to Tracfone Wireless}, Price: $149.00, Rating: 4.0
2) Name: Tracfone Samsung Galaxy A14, 5G, 64GB, Black - Prepaid Smartphone [Locked to Tracfone], Price: $99.88, Rating: 4.1
3) Name: AT&T Samsung Galaxy A15 5G, 128GB, 4GB RAM, Black - Prepaid Smartphone, Price: $139.00, Rating: 2.9
4) Name: AT&T Samsung Galaxy A15 5G, 128GB, 4GB RAM, Black - Prepaid Smartphone, Price: $139.00, Rating: 2.9
5) Name: Tracfone Motorola moto g 5G (2024), 64GB, Gray - Prepaid Smartphone [Locked to Tracfone], Price: $99.88, Rating: 3.8
6) Name: AT&T Samsung Galaxy A14 5G, 64GB Black - Prepaid Smartphone, Price: $69.88, Rating: 3.7
7) Name: AT&T Samsung Galaxy A14 5G, 64GB Black - Prepaid Smartphone, Price: $69.88, Rating: 3.7
8) Name: Tracfone BLU View 5, 64GB, Black - Prepaid Smartphone [Locked to Tracfone], Price: $29.88, Rating: 3.4
9) Name: Tracfone BLU View 5 Pro, 64GB, Black - Prepaid Smartphone [Locked to Tracfone], Price: $69.88, Rating: 3.8
10) Name: Tracfone Motorola moto g Play 4G (2024), 64GB, Black - Prepaid Smartphone [Locked to Tracfone], Price: $49.88, Rating: 3.8.
The prompt is then fed to LLMs.
python serve.py
Testing on web-app. Link