Spaces:
Runtime error
Runtime error
Yannick Lemin
commited on
Commit
·
bfc9491
1
Parent(s):
7cf9fb8
moved a few things to environment variables, added requirements.txt
Browse files- README.md +48 -48
- requirements.txt +8 -0
- src/utils/constants.py +8 -6
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: L'Atelier du Fer -
|
| 3 |
emoji: 🔍
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
|
@@ -8,87 +8,87 @@ sdk_version: 5.29.0
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
-
short_description:
|
| 12 |
---
|
| 13 |
|
| 14 |
-
# L'Atelier du Fer -
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
##
|
| 19 |
|
| 20 |
-
###
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
|
| 26 |
-
###
|
| 27 |
-
-
|
| 28 |
-
-
|
| 29 |
|
| 30 |
-
## Technologies
|
| 31 |
|
| 32 |
- Python 3.13.3
|
| 33 |
-
- Gradio
|
| 34 |
-
- OpenAI GPT-4.1
|
| 35 |
-
- MongoDB Atlas Vector Search
|
| 36 |
-
- LangChain
|
| 37 |
|
| 38 |
-
## Installation
|
| 39 |
|
| 40 |
-
1.
|
| 41 |
```bash
|
| 42 |
-
git clone https://github.com/
|
| 43 |
cd adf-chatbot2
|
| 44 |
```
|
| 45 |
|
| 46 |
-
2.
|
| 47 |
```bash
|
| 48 |
uv venv
|
| 49 |
-
source .venv/bin/activate #
|
| 50 |
uv pip install -e .
|
| 51 |
```
|
| 52 |
|
| 53 |
-
3.
|
| 54 |
```
|
| 55 |
-
OPENAI_API_KEY=
|
| 56 |
-
MONGODB_URI=
|
| 57 |
```
|
| 58 |
|
| 59 |
-
4.
|
| 60 |
```bash
|
| 61 |
python app.py
|
| 62 |
```
|
| 63 |
|
| 64 |
-
##
|
| 65 |
|
| 66 |
-
1.
|
| 67 |
-
2.
|
| 68 |
-
3.
|
| 69 |
-
4.
|
| 70 |
-
5.
|
| 71 |
-
- `OPENAI_API_KEY
|
| 72 |
-
- `MONGODB_URI
|
| 73 |
|
| 74 |
-
## Structure
|
| 75 |
|
| 76 |
-
- `app.py
|
| 77 |
-
- `src
|
| 78 |
-
- `database
|
| 79 |
-
- `image
|
| 80 |
-
- `search
|
| 81 |
-
- `ui
|
| 82 |
-
- `utils
|
| 83 |
-
- `tests
|
| 84 |
|
| 85 |
-
##
|
| 86 |
|
| 87 |
-
|
| 88 |
```bash
|
| 89 |
uv run -m unittest discover tests
|
| 90 |
```
|
| 91 |
|
| 92 |
-
##
|
| 93 |
|
| 94 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
title: L'Atelier du Fer - Catalog Search
|
| 3 |
emoji: 🔍
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
+
short_description: Search app for L'Atelier du Fer catalog
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# L'Atelier du Fer - Catalog Search
|
| 15 |
|
| 16 |
+
This application allows users to search for items in the decorative ironwork catalog of L'Atelier du Fer. It uses artificial intelligence to understand textual descriptions and analyze images to find the most relevant items.
|
| 17 |
|
| 18 |
+
## Features
|
| 19 |
|
| 20 |
+
### For Customers
|
| 21 |
+
- Search for items by text description
|
| 22 |
+
- Search for items by image
|
| 23 |
+
- Combined search (text + image)
|
| 24 |
+
- Display of results as thumbnails with image, title, description, price, and link to the product page
|
| 25 |
|
| 26 |
+
### For Staff
|
| 27 |
+
- Quick identification of an item from a photo
|
| 28 |
+
- Display of detailed item information (price, reference, etc.)
|
| 29 |
|
| 30 |
+
## Technologies Used
|
| 31 |
|
| 32 |
- Python 3.13.3
|
| 33 |
+
- Gradio for the user interface
|
| 34 |
+
- OpenAI GPT-4.1 for text and image analysis
|
| 35 |
+
- MongoDB Atlas Vector Search for vector search
|
| 36 |
+
- LangChain for component orchestration
|
| 37 |
|
| 38 |
+
## Local Installation
|
| 39 |
|
| 40 |
+
1. Clone the repository:
|
| 41 |
```bash
|
| 42 |
+
git clone https://github.com/your-organization/adf-chatbot2.git
|
| 43 |
cd adf-chatbot2
|
| 44 |
```
|
| 45 |
|
| 46 |
+
2. Install dependencies with uv:
|
| 47 |
```bash
|
| 48 |
uv venv
|
| 49 |
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
| 50 |
uv pip install -e .
|
| 51 |
```
|
| 52 |
|
| 53 |
+
3. Create a `.env` file at the root of the project with the following variables:
|
| 54 |
```
|
| 55 |
+
OPENAI_API_KEY=your_openai_api_key
|
| 56 |
+
MONGODB_URI=your_mongodb_atlas_uri
|
| 57 |
```
|
| 58 |
|
| 59 |
+
4. Launch the application:
|
| 60 |
```bash
|
| 61 |
python app.py
|
| 62 |
```
|
| 63 |
|
| 64 |
+
## Deployment on Hugging Face Spaces
|
| 65 |
|
| 66 |
+
1. Fork this repository on GitHub
|
| 67 |
+
2. Create a new Space on Hugging Face
|
| 68 |
+
3. Select "GitHub" as the code source
|
| 69 |
+
4. Select your fork of the repository
|
| 70 |
+
5. Add the following secrets in the Space settings:
|
| 71 |
+
- `OPENAI_API_KEY`: Your OpenAI API key
|
| 72 |
+
- `MONGODB_URI`: Your MongoDB Atlas URI
|
| 73 |
|
| 74 |
+
## Project Structure
|
| 75 |
|
| 76 |
+
- `app.py`: Application entry point
|
| 77 |
+
- `src/`: Application source code
|
| 78 |
+
- `database/`: Database connection module
|
| 79 |
+
- `image/`: Image processing module
|
| 80 |
+
- `search/`: Vector search module
|
| 81 |
+
- `ui/`: Gradio user interface module
|
| 82 |
+
- `utils/`: Utilities and constants
|
| 83 |
+
- `tests/`: Unit tests
|
| 84 |
|
| 85 |
+
## Running Tests
|
| 86 |
|
| 87 |
+
To run all unit tests:
|
| 88 |
```bash
|
| 89 |
uv run -m unittest discover tests
|
| 90 |
```
|
| 91 |
|
| 92 |
+
## License
|
| 93 |
|
| 94 |
+
This project is licensed under Apache 2.0. See the LICENSE file for more details.
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=5.29.0
|
| 2 |
+
langchain>=0.1.0
|
| 3 |
+
langchain-openai>=0.1.0
|
| 4 |
+
langchain-mongodb>=0.1.0
|
| 5 |
+
openai>=1.10.0
|
| 6 |
+
pymongo>=4.6.0
|
| 7 |
+
python-dotenv>=1.0.0
|
| 8 |
+
pillow>=10.0.0
|
src/utils/constants.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
|
|
|
|
|
| 1 |
class Constants:
|
| 2 |
# MODEL NAMES
|
| 3 |
-
MODEL =
|
| 4 |
-
EMBEDDING_MODEL = "
|
| 5 |
|
| 6 |
# Database
|
| 7 |
-
DB_NAME = "
|
| 8 |
-
COLLECTION_NAME = "
|
| 9 |
-
ATLAS_VECTOR_SEARCH_INDEX_NAME = "
|
| 10 |
|
| 11 |
# Search parameters
|
| 12 |
CUSTOMER_SEARCH_LIMIT = 5
|
|
@@ -44,4 +46,4 @@ class Constants:
|
|
| 44 |
UI_PRICE_LABEL = "Prix:"
|
| 45 |
|
| 46 |
# Placeholder image URL for articles without images
|
| 47 |
-
PLACEHOLDER_IMAGE_URL = "https://
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
class Constants:
|
| 4 |
# MODEL NAMES
|
| 5 |
+
MODEL = os.getenv("MODEL")
|
| 6 |
+
EMBEDDING_MODEL = os.getenv("EMBEDDING_MODEL")
|
| 7 |
|
| 8 |
# Database
|
| 9 |
+
DB_NAME = os.getenv("DB_NAME")
|
| 10 |
+
COLLECTION_NAME = os.getenv("COLLECTION_NAME")
|
| 11 |
+
ATLAS_VECTOR_SEARCH_INDEX_NAME = os.getenv("ATLAS_VECTOR_SEARCH_INDEX_NAME")
|
| 12 |
|
| 13 |
# Search parameters
|
| 14 |
CUSTOMER_SEARCH_LIMIT = 5
|
|
|
|
| 46 |
UI_PRICE_LABEL = "Prix:"
|
| 47 |
|
| 48 |
# Placeholder image URL for articles without images
|
| 49 |
+
PLACEHOLDER_IMAGE_URL = "https://placehold.co/150?text=Pas+d'image"
|