Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ All contributing instructions are in [CONTRIBUTING](CONTRIBUTING.md).
- [authors-tools](./services/authors-tools) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-authors-tools.svg)](https://hub.docker.com/r/cnrsinist/ws-authors-tools/)
- [base-line](./services/base-line) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-base-line.svg)](https://hub.docker.com/r/cnrsinist/ws-base-line/)
- [base-line-python](./services/base-line-python) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-base-line-python.svg)](https://hub.docker.com/r/cnrsinist/ws-base-line-python/)
- [baseline-dvc](./services/baseline-dvc) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-baseline-dvc.svg)](https://hub.docker.com/r/cnrsinist/ws-baseline-dvc/)
- [biblio-ref](./services/biblio-ref) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-biblio-ref.svg)](https://hub.docker.com/r/cnrsinist/ws-biblio-ref/)
- [biblio-tools](./services/biblio-tools) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-biblio-tools.svg)](https://hub.docker.com/r/cnrsinist/ws-biblio-tools/)
- [chem-ner](./services/chem-ner) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-chem-ner.svg)](https://hub.docker.com/r/cnrsinist/ws-chem-ner/)
Expand All @@ -51,13 +52,15 @@ All contributing instructions are in [CONTRIBUTING](CONTRIBUTING.md).
- [hal-classifier](./services/hal-classifier) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-hal-classifier.svg)](https://hub.docker.com/r/cnrsinist/ws-hal-classifier/)
- [hiddentext-detect](./services/hiddentext-detect) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-hiddentext-detect.svg)](https://hub.docker.com/r/cnrsinist/ws-hiddentext-detect/)
- [irc3-species](./services/irc3-species) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-irc3-species.svg)](https://hub.docker.com/r/cnrsinist/ws-irc3-species/)
- [loterre-annotate](./services/loterre-annotate) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-loterre-annotate.svg)](https://hub.docker.com/r/cnrsinist/ws-loterre-annotate/)
- [loterre-resolvers](./services/loterre-resolvers) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-loterre-resolvers.svg)](https://hub.docker.com/r/cnrsinist/ws-loterre-resolvers/)
- [ner-tagger](./services/ner-tagger) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-ner-tagger.svg)](https://hub.docker.com/r/cnrsinist/ws-ner-tagger/)
- [nlp-tools2](./services/nlp-tools2) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-nlp-tools2.svg)](https://hub.docker.com/r/cnrsinist/ws-nlp-tools2/)
- [openalex-classification](./services/openalex-classification) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-openalex-classification.svg)](https://hub.docker.com/r/cnrsinist/ws-openalex-classification/)
- [openalex-doctype](./services/openalex-doctype) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-openalex-doctype.svg)](https://hub.docker.com/r/cnrsinist/ws-openalex-doctype/)
- [pdf-text](./services/pdf-text) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-pdf-text.svg)](https://hub.docker.com/r/cnrsinist/ws-pdf-text/)
- [person-ner](./services/person-ner) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-person-ner.svg)](https://hub.docker.com/r/cnrsinist/ws-person-ner/)
- [rag-tools](./services/rag-tools) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-rag-tools.svg)](https://hub.docker.com/r/cnrsinist/ws-rag-tools/)
- [sciencemetrix-classification](./services/sciencemetrix-classification) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-sciencemetrix-classification.svg)](https://hub.docker.com/r/cnrsinist/ws-sciencemetrix-classification/)
- [software-extract](./services/software-extract) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-software-extract.svg)](https://hub.docker.com/r/cnrsinist/ws-software-extract/)
- [tabbr-mine](./services/tabbr-mine) [![Docker Pulls](https://img.shields.io/docker/pulls/cnrsinist/ws-tabbr-mine.svg)](https://hub.docker.com/r/cnrsinist/ws-tabbr-mine/)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"services/openalex-doctype",
"services/pdf-text",
"services/person-ner",
"services/rag-tools",
"services/sciencemetrix-classification",
"services/software-extract",
"services/tabbr-mine",
Expand All @@ -100,4 +101,4 @@
"devDependencies": {
"@types/node": "24.13.3"
}
}
}
7 changes: 7 additions & 0 deletions services/rag-tools/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore all files by default
*

# White list only the required files
!config.json
!v1
!swagger.json
28 changes: 28 additions & 0 deletions services/rag-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# syntax=docker/dockerfile:1.2

FROM cnrsinist/ezs-python-server:py3.9-no24-1.0.14

WORKDIR /app

# Installe torch en version CPU uniquement : le wheel par défaut de pip
# embarque tout le support CUDA (bibliothèques NVIDIA), qui représente à
# lui seul plusieurs Go, totalement inutile sans GPU.
RUN pip install --no-cache-dir torch --extra-index-url https://download.pytorch.org/whl/cpu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪳 : nitpick (non-blocking): ‏On ne fixe pas la version de torch installée.

Ça peut poser un problème de reproductibilité si on reconstruit l'image plus tard.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Par ailleurs, on a une image de base ezs-python-pytorch-server qui installe déjà une version précise de torch.

Certes, elle peut être un peu plus grosse, mais si jamais on l'optimise, rag-tools n'en profitera pas directement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pip install torch et sentence-transformers sans version contrevient à la règle projet (« Dependencies pinned with exact versions in Dockerfile ») suivie partout ailleurs (requests==2.32.5, sentence-transformers==2.2.2, etc.).

Piège supplémentaire : --extra-index-url n'exclut pas PyPI — pip peut résoudre une version plus récente depuis PyPI et récupérer le wheel CUDA que le commentaire cherche justement à éviter.
Épinglez torch==X.Y.Z+cpu avec --index-url (cf. bases/ezs-python-pytorch-server/Dockerfile qui fait exactement cela), et ajoutez requests explicitement comme data-geonames le fait — il n'arrive ici que transitivement via huggingface_hub.

Considérez aussi la base existante cnrsinist/ezs-python-pytorch-server:py3.9-no24-1.1.9 (torch CPU déjà fourni), utilisée par data-corpussummarize et data-geonames.

# sentence-transformers réutilise le torch CPU déjà installé ci-dessus
# (huggingface_hub est déjà une dépendance transitive de
# sentence-transformers/transformers, pas besoin de l'installer à part).
RUN pip install --no-cache-dir sentence-transformers

# Télécharge le modèle, puis nettoie le cache de téléchargement HuggingFace
# dans la MÊME couche : le modèle existe sinon en double (cache + /models),
# soit environ 2,2 Go gaspillés inutilement.
RUN python -c "\
from sentence_transformers import SentenceTransformer; \
model = SentenceTransformer('BAAI/bge-m3'); \
model.save('/models/BAAI/bge-m3')" \
&& rm -rf /root/.cache/huggingface
Comment thread
Luc-Ank marked this conversation as resolved.

WORKDIR /app/public

COPY --chown=daemon:daemon . /app/public/
COPY --chown=daemon:daemon ./config.json /app/config.json
5 changes: 5 additions & 0 deletions services/rag-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ws-rag-tools@0.3.0

Ws to generate embeddings and use those for rag

Ws to generate embeddings and use those for rag
15 changes: 15 additions & 0 deletions services/rag-tools/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"environnement": {
"EZS_TITLE": "Ws to generate embeddings and use those for rag",
"EZS_DESCRIPTION": "Ws to generate embeddings and use those for rag",
"EZS_METRICS": true,
"EZS_CONCURRENCY": 2,
Comment thread
Luc-Ank marked this conversation as resolved.
"EZS_CONTINUE_DELAY": 60,
"EZS_NSHARDS": 32,
"EZS_CACHE": true,
"EZS_VERBOSE": false,
"NODE_OPTIONS": "--max_old_space_size=1024",
"NODE_ENV": "production",
"ILAAS_API_KEY": "real_api_key"
}
}
17 changes: 17 additions & 0 deletions services/rag-tools/examples.http

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☑️ todo:examples.http est toujours le template

