django-lucy-assist 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_lucy_assist-0.1.0/MANIFEST.in +23 -0
- django_lucy_assist-0.1.0/PKG-INFO +206 -0
- django_lucy_assist-0.1.0/README.md +163 -0
- django_lucy_assist-0.1.0/django_lucy_assist.egg-info/PKG-INFO +206 -0
- django_lucy_assist-0.1.0/django_lucy_assist.egg-info/SOURCES.txt +48 -0
- django_lucy_assist-0.1.0/django_lucy_assist.egg-info/dependency_links.txt +1 -0
- django_lucy_assist-0.1.0/django_lucy_assist.egg-info/requires.txt +14 -0
- django_lucy_assist-0.1.0/django_lucy_assist.egg-info/top_level.txt +1 -0
- django_lucy_assist-0.1.0/lucy_assist/__init__.py +11 -0
- django_lucy_assist-0.1.0/lucy_assist/admin.py +22 -0
- django_lucy_assist-0.1.0/lucy_assist/apps.py +10 -0
- django_lucy_assist-0.1.0/lucy_assist/conf.py +103 -0
- django_lucy_assist-0.1.0/lucy_assist/constantes.py +120 -0
- django_lucy_assist-0.1.0/lucy_assist/context_processors.py +65 -0
- django_lucy_assist-0.1.0/lucy_assist/migrations/0001_initial.py +92 -0
- django_lucy_assist-0.1.0/lucy_assist/migrations/__init__.py +0 -0
- django_lucy_assist-0.1.0/lucy_assist/models/__init__.py +14 -0
- django_lucy_assist-0.1.0/lucy_assist/models/base.py +54 -0
- django_lucy_assist-0.1.0/lucy_assist/models/configuration.py +175 -0
- django_lucy_assist-0.1.0/lucy_assist/models/conversation.py +54 -0
- django_lucy_assist-0.1.0/lucy_assist/models/message.py +45 -0
- django_lucy_assist-0.1.0/lucy_assist/models/project_context_cache.py +213 -0
- django_lucy_assist-0.1.0/lucy_assist/services/__init__.py +21 -0
- django_lucy_assist-0.1.0/lucy_assist/services/bug_notification_service.py +183 -0
- django_lucy_assist-0.1.0/lucy_assist/services/claude_service.py +417 -0
- django_lucy_assist-0.1.0/lucy_assist/services/context_service.py +350 -0
- django_lucy_assist-0.1.0/lucy_assist/services/crud_service.py +364 -0
- django_lucy_assist-0.1.0/lucy_assist/services/gitlab_service.py +248 -0
- django_lucy_assist-0.1.0/lucy_assist/services/project_context_service.py +412 -0
- django_lucy_assist-0.1.0/lucy_assist/services/tool_executor_service.py +343 -0
- django_lucy_assist-0.1.0/lucy_assist/services/tools_definition.py +229 -0
- django_lucy_assist-0.1.0/lucy_assist/signals.py +25 -0
- django_lucy_assist-0.1.0/lucy_assist/static/lucy_assist/css/lucy-assist.css +160 -0
- django_lucy_assist-0.1.0/lucy_assist/static/lucy_assist/image/icon-lucy.png +0 -0
- django_lucy_assist-0.1.0/lucy_assist/static/lucy_assist/js/lucy-assist.js +824 -0
- django_lucy_assist-0.1.0/lucy_assist/templates/lucy_assist/chatbot_sidebar.html +419 -0
- django_lucy_assist-0.1.0/lucy_assist/templates/lucy_assist/partials/documentation_content.html +107 -0
- django_lucy_assist-0.1.0/lucy_assist/tests/__init__.py +0 -0
- django_lucy_assist-0.1.0/lucy_assist/tests/factories/__init__.py +15 -0
- django_lucy_assist-0.1.0/lucy_assist/tests/factories/lucy_assist_factories.py +109 -0
- django_lucy_assist-0.1.0/lucy_assist/tests/test_lucy_assist.py +186 -0
- django_lucy_assist-0.1.0/lucy_assist/urls.py +36 -0
- django_lucy_assist-0.1.0/lucy_assist/utils/__init__.py +7 -0
- django_lucy_assist-0.1.0/lucy_assist/utils/log_utils.py +59 -0
- django_lucy_assist-0.1.0/lucy_assist/utils/message_utils.py +130 -0
- django_lucy_assist-0.1.0/lucy_assist/utils/token_utils.py +87 -0
- django_lucy_assist-0.1.0/lucy_assist/views/__init__.py +13 -0
- django_lucy_assist-0.1.0/lucy_assist/views/api_views.py +595 -0
- django_lucy_assist-0.1.0/pyproject.toml +110 -0
- django_lucy_assist-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Include templates
|
|
2
|
+
recursive-include lucy_assist/templates *
|
|
3
|
+
|
|
4
|
+
# Include static files
|
|
5
|
+
recursive-include lucy_assist/static *
|
|
6
|
+
|
|
7
|
+
# Include migrations
|
|
8
|
+
recursive-include lucy_assist/migrations *.py
|
|
9
|
+
|
|
10
|
+
# Include documentation
|
|
11
|
+
include README.md
|
|
12
|
+
include LICENSE
|
|
13
|
+
|
|
14
|
+
# Exclude development and test files
|
|
15
|
+
exclude .gitignore
|
|
16
|
+
exclude .pre-commit-config.yaml
|
|
17
|
+
prune tests
|
|
18
|
+
prune .git
|
|
19
|
+
prune .github
|
|
20
|
+
prune __pycache__
|
|
21
|
+
global-exclude *.py[cod]
|
|
22
|
+
global-exclude __pycache__
|
|
23
|
+
global-exclude .DS_Store
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-lucy-assist
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Assistant IA intelligent Revolucy pour outil métier
|
|
5
|
+
Author-email: Revolucy <hello@revolucy.fr>
|
|
6
|
+
Maintainer-email: Maxence <hello@revolucy.fr>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/revolucy/django-lucy-assist
|
|
9
|
+
Project-URL: Documentation, https://github.com/revolucy/django-lucy-assist#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/revolucy/django-lucy-assist.git
|
|
11
|
+
Project-URL: Issues, https://github.com/revolucy/django-lucy-assist/issues
|
|
12
|
+
Keywords: django,chatbot,ai,claude,anthropic,assistant,crm
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Web Environment
|
|
15
|
+
Classifier: Framework :: Django
|
|
16
|
+
Classifier: Framework :: Django :: 4.2
|
|
17
|
+
Classifier: Framework :: Django :: 5.0
|
|
18
|
+
Classifier: Framework :: Django :: 5.1
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Programming Language :: Python
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
Requires-Dist: Django>=4.0
|
|
32
|
+
Requires-Dist: anthropic>=0.20.0
|
|
33
|
+
Requires-Dist: requests>=2.28.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-django>=4.5.0; extra == "dev"
|
|
37
|
+
Requires-Dist: factory-boy>=3.3.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
40
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
41
|
+
Provides-Extra: gitlab
|
|
42
|
+
Requires-Dist: python-gitlab>=3.15.0; extra == "gitlab"
|
|
43
|
+
|
|
44
|
+
# Django Lucy Assist
|
|
45
|
+
|
|
46
|
+
Assistant IA intelligent basé sur Claude d'Anthropic, intégrable dans n'importe quelle application Django.
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install django-lucy-assist
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
### 1. Ajouter l'application à INSTALLED_APPS
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
INSTALLED_APPS = [
|
|
60
|
+
...
|
|
61
|
+
'lucy_assist',
|
|
62
|
+
]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Configurer les variables d'environnement
|
|
66
|
+
|
|
67
|
+
Ajouter dans votre fichier `.env` :
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# ======================================== LUCY ASSIST ========================================
|
|
71
|
+
# Clé API Claude
|
|
72
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
73
|
+
|
|
74
|
+
# Configuration GitLab pour l'analyse de bugs (optionnel)
|
|
75
|
+
GITLAB_URL=https://gitlab.example.com
|
|
76
|
+
GITLAB_TOKEN=glpat-...
|
|
77
|
+
GITLAB_PROJECT_ID=123
|
|
78
|
+
|
|
79
|
+
# SIREN client pour l'API Lucy CRM (Si non présent via le module de retour)
|
|
80
|
+
SIREN_CLIENT=123456789
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Puis dans votre `settings.py` :
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import os
|
|
87
|
+
|
|
88
|
+
# Lucy Assist
|
|
89
|
+
ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY')
|
|
90
|
+
GITLAB_URL = os.getenv('GITLAB_URL')
|
|
91
|
+
GITLAB_TOKEN = os.getenv('GITLAB_TOKEN')
|
|
92
|
+
GITLAB_PROJECT_ID = os.getenv('GITLAB_PROJECT_ID')
|
|
93
|
+
SIREN_CLIENT = os.getenv('SIREN_CLIENT')
|
|
94
|
+
|
|
95
|
+
# Configuration avancée (optionnel)
|
|
96
|
+
LUCY_ASSIST = {
|
|
97
|
+
# Modèle de base personnalisé
|
|
98
|
+
'BASE_MODEL': 'mon_app.models.MonModeleBase',
|
|
99
|
+
# Préfixe des apps du projet pour le mapping modèle -> app
|
|
100
|
+
'PROJECT_APPS_PREFIX': 'apps.',
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 3. Ajouter les URLs
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
# urls.py
|
|
108
|
+
from django.urls import path, include
|
|
109
|
+
|
|
110
|
+
urlpatterns = [
|
|
111
|
+
...
|
|
112
|
+
path('lucy-assist/', include('lucy_assist.urls')),
|
|
113
|
+
]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. Ajouter le context processor
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# settings.py
|
|
120
|
+
TEMPLATES = [
|
|
121
|
+
{
|
|
122
|
+
...
|
|
123
|
+
'OPTIONS': {
|
|
124
|
+
'context_processors': [
|
|
125
|
+
...
|
|
126
|
+
'lucy_assist.context_processors.lucy_assist_context',
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 5. Inclure le template dans votre base.html
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<!-- templates/base.html -->
|
|
137
|
+
{% include 'lucy_assist/chatbot_sidebar.html' %}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 6. Exécuter les migrations
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
python manage.py migrate lucy_assist
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Utilisation
|
|
147
|
+
|
|
148
|
+
Une fois installé et configuré, Lucy Assist apparaîtra automatiquement sur toutes les pages de votre application avec un bouton flottant en bas à droite.
|
|
149
|
+
|
|
150
|
+
### Fonctionnalités
|
|
151
|
+
|
|
152
|
+
- **Chat IA contextuel** : Lucy comprend le contexte de la page actuelle
|
|
153
|
+
- **Actions CRUD** : Lucy peut créer, modifier, rechercher et supprimer des objets
|
|
154
|
+
- **Analyse de bugs** : Connexion à GitLab pour analyser les problèmes signalés
|
|
155
|
+
- **Historique des conversations** : Sauvegarde automatique des conversations
|
|
156
|
+
- **Gestion des tokens** : Suivi de la consommation des tokens Claude
|
|
157
|
+
|
|
158
|
+
## Configuration avancée
|
|
159
|
+
|
|
160
|
+
### Modèle de base personnalisé
|
|
161
|
+
|
|
162
|
+
Si vous utilisez un modèle de base personnalisé avec des champs d'audit (created_date, updated_date, etc.), vous pouvez le configurer :
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
LUCY_ASSIST = {
|
|
166
|
+
'BASE_MODEL': 'mon_app.models.MonModeleBase',
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Personnalisation des questions fréquentes
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
LUCY_ASSIST = {
|
|
174
|
+
'QUESTIONS_FREQUENTES_DEFAULT': [
|
|
175
|
+
"Comment créer un nouveau membre ?",
|
|
176
|
+
"Comment effectuer un paiement ?",
|
|
177
|
+
"Comment exporter des données ?",
|
|
178
|
+
],
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## API
|
|
183
|
+
|
|
184
|
+
Lucy Assist expose plusieurs endpoints API :
|
|
185
|
+
|
|
186
|
+
- `GET /lucy-assist/api/conversations/` - Liste des conversations
|
|
187
|
+
- `POST /lucy-assist/api/conversations/` - Créer une conversation
|
|
188
|
+
- `GET /lucy-assist/api/conversations/<id>/` - Détail d'une conversation
|
|
189
|
+
- `POST /lucy-assist/api/conversations/<id>/messages/` - Ajouter un message
|
|
190
|
+
- `POST /lucy-assist/api/conversations/<id>/completion/` - Générer une réponse (streaming)
|
|
191
|
+
- `GET /lucy-assist/api/tokens/status/` - Statut des tokens
|
|
192
|
+
|
|
193
|
+
## Licence
|
|
194
|
+
|
|
195
|
+
[Revolucy](https://www.revolucy.fr)
|
|
196
|
+
|
|
197
|
+
## Versionning
|
|
198
|
+
|
|
199
|
+
- V1.0.0 | Création du module Lucy
|
|
200
|
+
|
|
201
|
+
## Déploiement Pypi
|
|
202
|
+
|
|
203
|
+
1. `pip install build twine`
|
|
204
|
+
2. `python -m build`
|
|
205
|
+
3. `python -m twine upload dist/*`
|
|
206
|
+
4. Indiquer le token présent dans 1Password
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Django Lucy Assist
|
|
2
|
+
|
|
3
|
+
Assistant IA intelligent basé sur Claude d'Anthropic, intégrable dans n'importe quelle application Django.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install django-lucy-assist
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
### 1. Ajouter l'application à INSTALLED_APPS
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
INSTALLED_APPS = [
|
|
17
|
+
...
|
|
18
|
+
'lucy_assist',
|
|
19
|
+
]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 2. Configurer les variables d'environnement
|
|
23
|
+
|
|
24
|
+
Ajouter dans votre fichier `.env` :
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# ======================================== LUCY ASSIST ========================================
|
|
28
|
+
# Clé API Claude
|
|
29
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
30
|
+
|
|
31
|
+
# Configuration GitLab pour l'analyse de bugs (optionnel)
|
|
32
|
+
GITLAB_URL=https://gitlab.example.com
|
|
33
|
+
GITLAB_TOKEN=glpat-...
|
|
34
|
+
GITLAB_PROJECT_ID=123
|
|
35
|
+
|
|
36
|
+
# SIREN client pour l'API Lucy CRM (Si non présent via le module de retour)
|
|
37
|
+
SIREN_CLIENT=123456789
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Puis dans votre `settings.py` :
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import os
|
|
44
|
+
|
|
45
|
+
# Lucy Assist
|
|
46
|
+
ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY')
|
|
47
|
+
GITLAB_URL = os.getenv('GITLAB_URL')
|
|
48
|
+
GITLAB_TOKEN = os.getenv('GITLAB_TOKEN')
|
|
49
|
+
GITLAB_PROJECT_ID = os.getenv('GITLAB_PROJECT_ID')
|
|
50
|
+
SIREN_CLIENT = os.getenv('SIREN_CLIENT')
|
|
51
|
+
|
|
52
|
+
# Configuration avancée (optionnel)
|
|
53
|
+
LUCY_ASSIST = {
|
|
54
|
+
# Modèle de base personnalisé
|
|
55
|
+
'BASE_MODEL': 'mon_app.models.MonModeleBase',
|
|
56
|
+
# Préfixe des apps du projet pour le mapping modèle -> app
|
|
57
|
+
'PROJECT_APPS_PREFIX': 'apps.',
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Ajouter les URLs
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# urls.py
|
|
65
|
+
from django.urls import path, include
|
|
66
|
+
|
|
67
|
+
urlpatterns = [
|
|
68
|
+
...
|
|
69
|
+
path('lucy-assist/', include('lucy_assist.urls')),
|
|
70
|
+
]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4. Ajouter le context processor
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
# settings.py
|
|
77
|
+
TEMPLATES = [
|
|
78
|
+
{
|
|
79
|
+
...
|
|
80
|
+
'OPTIONS': {
|
|
81
|
+
'context_processors': [
|
|
82
|
+
...
|
|
83
|
+
'lucy_assist.context_processors.lucy_assist_context',
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 5. Inclure le template dans votre base.html
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<!-- templates/base.html -->
|
|
94
|
+
{% include 'lucy_assist/chatbot_sidebar.html' %}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 6. Exécuter les migrations
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
python manage.py migrate lucy_assist
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Utilisation
|
|
104
|
+
|
|
105
|
+
Une fois installé et configuré, Lucy Assist apparaîtra automatiquement sur toutes les pages de votre application avec un bouton flottant en bas à droite.
|
|
106
|
+
|
|
107
|
+
### Fonctionnalités
|
|
108
|
+
|
|
109
|
+
- **Chat IA contextuel** : Lucy comprend le contexte de la page actuelle
|
|
110
|
+
- **Actions CRUD** : Lucy peut créer, modifier, rechercher et supprimer des objets
|
|
111
|
+
- **Analyse de bugs** : Connexion à GitLab pour analyser les problèmes signalés
|
|
112
|
+
- **Historique des conversations** : Sauvegarde automatique des conversations
|
|
113
|
+
- **Gestion des tokens** : Suivi de la consommation des tokens Claude
|
|
114
|
+
|
|
115
|
+
## Configuration avancée
|
|
116
|
+
|
|
117
|
+
### Modèle de base personnalisé
|
|
118
|
+
|
|
119
|
+
Si vous utilisez un modèle de base personnalisé avec des champs d'audit (created_date, updated_date, etc.), vous pouvez le configurer :
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
LUCY_ASSIST = {
|
|
123
|
+
'BASE_MODEL': 'mon_app.models.MonModeleBase',
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Personnalisation des questions fréquentes
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
LUCY_ASSIST = {
|
|
131
|
+
'QUESTIONS_FREQUENTES_DEFAULT': [
|
|
132
|
+
"Comment créer un nouveau membre ?",
|
|
133
|
+
"Comment effectuer un paiement ?",
|
|
134
|
+
"Comment exporter des données ?",
|
|
135
|
+
],
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## API
|
|
140
|
+
|
|
141
|
+
Lucy Assist expose plusieurs endpoints API :
|
|
142
|
+
|
|
143
|
+
- `GET /lucy-assist/api/conversations/` - Liste des conversations
|
|
144
|
+
- `POST /lucy-assist/api/conversations/` - Créer une conversation
|
|
145
|
+
- `GET /lucy-assist/api/conversations/<id>/` - Détail d'une conversation
|
|
146
|
+
- `POST /lucy-assist/api/conversations/<id>/messages/` - Ajouter un message
|
|
147
|
+
- `POST /lucy-assist/api/conversations/<id>/completion/` - Générer une réponse (streaming)
|
|
148
|
+
- `GET /lucy-assist/api/tokens/status/` - Statut des tokens
|
|
149
|
+
|
|
150
|
+
## Licence
|
|
151
|
+
|
|
152
|
+
[Revolucy](https://www.revolucy.fr)
|
|
153
|
+
|
|
154
|
+
## Versionning
|
|
155
|
+
|
|
156
|
+
- V1.0.0 | Création du module Lucy
|
|
157
|
+
|
|
158
|
+
## Déploiement Pypi
|
|
159
|
+
|
|
160
|
+
1. `pip install build twine`
|
|
161
|
+
2. `python -m build`
|
|
162
|
+
3. `python -m twine upload dist/*`
|
|
163
|
+
4. Indiquer le token présent dans 1Password
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-lucy-assist
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Assistant IA intelligent Revolucy pour outil métier
|
|
5
|
+
Author-email: Revolucy <hello@revolucy.fr>
|
|
6
|
+
Maintainer-email: Maxence <hello@revolucy.fr>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/revolucy/django-lucy-assist
|
|
9
|
+
Project-URL: Documentation, https://github.com/revolucy/django-lucy-assist#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/revolucy/django-lucy-assist.git
|
|
11
|
+
Project-URL: Issues, https://github.com/revolucy/django-lucy-assist/issues
|
|
12
|
+
Keywords: django,chatbot,ai,claude,anthropic,assistant,crm
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Web Environment
|
|
15
|
+
Classifier: Framework :: Django
|
|
16
|
+
Classifier: Framework :: Django :: 4.2
|
|
17
|
+
Classifier: Framework :: Django :: 5.0
|
|
18
|
+
Classifier: Framework :: Django :: 5.1
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Programming Language :: Python
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
Requires-Dist: Django>=4.0
|
|
32
|
+
Requires-Dist: anthropic>=0.20.0
|
|
33
|
+
Requires-Dist: requests>=2.28.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-django>=4.5.0; extra == "dev"
|
|
37
|
+
Requires-Dist: factory-boy>=3.3.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
40
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
41
|
+
Provides-Extra: gitlab
|
|
42
|
+
Requires-Dist: python-gitlab>=3.15.0; extra == "gitlab"
|
|
43
|
+
|
|
44
|
+
# Django Lucy Assist
|
|
45
|
+
|
|
46
|
+
Assistant IA intelligent basé sur Claude d'Anthropic, intégrable dans n'importe quelle application Django.
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install django-lucy-assist
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
### 1. Ajouter l'application à INSTALLED_APPS
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
INSTALLED_APPS = [
|
|
60
|
+
...
|
|
61
|
+
'lucy_assist',
|
|
62
|
+
]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Configurer les variables d'environnement
|
|
66
|
+
|
|
67
|
+
Ajouter dans votre fichier `.env` :
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# ======================================== LUCY ASSIST ========================================
|
|
71
|
+
# Clé API Claude
|
|
72
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
73
|
+
|
|
74
|
+
# Configuration GitLab pour l'analyse de bugs (optionnel)
|
|
75
|
+
GITLAB_URL=https://gitlab.example.com
|
|
76
|
+
GITLAB_TOKEN=glpat-...
|
|
77
|
+
GITLAB_PROJECT_ID=123
|
|
78
|
+
|
|
79
|
+
# SIREN client pour l'API Lucy CRM (Si non présent via le module de retour)
|
|
80
|
+
SIREN_CLIENT=123456789
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Puis dans votre `settings.py` :
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import os
|
|
87
|
+
|
|
88
|
+
# Lucy Assist
|
|
89
|
+
ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY')
|
|
90
|
+
GITLAB_URL = os.getenv('GITLAB_URL')
|
|
91
|
+
GITLAB_TOKEN = os.getenv('GITLAB_TOKEN')
|
|
92
|
+
GITLAB_PROJECT_ID = os.getenv('GITLAB_PROJECT_ID')
|
|
93
|
+
SIREN_CLIENT = os.getenv('SIREN_CLIENT')
|
|
94
|
+
|
|
95
|
+
# Configuration avancée (optionnel)
|
|
96
|
+
LUCY_ASSIST = {
|
|
97
|
+
# Modèle de base personnalisé
|
|
98
|
+
'BASE_MODEL': 'mon_app.models.MonModeleBase',
|
|
99
|
+
# Préfixe des apps du projet pour le mapping modèle -> app
|
|
100
|
+
'PROJECT_APPS_PREFIX': 'apps.',
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 3. Ajouter les URLs
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
# urls.py
|
|
108
|
+
from django.urls import path, include
|
|
109
|
+
|
|
110
|
+
urlpatterns = [
|
|
111
|
+
...
|
|
112
|
+
path('lucy-assist/', include('lucy_assist.urls')),
|
|
113
|
+
]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. Ajouter le context processor
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# settings.py
|
|
120
|
+
TEMPLATES = [
|
|
121
|
+
{
|
|
122
|
+
...
|
|
123
|
+
'OPTIONS': {
|
|
124
|
+
'context_processors': [
|
|
125
|
+
...
|
|
126
|
+
'lucy_assist.context_processors.lucy_assist_context',
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 5. Inclure le template dans votre base.html
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<!-- templates/base.html -->
|
|
137
|
+
{% include 'lucy_assist/chatbot_sidebar.html' %}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 6. Exécuter les migrations
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
python manage.py migrate lucy_assist
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Utilisation
|
|
147
|
+
|
|
148
|
+
Une fois installé et configuré, Lucy Assist apparaîtra automatiquement sur toutes les pages de votre application avec un bouton flottant en bas à droite.
|
|
149
|
+
|
|
150
|
+
### Fonctionnalités
|
|
151
|
+
|
|
152
|
+
- **Chat IA contextuel** : Lucy comprend le contexte de la page actuelle
|
|
153
|
+
- **Actions CRUD** : Lucy peut créer, modifier, rechercher et supprimer des objets
|
|
154
|
+
- **Analyse de bugs** : Connexion à GitLab pour analyser les problèmes signalés
|
|
155
|
+
- **Historique des conversations** : Sauvegarde automatique des conversations
|
|
156
|
+
- **Gestion des tokens** : Suivi de la consommation des tokens Claude
|
|
157
|
+
|
|
158
|
+
## Configuration avancée
|
|
159
|
+
|
|
160
|
+
### Modèle de base personnalisé
|
|
161
|
+
|
|
162
|
+
Si vous utilisez un modèle de base personnalisé avec des champs d'audit (created_date, updated_date, etc.), vous pouvez le configurer :
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
LUCY_ASSIST = {
|
|
166
|
+
'BASE_MODEL': 'mon_app.models.MonModeleBase',
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Personnalisation des questions fréquentes
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
LUCY_ASSIST = {
|
|
174
|
+
'QUESTIONS_FREQUENTES_DEFAULT': [
|
|
175
|
+
"Comment créer un nouveau membre ?",
|
|
176
|
+
"Comment effectuer un paiement ?",
|
|
177
|
+
"Comment exporter des données ?",
|
|
178
|
+
],
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## API
|
|
183
|
+
|
|
184
|
+
Lucy Assist expose plusieurs endpoints API :
|
|
185
|
+
|
|
186
|
+
- `GET /lucy-assist/api/conversations/` - Liste des conversations
|
|
187
|
+
- `POST /lucy-assist/api/conversations/` - Créer une conversation
|
|
188
|
+
- `GET /lucy-assist/api/conversations/<id>/` - Détail d'une conversation
|
|
189
|
+
- `POST /lucy-assist/api/conversations/<id>/messages/` - Ajouter un message
|
|
190
|
+
- `POST /lucy-assist/api/conversations/<id>/completion/` - Générer une réponse (streaming)
|
|
191
|
+
- `GET /lucy-assist/api/tokens/status/` - Statut des tokens
|
|
192
|
+
|
|
193
|
+
## Licence
|
|
194
|
+
|
|
195
|
+
[Revolucy](https://www.revolucy.fr)
|
|
196
|
+
|
|
197
|
+
## Versionning
|
|
198
|
+
|
|
199
|
+
- V1.0.0 | Création du module Lucy
|
|
200
|
+
|
|
201
|
+
## Déploiement Pypi
|
|
202
|
+
|
|
203
|
+
1. `pip install build twine`
|
|
204
|
+
2. `python -m build`
|
|
205
|
+
3. `python -m twine upload dist/*`
|
|
206
|
+
4. Indiquer le token présent dans 1Password
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
django_lucy_assist.egg-info/PKG-INFO
|
|
5
|
+
django_lucy_assist.egg-info/SOURCES.txt
|
|
6
|
+
django_lucy_assist.egg-info/dependency_links.txt
|
|
7
|
+
django_lucy_assist.egg-info/requires.txt
|
|
8
|
+
django_lucy_assist.egg-info/top_level.txt
|
|
9
|
+
lucy_assist/__init__.py
|
|
10
|
+
lucy_assist/admin.py
|
|
11
|
+
lucy_assist/apps.py
|
|
12
|
+
lucy_assist/conf.py
|
|
13
|
+
lucy_assist/constantes.py
|
|
14
|
+
lucy_assist/context_processors.py
|
|
15
|
+
lucy_assist/signals.py
|
|
16
|
+
lucy_assist/urls.py
|
|
17
|
+
lucy_assist/migrations/0001_initial.py
|
|
18
|
+
lucy_assist/migrations/__init__.py
|
|
19
|
+
lucy_assist/models/__init__.py
|
|
20
|
+
lucy_assist/models/base.py
|
|
21
|
+
lucy_assist/models/configuration.py
|
|
22
|
+
lucy_assist/models/conversation.py
|
|
23
|
+
lucy_assist/models/message.py
|
|
24
|
+
lucy_assist/models/project_context_cache.py
|
|
25
|
+
lucy_assist/services/__init__.py
|
|
26
|
+
lucy_assist/services/bug_notification_service.py
|
|
27
|
+
lucy_assist/services/claude_service.py
|
|
28
|
+
lucy_assist/services/context_service.py
|
|
29
|
+
lucy_assist/services/crud_service.py
|
|
30
|
+
lucy_assist/services/gitlab_service.py
|
|
31
|
+
lucy_assist/services/project_context_service.py
|
|
32
|
+
lucy_assist/services/tool_executor_service.py
|
|
33
|
+
lucy_assist/services/tools_definition.py
|
|
34
|
+
lucy_assist/static/lucy_assist/css/lucy-assist.css
|
|
35
|
+
lucy_assist/static/lucy_assist/image/icon-lucy.png
|
|
36
|
+
lucy_assist/static/lucy_assist/js/lucy-assist.js
|
|
37
|
+
lucy_assist/templates/lucy_assist/chatbot_sidebar.html
|
|
38
|
+
lucy_assist/templates/lucy_assist/partials/documentation_content.html
|
|
39
|
+
lucy_assist/tests/__init__.py
|
|
40
|
+
lucy_assist/tests/test_lucy_assist.py
|
|
41
|
+
lucy_assist/tests/factories/__init__.py
|
|
42
|
+
lucy_assist/tests/factories/lucy_assist_factories.py
|
|
43
|
+
lucy_assist/utils/__init__.py
|
|
44
|
+
lucy_assist/utils/log_utils.py
|
|
45
|
+
lucy_assist/utils/message_utils.py
|
|
46
|
+
lucy_assist/utils/token_utils.py
|
|
47
|
+
lucy_assist/views/__init__.py
|
|
48
|
+
lucy_assist/views/api_views.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lucy_assist
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Lucy Assist - Assistant IA intelligent pour applications Django.
|
|
3
|
+
|
|
4
|
+
Un chatbot IA basé sur Claude d'Anthropic, intégrable dans n'importe quelle
|
|
5
|
+
application Django pour fournir une assistance contextuelle aux utilisateurs.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = '0.1.0'
|
|
9
|
+
__author__ = 'Revolucy'
|
|
10
|
+
|
|
11
|
+
default_app_config = 'lucy_assist.apps.LucyAssistConfig'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
|
|
3
|
+
from lucy_assist.models import Conversation, Message, ConfigurationLucyAssist
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BlockMessage(admin.StackedInline):
|
|
7
|
+
model = Message
|
|
8
|
+
extra = 1
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@admin.register(Conversation)
|
|
12
|
+
class ConversationAdmin(admin.ModelAdmin):
|
|
13
|
+
list_display = ('id', 'utilisateur', 'titre', 'created_date', 'is_active')
|
|
14
|
+
list_filter = ('is_active', 'created_date')
|
|
15
|
+
search_fields = ('utilisateur__email', 'titre')
|
|
16
|
+
ordering = ('-created_date',)
|
|
17
|
+
inlines = [BlockMessage]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@admin.register(ConfigurationLucyAssist)
|
|
21
|
+
class ConfigurationLucyAssistAdmin(admin.ModelAdmin):
|
|
22
|
+
list_display = ('id', 'tokens_disponibles', 'prix_par_million_tokens', 'updated_date')
|