-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from etalab-ia/dev
v0.2.0
- Loading branch information
Showing
25 changed files
with
1,069 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,8 @@ venv/ | |
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
.direnv/ | ||
.envrc | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## 0.2.0 | ||
|
||
### 🚀 Features | ||
|
||
- Use the chat history to build messages compatible with the openai api [{role, content}]. | ||
- Support for reply in thread. | ||
- Improve conversation history management. | ||
- Manage reply in conversation + improved albert messaging. | ||
- Add a minimal system prompt in norag mode | ||
- Improve albert command and response format. | ||
- Add command aliases. | ||
- Add a grist table for user management (implement an minimalistic async grist client) | ||
|
||
### 🐛 Bug Fixes | ||
|
||
- Pyalbert version for gemma-2 support | ||
- Better error management | ||
|
||
### Refacto | ||
|
||
- Github actions (#72) | ||
- Bot commands refactorization | ||
- Add all bot custom messages in a dedicated AlbertMsg classe. | ||
|
||
### Scripts | ||
|
||
- Dump users state list | ||
- Update users table from list | ||
- Send error message demo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
Le code est linté et les imports trié avec [Ruff](https://docs.astral.sh/ruff/) : | ||
```bash | ||
ruff check --fix --select I . | ||
``` | ||
|
||
|
||
Ruff s'intégre dans la plupart des éditeurs de code. Vous pouvez automatiser le linter avec les _hooks_ de _pre-commit_ de git si vous préférez : | ||
```bash | ||
pre-commit install | ||
`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Etalab | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from config import APP_VERSION, COMMAND_PREFIX, Config | ||
|
||
|
||
class AlbertMsg: | ||
common_msg_prefixes = [ | ||
"👋 Bonjour, je suis **Albert**", | ||
"🤖 Configuration actuelle", | ||
"\u26a0\ufe0f **Erreur**", | ||
"\u26a0\ufe0f **Commande inconnue**", | ||
"**La conversation a été remise à zéro**", | ||
"🤖 Albert a échoué", | ||
] | ||
shorts = { | ||
"help": f"Pour retrouver ce message informatif, tapez `{COMMAND_PREFIX}aide`. Pour les geek tapez `{COMMAND_PREFIX}aide -v`.", | ||
"reset": f"Pour ré-initialiser notre conversation, tapez `{COMMAND_PREFIX}reset`", | ||
"conversation": f"Pour activer/désactiver le mode conversation, tapez `{COMMAND_PREFIX}conversation`", | ||
"debug": f"Pour afficher des informations sur la configuration actuelle, `{COMMAND_PREFIX}debug`", | ||
"model": f"Pour modifier le modèle, tapez `{COMMAND_PREFIX}model MODEL_NAME`", | ||
"mode": f"Pour modifier le mode du modèle (c'est-à-dire le modèle de prompt utilisé), tapez `{COMMAND_PREFIX}mode MODE`", | ||
"sources": f"Pour obtenir les sources utilisées pour générer ma dernière réponse, tapez `{COMMAND_PREFIX}sources`", | ||
} | ||
|
||
failed = "🤖 Albert a échoué à répondre. Veuillez réessayez dans un moment." | ||
|
||
reset = "**La conversation a été remise à zéro**. Vous pouvez néanmoins toujours répondre dans un fil de discussion." | ||
|
||
user_not_allowed = "Albert est en phase de test et n'est pas encore disponible pour votre utilisateur. Contactez [email protected] pour demander un accès." | ||
|
||
domain_not_allowed = "Albert n'est pas encore disponible pour votre domaine. Merci de rester en contact, il sera disponible après une phase beta test." | ||
|
||
def error_debug(reason, config): | ||
msg = f"\u26a0\ufe0f **Albert API error**\n\n{reason}\n\n- Albert API URL: {config.albert_api_url}\n- Matrix server: {config.matrix_home_server}" | ||
return msg | ||
|
||
def help(model_url, model_short_name, cmds): | ||
msg = "👋 Bonjour, je suis **Albert**, votre **assistant automatique dédié aux questions légales et administratives** mis à disposition par la **DINUM**. Je suis actuellement en phase de **test**.\n\n" | ||
msg += f"J'utilise le modèle de langage _[{model_short_name}]({model_url})_ et j'ai été alimenté par des bases de connaissances gouvernementales, comme les fiches pratiques de service-public.fr éditées par la Direction de l'information légale et administrative (DILA).\n\n" | ||
msg += "Maintenant que nous avons fait plus connaissance, quelques **règles pour m'utiliser** :\n\n" | ||
msg += "🔮 Ne m'utilisez pas pour élaborer une décision administrative individuelle.\n\n" | ||
msg += "❌ **Ne me transmettez pas** :\n" | ||
msg += "- des **fichiers** (pdf, images, etc.) ;\n" | ||
msg += "- des données permettant de **vous** identifier ou **d'autres personnes** ;\n" | ||
msg += "- des données **confidentielles** ;\n\n" | ||
msg += "Enfin, quelques informations pratiques :\n\n" | ||
msg += "🛠️ **Pour gérer notre conversation** :\n" | ||
msg += "- " + "\n- ".join(cmds) | ||
msg += "\n\n" | ||
msg += "📁 **Sur l'usage des données**\nLes conversations sont stockées de manière anonyme. Elles me permettent de contextualiser les conversations et l'équipe qui me développe les utilise pour m'évaluer et analyser mes performances.\n\n" | ||
msg += "📯 Nous contacter : [email protected]" | ||
|
||
return msg | ||
|
||
def commands(cmds): | ||
msg = "Les commandes spéciales suivantes sont disponibles :\n\n" | ||
msg += "- " + "\n- ".join(cmds) | ||
return msg | ||
|
||
def unknown_command(cmds_msg): | ||
msg = f"\u26a0\ufe0f **Commande inconnue**\n\n{cmds_msg}" | ||
return msg | ||
|
||
def reset_notif(delay_min): | ||
msg = f"Comme vous n'avez pas continué votre conversation avec Albert depuis plus de {delay_min} minutes, **la conversation a été automatiquement remise à zéro**. Vous pouvez néanmoins toujours répondre dans un fil de discussion.\n\n" | ||
msg += "Entrez **!aide** pour obtenir plus d'informatin sur ma paramétrisatiion." | ||
return msg | ||
|
||
def debug(config: Config): | ||
msg = "🤖 Configuration actuelle :\n\n" | ||
msg += f"- Version: {APP_VERSION}\n" | ||
msg += f"- API: {config.albert_api_url}\n" | ||
msg += f"- Model: {config.albert_model}\n" | ||
msg += f"- Mode: {config.albert_mode}\n" | ||
msg += f"- With history: {config.albert_with_history}\n" | ||
return msg |
Oops, something went wrong.