From f7e2894856c10d8a1e2d429a7858d9f143c42404 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Wed, 24 Jun 2026 18:11:10 +0900 Subject: Web検索などのツール呼び出しによる応答不能を回避 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ollama_web/tools/pdf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ollama_web/tools/pdf.py') diff --git a/src/ollama_web/tools/pdf.py b/src/ollama_web/tools/pdf.py index 8dc5abb..815c053 100644 --- a/src/ollama_web/tools/pdf.py +++ b/src/ollama_web/tools/pdf.py @@ -2,6 +2,7 @@ from __future__ import annotations +import io from pathlib import Path from pypdf import PdfReader @@ -25,7 +26,7 @@ def extract_pdf_text(data: bytes, max_chars: int | None = None) -> str: limit = max_chars if max_chars is not None and max_chars > 0 else settings.fetch_max_chars try: - reader = PdfReader(stream=data) + reader = PdfReader(stream=io.BytesIO(data)) except Exception as exc: # noqa: BLE001 return f"Failed to parse PDF: {exc}" -- cgit v1.2.3