mirror of
https://github.com/Ladebeze66/llm_ticket3.git
synced 2025-12-13 10:46:51 +01:00
0605-17:04
This commit is contained in:
parent
f39d8e5985
commit
dc7d208480
@ -1,5 +0,0 @@
|
||||
ÉMETTEUR,TYPE,DATE,CONTENU,ÉLÉMENTS VISUELS
|
||||
CLIENT,question,28/03/2025 15:00,Les parties d’ouvrage n’apparaissent plus.,"L'image montre une interface de gestion de chantier fonctionnelle, mais aucune mention explicite des ""parties d’ouvrage"" n'est visible."
|
||||
SUPPORT,réponse,28/03/2025 15:59,"Nous venons d'appliquer un correctif sur votre site, les parties de chantier sont de nouveau accessibles.",L'image confirme que l'interface est accessible avec des champs modifiables et des boutons actifs.
|
||||
CLIENT,question,28/03/2025 16:02,Je ne peux plus accéder à CBAO.,L'image ne montre pas d'erreur d'accès à CBAO.
|
||||
SUPPORT,réponse,28/03/2025 16:06,Votre site est bien accessible à l'adresse suivante : https://nob.brg-lab.com/.,"L'image confirme que le client ""NORD OUEST BETON"" est bien visible dans la liste des laboratoires."
|
||||
|
@ -1,3 +0,0 @@
|
||||
ÉMETTEUR,TYPE,DATE,CONTENU,ÉLÉMENTS VISUELS
|
||||
CLIENT,question,02/04/2025 15:52,Il est impossible de mettre des décimales sur la valeur de CO2/Tonne dans les caractéristiques des granulats de carrière.,Aucune image disponible
|
||||
SUPPORT,réponse,03/04/2025 07:44,Nous constatons bien ce dysfonctionnement. Un ticket a été ouvert auprès de notre équipe de développement. Vous serez automatiquement informé de sa résolution.,Aucune image disponible
|
||||
|
@ -1,4 +0,0 @@
|
||||
ÉMETTEUR,TYPE,DATE,CONTENU,ÉLÉMENTS VISUELS
|
||||
CLIENT,question,03/04/2025 08:34,"Bonjour, Je ne parviens pas à accéder au l’essai au bleu. Merci par avance pour votre. Cordialement",Essai au bleu de méthylène de méthylène (MB) - NF EN 933-9 (02-2022)
|
||||
SUPPORT,réponse,03/04/2025 12:17,"Bonjour, Pouvez-vous vérifier si vous avez bien accès à la page suivante en l'ouvrant dans votre navigateur : https://zk1.brg-lab.com/ Voici ce que vous devriez voir affiché : Si ce n'est pas le cas, pouvez-vous me faire une capture d'écran de ce qui est affiché? Je reste à votre entière disposition pour toute information complémentaire. Cordialement,","Page d'accueil par défaut d'Apache Tomcat avec le message ""It works!"""
|
||||
CLIENT,information,03/04/2025 12:21,"Bonjour, Le problème s’est résolu seul par la suite. Je vous remercie pour votre retour. Bonne journée PS : l’adresse fonctionne",Essai au bleu de méthylène de méthylène (MB) - NF EN 933-9 (02-2022)
|
||||
|
@ -3,9 +3,14 @@ import json
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
|
||||
from ..base_agent import BaseAgent
|
||||
from ..utils.pipeline_logger import sauvegarder_donnees
|
||||
from utils.ocr_cleaner import clean_text_with_profiles # AJOUT
|
||||
from utils.ocr_utils import extraire_texte
|
||||
from utils.image_preparer import prepare_image_for_llama_vision
|
||||
|
||||
|
||||
logger = logging.getLogger("AgentVisionOCR")
|
||||
|
||||
@ -48,50 +53,46 @@ class AgentVisionOCR(BaseAgent):
|
||||
}
|
||||
|
||||
# Prompt OCR optimisé
|
||||
self.system_prompt = ("""You are tasked with performing a high-precision OCR extraction on a partially cropped screenshot of a technical web interface.
|
||||
self.system_prompt = ("""You are tasked with performing an exhaustive OCR extraction on a technical or administrative web interface screenshot.
|
||||
|
||||
GOAL: Extract **all visible and partially visible text** from the image, no matter how small, faint, or cropped. Structure the output clearly to maximize usability.
|
||||
GOAL: Extract **every legible piece of text**, even partially visible, faded, or cropped. Structure your output for clarity. Do not guess, but always report what is visible.
|
||||
|
||||
FORMAT THE OUTPUT AS FOLLOWS:
|
||||
|
||||
---
|
||||
FORMAT USING THESE CATEGORIES:
|
||||
|
||||
1. PAGE STRUCTURE
|
||||
* Page title or headers (e.g., test names, document references)
|
||||
* Section labels or grouping titles
|
||||
* URL or navigation path (if visible)
|
||||
- Page titles
|
||||
- Interface headers or section labels
|
||||
- Navigation bars or visible URLs
|
||||
|
||||
2. LABORATORY DATA
|
||||
* Sample references or IDs (e.g., 25-00075)
|
||||
* Material descriptions (e.g., Sable 0/2 C)
|
||||
* Dates, operators (e.g., 02/04/2025 – BOLLÉE Victor)
|
||||
2. IDENTIFIERS & DATA
|
||||
- Operator or user names
|
||||
- Sample IDs, test references
|
||||
- Materials, dates, batch numbers
|
||||
|
||||
3. UI ELEMENTS
|
||||
* Sidebar text, tabs, and form labels
|
||||
* Buttons (e.g., RAZ, IMPRIMER, ENREGISTRER)
|
||||
* Navigation or functional labels (e.g., ESSAI, SMQ)
|
||||
3. INTERFACE ELEMENTS (MANDATORY SCAN)
|
||||
- Button labels (e.g., RAZ, SAVE)
|
||||
- Tabs (e.g., MATERIAL, OBSERVATIONS)
|
||||
- Sidebars, form field labels
|
||||
|
||||
4. SYSTEM MESSAGES & ERRORS
|
||||
* Any status or error message (e.g., "Impossible de trouver l'adresse IP du serveur de zkt1.brg-lab.com")
|
||||
* Domain names, IPs, server paths
|
||||
4. SYSTEM MESSAGES
|
||||
- Connection or server errors
|
||||
- Domains, IP addresses, server notices
|
||||
|
||||
5. METADATA
|
||||
* Document standards (e.g., NF EN 933-9)
|
||||
* Version/date (e.g., 02-2022)
|
||||
* Any hidden identifiers, codes, or repeated numbers
|
||||
- Standard references (e.g., "NF EN ####-#")
|
||||
- Version numbers, document codes, timestamps
|
||||
|
||||
6. PERIPHERAL / UNCERTAIN TEXT
|
||||
* Logos (e.g., BRG-LAB), watermarks, faded/blurred text
|
||||
* Partially cropped lines: use “[...]” to indicate incomplete text
|
||||
6. UNCLEAR / CROPPED TEXT
|
||||
- Logos, partial lines (use "..." for truncated)
|
||||
- Background/faded elements, labels not fully legible
|
||||
|
||||
RULES:
|
||||
- Do NOT interpret or translate.
|
||||
- Preserve all punctuation, accents, and casing.
|
||||
- Include duplicated text if present multiple times.
|
||||
- Mark unclear/partial lines explicitly.
|
||||
- Report even faint or background text.
|
||||
- Preserve punctuation, case, accents exactly.
|
||||
- Include duplicates if text appears more than once.
|
||||
- Never skip faint or partial text; use "..." if incomplete.
|
||||
- Even if cropped, report as much as possible from any UI region.
|
||||
|
||||
This is a high-precision extraction. Output clean bullet points grouped by section. Stay fully factual.
|
||||
This prompt is designed to generalize across all web portals, technical forms, or reports. Prioritize completeness over certainty. Do not ignore UI components or system messages.
|
||||
""")
|
||||
|
||||
self._configurer_llm()
|
||||
@ -145,14 +146,31 @@ This is a high-precision extraction. Output clean bullet points grouped by secti
|
||||
|
||||
if not hasattr(self.llm, "interroger_avec_image"):
|
||||
raise RuntimeError("Le modèle ne supporte pas l'analyse d'images.")
|
||||
|
||||
# Étape 1 : OCR brut avec Tesseract
|
||||
ocr_brut, _ = extraire_texte(image_path, lang="auto")
|
||||
ocr_brut = ocr_brut.strip()
|
||||
|
||||
# Interroger le modèle
|
||||
response = self.llm.interroger_avec_image(image_path, self.system_prompt)
|
||||
# Étape 2 : Enrichissement du prompt
|
||||
if ocr_brut and len(ocr_brut) > 30:
|
||||
contexte_ocr_brut = f"\n\nNote: the following raw text was detected with a traditional OCR tool. It may be incomplete or inaccurate. Use it to guide or validate your structured output:\n---\n{ocr_brut[:1000]}\n---\n"
|
||||
else:
|
||||
contexte_ocr_brut = ""
|
||||
|
||||
prompt_avec_contexte = self.system_prompt + contexte_ocr_brut
|
||||
|
||||
# ✅ Étape 3 : Préparation de l'image pour le modèle Vision
|
||||
image_stem = Path(image_path).stem
|
||||
vision_ready_path = os.path.join("debug_ocr", f"vision_ready_{image_stem}.png")
|
||||
prepare_image_for_llama_vision(image_path, vision_ready_path)
|
||||
|
||||
# Étape 4 : Appel au modèle avec image traitée
|
||||
response = self.llm.interroger_avec_image(vision_ready_path, prompt_avec_contexte)
|
||||
|
||||
if not response or "i cannot" in response.lower():
|
||||
raise ValueError("Réponse vide ou invalide du modèle")
|
||||
|
||||
cleaned_text = response.strip()
|
||||
cleaned_text = clean_text_with_profiles(response.strip(), active_profiles=("ocr",))
|
||||
|
||||
model_name = getattr(self.llm, "pipeline_normalized_name",
|
||||
getattr(self.llm, "modele", "llama3-vision-90b-instruct"))
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
OCR Langue: fra
|
||||
Langue détectée: fr
|
||||
--------------------------------------------------
|
||||
C3 giraudbrg-lobicom/BRG-LAB/PAGE programmetssai/zEAAAHEVNGOAA
|
||||
|
||||
BRGLAS CD Béton CD Foumasew tubo © Masse
|
||||
|
||||
Echantillion n° 25-0007 éceptianné le 02/04/2025 pr BOLLÉE Victor prélevi le 02/04/2025 por BOLLEE Victor n° péédéwement 25-00078
|
||||
Matériau Sable 0/20 CARRIERE ADCEG
|
||||
|
||||
[vEssu JEMmarme |[ M Porrouo || onservanons ][<suo ][V hisromou
|
||||
|
||||
posait. de 11 e ‘ z2k1.brg-lab.com
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 103 KiB |
@ -1424,7 +1424,7 @@ Texte extrait:
|
||||
|
||||
\* "Fournisseur Labo:" label with dropdown menu (right side)
|
||||
|
||||
\- URL/path: zkt1.brg-lab.com (from the error message at the bottom) [](https://zkt1.brg-lab.com)
|
||||
\- URL/path: zkt1.brg-lab.com (from the error message at the bottom) [](https://zk1.brg-lab.com)
|
||||
|
||||
|
||||
|
||||
@ -1472,7 +1472,7 @@ Texte extrait:
|
||||
|
||||
\- Status/error message at the bottom of the page:
|
||||
|
||||
Impossible de trouver l'adresse IP du serveur zkt1.brg-lab.com.
|
||||
Impossible de trouver l'adresse IP du serveur zk1.brg-lab.com.
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user