La route v1/route/in/camel/case n'existe pas ; aucune des 5 vraies routes n'y est documentée.
C'est le fichier source de la doc et de la génération de tests (generate:example-tests) : un prochain npm run generate:example-tests services/rag-tools écraserait le tests.hurl écrit à la main. Il faudrait y mettre les vraies routes (ou bien supprimer le fichier, pour éviter un écrasement de ce type).

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# These examples can be used directly in VSCode, using HTTPYac extension (anweber.vscode-httpyac)
# They are important, because used to generate the tests.hurl file.

# Décommenter/commenter les lignes voulues pour tester localement
@host=http://localhost:31976
# @host=https://rag-tools.services.istex.fr

###
# @name v1routeInCamelCase
# Description de la route
POST {{host}}/v1/route/in/camel/case?indent=true HTTP/1.1
Content-Type: application/json

[
{ "value": "une valeur typique" },
{ "value": "en json" }
]
37 changes: 37 additions & 0 deletions services/rag-tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"private": true,
"name": "ws-rag-tools",
"version": "0.3.0",
"description": "Ws to generate embeddings and use those for rag",
"repository": {
"type": "git",
"url": "git+https://github.com/Inist-CNRS/web-services.git"
},
"keywords": [
"ezmaster"
],
"author": "Anki Lucas <lucas.anki@inist.fr>",
"license": "MIT",
"bugs": {
"url": "https://github.com/Inist-CNRS/web-services/issues"
},
"homepage": "https://github.com/Inist-CNRS/web-services/#readme",
"scripts": {
"version:insert:readme": "sed -i \"s#\\(${npm_package_name}.\\)\\([\\.a-z0-9]\\+\\)#\\1${npm_package_version}#g\" README.md && git add README.md",
"version:insert:swagger": "sed -i \"s/\\\"version\\\": \\\"[0-9]\\+.[0-9]\\+.[0-9]\\+\\\"/\\\"version\\\": \\\"${npm_package_version}\\\"/g\" swagger.json && git add swagger.json",
"version:insert": "npm run version:insert:readme && npm run version:insert:swagger",
"version:commit": "git commit -a -m \"release ${npm_package_name}@${npm_package_version}\"",
"version:tag": "git tag \"${npm_package_name}@${npm_package_version}\" -m \"${npm_package_name}@${npm_package_version}\"",
"version:push": "git push && git push origin \"${npm_package_name}@${npm_package_version}\"",
"version": "npm run version:insert && npm run version:commit && npm run version:tag",
"postversion": "npm run version:push",
"build:check": "DOCKER_BUILDKIT=1 docker build --check -t cnrsinist/${npm_package_name}:latest . && docker run --rm -i hadolint/hadolint hadolint - < Dockerfile ",
"build:dev": "docker build -t cnrsinist/${npm_package_name}:latest .",
"start:dev": ". ./.env 2> /dev/null; npm run build:dev && docker run -e ILAAS_API_KEY --name dev --rm --detach -p 31976:31976 cnrsinist/${npm_package_name}:latest",
"stop:dev": "docker stop dev",
"build": "docker build -t cnrsinist/${npm_package_name}:${npm_package_version} .",
"start": "docker run --rm -p 31976:31976 cnrsinist/${npm_package_name}:${npm_package_version}",
"publish": "docker push cnrsinist/${npm_package_name}:${npm_package_version}"
},
"avoid-testing": false
}
33 changes: 33 additions & 0 deletions services/rag-tools/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"openapi": "3.0.0",
"info": {
"title": "rag-tools - Ws to generate embeddings and use those for rag",
"description": "Ws to generate embeddings and use those for rag",
"version": "0.3.0",
"termsOfService": "https://services.istex.fr/",
"contact": {
"name": "Inist-CNRS",
"url": "https://www.inist.fr/nous-contacter/"
}
},
"servers": [
{
"x-comment": "Will be automatically completed by the ezs server."
},
{
"url": "http://vptdmservices.intra.inist.fr:49225/",
"description": "Latest version for production",
"#DISABLED#x-profil": "Standard"
}
],
"tags": [
{
"name": "rag-tools",
"description": "Ws to generate embeddings and use those for rag",
"externalDocs": {
"description": "Plus de documentation",
"url": "https://github.com/inist-cnrs/web-services/tree/main/services/rag-tools"
}
}
]
}
13 changes: 13 additions & 0 deletions services/rag-tools/test_rag.json
Comment thread
Luc-Ank marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"id": "rag_test_001",
"value": {
"question": "Quelle est la plus grande planète du système solaire et quelles sont ses principales caractéristiques ?",
"documents": [
"Jupiter est la plus grande planète du système solaire. C'est une planète gazeuse composée principalement d'hydrogène et d'hélium. Elle possède une grande tache rouge qui correspond à une immense tempête observée depuis plusieurs siècles.",
"Saturne est une planète gazeuse connue pour ses magnifiques anneaux composés principalement de glace et de roches. Elle est la sixième planète du système solaire en distance au Soleil.",
"La Terre est la troisième planète du système solaire en partant du Soleil. Elle possède une atmosphère riche en azote et en oxygène. C'est la seule planète connue où la vie existe actuellement."
]
}
}
]
18 changes: 18 additions & 0 deletions services/rag-tools/test_reformulate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"id": "reformulation_test_001",
"value": {
"question": "Et pour Saturne, c'est pareil ?",
"historique": [
{
"role": "user",
"content": "Quelle est la plus grande planète du système solaire et quelles sont ses principales caractéristiques ?"
},
{
"role": "assistant",
"content": "Jupiter est la plus grande planète du système solaire. C'est une planète gazeuse composée principalement d'hydrogène et d'hélium, et elle possède une grande tache rouge correspondant à une immense tempête observée depuis plusieurs siècles [Document 1]."
}
]
}
}
]
26 changes: 26 additions & 0 deletions services/rag-tools/test_vectorize.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"id": "doc_a82f91",
"value": "La Terre est la troisième planète du système solaire en partant du Soleil. Elle possède une atmosphère riche en azote et en oxygène. C'est la seule planète connue où la vie existe actuellement."
},
{
"id": "doc_b71c42",
"value": "Mars est une planète rocheuse située après la Terre dans le système solaire. Elle est surnommée la planète rouge à cause de la présence d'oxyde de fer à sa surface. Mars possède deux petites lunes appelées Phobos et Déimos."
},
{
"id": "doc_c94e35",
"value": "Jupiter est la plus grande planète du système solaire. C'est une planète gazeuse composée principalement d'hydrogène et d'hélium. Elle possède une grande tache rouge qui correspond à une immense tempête observée depuis plusieurs siècles."
},
{
"id": "doc_d28f76",
"value": "Saturne est une planète gazeuse connue pour ses magnifiques anneaux composés principalement de glace et de roches. Elle est la sixième planète du système solaire en distance au Soleil."
},
{
"id": "doc_e63a19",
"value": "Mercure est la planète la plus proche du Soleil. Elle est petite et rocheuse, et sa surface présente de nombreux cratères causés par des impacts d'astéroïdes."
},
{
"id": "doc_f52b88",
"value": "Vénus est la deuxième planète du système solaire. Elle possède une atmosphère très dense composée principalement de dioxyde de carbone. Sa température de surface est extrêmement élevée."
}
]
Loading