mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-15 05:04:27 +08:00
fix(mistral): honor dataset language in figure prompts (#18021)
### Summary Refs #17885. Mistral figure enrichment now receives the dataset language through the production parsing path. `by_mistral_ocr` forwards `lang` to `MistralParser.parse_pdf`; the parser stores the normalized language and passes it to the figure-description prompt. Empty or missing values still fall back to English.
This commit is contained in:
@@ -78,6 +78,7 @@ class MistralParser(RAGFlowPdfParser):
|
||||
# Optional tenant vision model (LLMBundle) for figure description;
|
||||
# set from parse_pdf's vision_model kwarg. None -> no enrichment.
|
||||
self.vision_model = None
|
||||
self.language = "English"
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Page image rendering
|
||||
@@ -326,7 +327,8 @@ class MistralParser(RAGFlowPdfParser):
|
||||
|
||||
# vision_llm_chunk expects a PIL Image (it calls img.size / img.save),
|
||||
# not raw bytes — pass the crop directly.
|
||||
desc = vision_llm_chunk(binary=img, vision_model=self.vision_model, prompt=vision_llm_figure_describe_prompt())
|
||||
self.logger.debug("[Mistral OCR] describing figure with language=%s", self.language)
|
||||
desc = vision_llm_chunk(binary=img, vision_model=self.vision_model, prompt=vision_llm_figure_describe_prompt(language=self.language))
|
||||
return (desc or "").strip()
|
||||
except Exception:
|
||||
self.logger.info("[Mistral OCR] figure description skipped", exc_info=True)
|
||||
@@ -457,6 +459,7 @@ class MistralParser(RAGFlowPdfParser):
|
||||
def parse_pdf(self, filepath: str | PathLike[str], binary=None, callback=None, parse_method: str = "raw", from_page: int = 0, to_page: int = MAXIMUM_PAGE_NUMBER, **kwargs) -> tuple[list, list]:
|
||||
# Optional tenant vision model for figure description (best-effort).
|
||||
self.vision_model = kwargs.pop("vision_model", None)
|
||||
self.language = kwargs.pop("lang", None) or "English"
|
||||
|
||||
# Load bytes.
|
||||
if binary is not None:
|
||||
|
||||
Reference in New Issue
Block a user