From 1ba4f3cc025791e1dbf0e523c10733d684ac908a Mon Sep 17 00:00:00 2001 From: oliviamn Date: Mon, 14 Jul 2025 22:24:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9E=84=E5=BB=BAmap?= =?UTF-8?q?ping=E7=9A=84=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile | 4 ++-- backend/app/core/utils/llm_validator.py | 19 +++++++++++++++---- backend/requirements.txt | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index fd0713c..27b0bfc 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \ # Copy requirements first to leverage Docker cache COPY requirements.txt . -RUN pip install huggingface_hub +# RUN pip install huggingface_hub # RUN wget https://github.com/opendatalab/MinerU/raw/master/scripts/download_models_hf.py -O download_models_hf.py # RUN wget https://raw.githubusercontent.com/opendatalab/MinerU/refs/heads/release-1.3.1/scripts/download_models_hf.py -O download_models_hf.py @@ -20,7 +20,7 @@ RUN pip install huggingface_hub RUN pip install --no-cache-dir -r requirements.txt -RUN pip install -U magic-pdf[full] +# RUN pip install -U magic-pdf[full] # Copy the rest of the application diff --git a/backend/app/core/utils/llm_validator.py b/backend/app/core/utils/llm_validator.py index 6846d71..168df91 100644 --- a/backend/app/core/utils/llm_validator.py +++ b/backend/app/core/utils/llm_validator.py @@ -90,9 +90,11 @@ class LLMResponseValidator: """ try: validate(instance=response, schema=cls.ENTITY_EXTRACTION_SCHEMA) + logger.debug(f"Entity extraction validation passed for response: {response}") return True except ValidationError as e: - logger.warning(f"Entity extraction validation error: {e}") + logger.warning(f"Entity extraction validation failed: {e}") + logger.warning(f"Response that failed validation: {response}") return False @classmethod @@ -108,9 +110,16 @@ class LLMResponseValidator: """ try: validate(instance=response, schema=cls.ENTITY_LINKAGE_SCHEMA) - return cls._validate_linkage_content(response) + content_valid = cls._validate_linkage_content(response) + if content_valid: + logger.debug(f"Entity linkage validation passed for response: {response}") + return True + else: + logger.warning(f"Entity linkage content validation failed for response: {response}") + return False except ValidationError as e: - logger.warning(f"Entity linkage validation error: {e}") + logger.warning(f"Entity linkage validation failed: {e}") + logger.warning(f"Response that failed validation: {response}") return False @classmethod @@ -126,9 +135,11 @@ class LLMResponseValidator: """ try: validate(instance=response, schema=cls.REGEX_ENTITY_SCHEMA) + logger.debug(f"Regex entity validation passed for response: {response}") return True except ValidationError as e: - logger.warning(f"Regex entity validation error: {e}") + logger.warning(f"Regex entity validation failed: {e}") + logger.warning(f"Response that failed validation: {response}") return False @classmethod diff --git a/backend/requirements.txt b/backend/requirements.txt index 6ddc25b..515d6be 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -28,5 +28,5 @@ requests==2.28.1 python-docx>=0.8.11 PyPDF2>=3.0.0 pandas>=2.0.0 -magic-pdf[full] +# magic-pdf[full] jsonschema>=4.20.0 \ No newline at end of file