From 326158f680da8012d8ad61af01b3e0a75339abd6 Mon Sep 17 00:00:00 2001 From: gilles Date: Sun, 22 Feb 2026 13:11:34 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20noms=20PlantNet=20en=20fran=C3=A7ais=20(?= =?UTF-8?q?lang=3Dfr)=20+=20sauvegarde=20image=20syst=C3=A9matique=20sans?= =?UTF-8?q?=20plante=20li=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/services/plantnet.py | 2 +- .../src/components/PhotoIdentifyModal.vue | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/backend/app/services/plantnet.py b/backend/app/services/plantnet.py index f9c6e31..a60cf26 100644 --- a/backend/app/services/plantnet.py +++ b/backend/app/services/plantnet.py @@ -13,7 +13,7 @@ async def identify(image_bytes: bytes, filename: str = "photo.jpg") -> List[dict async with httpx.AsyncClient(timeout=10.0) as client: resp = await client.post( PLANTNET_URL, - params={"api-key": PLANTNET_KEY, "nb-results": 3}, + params={"api-key": PLANTNET_KEY, "nb-results": 3, "lang": "fr"}, files={"images": (filename, image_bytes, "image/jpeg")}, data={"organs": ["auto"]}, ) diff --git a/frontend/src/components/PhotoIdentifyModal.vue b/frontend/src/components/PhotoIdentifyModal.vue index 9e9d697..e027e5b 100644 --- a/frontend/src/components/PhotoIdentifyModal.vue +++ b/frontend/src/components/PhotoIdentifyModal.vue @@ -184,18 +184,17 @@ async function saveAndLink() { '/api/upload', fd, ) - if (linkPlantId.value !== null) { - await axios.post('/api/media', { - entity_type: 'plante', - entity_id: linkPlantId.value, - url: uploaded.url, - thumbnail_url: uploaded.thumbnail_url, - identified_species: r.species, - identified_common: r.common_name, - identified_confidence: r.confidence, - identified_source: source.value, - }) - } + // Toujours sauvegarder : lié à une plante si choisie, sinon dans la bibliothèque générale + await axios.post('/api/media', { + entity_type: linkPlantId.value !== null ? 'plante' : 'bibliotheque', + entity_id: linkPlantId.value ?? 0, + url: uploaded.url, + thumbnail_url: uploaded.thumbnail_url, + identified_species: r.species, + identified_common: r.common_name, + identified_confidence: r.confidence, + identified_source: source.value, + }) emit('identified', { ...r, imageUrl: uploaded.url, plantId: linkPlantId.value }) emit('close') } finally {