Yannick Lemin commited on
Commit
bfc9491
·
1 Parent(s): 7cf9fb8

moved a few things to environment variables, added requirements.txt

Browse files
Files changed (3) hide show
  1. README.md +48 -48
  2. requirements.txt +8 -0
  3. src/utils/constants.py +8 -6
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: L'Atelier du Fer - Recherche Catalogue
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: App de recherche pour le catalogue de l'Atelier du Fer
12
  ---
13
 
14
- # L'Atelier du Fer - Recherche Catalogue
15
 
16
- Cette application permet de rechercher des articles dans le catalogue de ferronnerie décorative de l'Atelier du Fer. Elle utilise l'intelligence artificielle pour comprendre les descriptions textuelles et analyser les images afin de trouver les articles les plus pertinents.
17
 
18
- ## Fonctionnalités
19
 
20
- ### Pour les clients
21
- - Recherche d'articles par description textuelle
22
- - Recherche d'articles par image
23
- - Recherche combinée (texte + image)
24
- - Affichage des résultats sous forme de vignettes avec image, titre, description, prix et lien vers la page produit
25
 
26
- ### Pour le personnel
27
- - Identification rapide d'un article à partir d'une photo
28
- - Affichage des informations détaillées de l'article (prix, référence, etc.)
29
 
30
- ## Technologies utilisées
31
 
32
  - Python 3.13.3
33
- - Gradio pour l'interface utilisateur
34
- - OpenAI GPT-4.1 pour l'analyse de texte et d'images
35
- - MongoDB Atlas Vector Search pour la recherche vectorielle
36
- - LangChain pour l'orchestration des composants
37
 
38
- ## Installation locale
39
 
40
- 1. Cloner le dépôt :
41
  ```bash
42
- git clone https://github.com/votre-organisation/adf-chatbot2.git
43
  cd adf-chatbot2
44
  ```
45
 
46
- 2. Installer les dépendances avec uv :
47
  ```bash
48
  uv venv
49
- source .venv/bin/activate # Sur Windows: .venv\Scripts\activate
50
  uv pip install -e .
51
  ```
52
 
53
- 3. Créer un fichier `.env` à la racine du projet avec les variables suivantes :
54
  ```
55
- OPENAI_API_KEY=votre_clé_api_openai
56
- MONGODB_URI=votre_uri_mongodb_atlas
57
  ```
58
 
59
- 4. Lancer l'application :
60
  ```bash
61
  python app.py
62
  ```
63
 
64
- ## Déploiement sur Hugging Face Spaces
65
 
66
- 1. Forker ce dépôt sur GitHub
67
- 2. Créer un nouveau Space sur Hugging Face
68
- 3. Sélectionner "GitHub" comme source de code
69
- 4. Sélectionner votre fork du dépôt
70
- 5. Ajouter les secrets suivants dans les paramètres du Space :
71
- - `OPENAI_API_KEY` : Votre clé API OpenAI
72
- - `MONGODB_URI` : Votre URI MongoDB Atlas
73
 
74
- ## Structure du projet
75
 
76
- - `app.py` : Point d'entrée de l'application
77
- - `src/` : Code source de l'application
78
- - `database/` : Module de connexion à la base de données
79
- - `image/` : Module de traitement d'images
80
- - `search/` : Module de recherche vectorielle
81
- - `ui/` : Module d'interface utilisateur Gradio
82
- - `utils/` : Utilitaires et constantes
83
- - `tests/` : Tests unitaires
84
 
85
- ## Exécution des tests
86
 
87
- Pour exécuter tous les tests unitaires :
88
  ```bash
89
  uv run -m unittest discover tests
90
  ```
91
 
92
- ## Licence
93
 
94
- Ce projet est sous licence Apache 2.0. Voir le fichier LICENSE pour plus de détails.
 
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 = "gpt-4.1"
4
- EMBEDDING_MODEL = "text-embedding-3-large"
5
 
6
  # Database
7
- DB_NAME = "adf"
8
- COLLECTION_NAME = "catalog"
9
- ATLAS_VECTOR_SEARCH_INDEX_NAME = "adf_catalog_search_index"
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://via.placeholder.com/150?text=Pas+d'image"
 
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"