From d1d361797893f01aedd07969e6200d23b89f719e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Wed, 3 May 2023 11:51:11 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20fix:=20take=20last=20matching=20blo?= =?UTF-8?q?ck=20and=20support=20pdf=20multi=20media?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/options/generate/generator.py | 6 +++--- src/options/generate/static_files/microservice/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/options/generate/generator.py b/src/options/generate/generator.py index c463db2..2710691 100644 --- a/src/options/generate/generator.py +++ b/src/options/generate/generator.py @@ -47,9 +47,9 @@ class Generator: def extract_content_from_result(self, plain_text, file_name, match_single_block=False, can_contain_code_block=True): optional_line_break = '\n' if can_contain_code_block else '' # the \n at the end makes sure that ``` within the generated code is not matched because it is not right before a line break pattern = fr"\*?\*?{file_name}\*?\*?\n```(?:\w+\n)?([\s\S]*?){optional_line_break}```" - match = re.search(pattern, plain_text, re.MULTILINE) - if match: - return match.group(1).strip() + matches = re.findall(pattern, plain_text, re.MULTILINE) + if matches: + return matches[-1].strip() elif match_single_block: # Check for a single code block single_code_block_pattern = r"```(?:\w+\n)?([\s\S]*?)```" diff --git a/src/options/generate/static_files/microservice/Dockerfile b/src/options/generate/static_files/microservice/Dockerfile index 29805eb..7822c80 100644 --- a/src/options/generate/static_files/microservice/Dockerfile +++ b/src/options/generate/static_files/microservice/Dockerfile @@ -2,7 +2,7 @@ FROM jinaai/jina:3.14.1-py39-standard # update pip RUN pip install --upgrade pip -RUN apt-get update && apt-get install --no-install-recommends -y ffmpeg build-essential pkg-config {{apt_get_packages}} && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install --no-install-recommends -y ffmpeg build-essential pkg-config poppler-utils {{apt_get_packages}} && apt-get clean && rm -rf /var/lib/apt/lists/* ## install requirements for the executor COPY requirements.txt .