Skip to content

An error occurred when using custom prompt template #636

@Tql-ws1

Description

@Tql-ws1

Before you asking

  • I have searched the existing issues
  • I spend at least 5 minutes for thinking and preparing
  • I have thoroughly and completely read the wiki.
  • I have carefully checked the issue, and it is unrelated to the network environment.

Environment

- OS: Arch Linux
- Python: 3.12.9
- pdf2zh: 1.8.9

Describe the bug

When using custom prompt templates, the translation progress does not advance (indicated by consistently appearing ambiguous error messages) and I repeatedly attempt to translate, as shown in the figure below:

Image

It's unrelated to the model (I've tried command-r7b and qwen2.5); it also has nothing to do with the prompt template format (I have tried removing the commas at the end of the fourth and eighth lines), and here is the prompt template:

Image

To Reproduce

  1. Visit the website and use the keyboard shortcut Ctrl + P to save the website content as a PDF file.
  2. Run the following command:
    pdf2zh Understanding\ the\ Python\ Mock\ Object\ Library\ –\ Real\ Python.pdf -li en -lo zh --prompt pdf2zh-prompt.txt -s ollama:huihui_ai/command-r7b-abliterated:latest
  3. An error occurs when translating to page five.

Expected behavior

Translate the entire PDF and provide the user with a clear error message even if an error occurs. 😅

Relevant log output

invalid syntax. Perhaps you forgot a comma? (<string>, line 8)
ERROR:pdf2zh.converter:All models failed
invalid syntax. Perhaps you forgot a comma? (<string>, line 8)
ERROR:pdf2zh.converter:All models failed
invalid syntax. Perhaps you forgot a comma? (<string>, line 8)
ERROR:pdf2zh.converter:All models failed
......

Origin PDF file

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions