Skip to content

Commit 0edbb15

Browse files
authored
Merge pull request #15 from MarkPDFdown/fix_hunyuan_400
fix: Fixed the issue where hunyuan does not support empty system_prompt
2 parents f97f99c + 5506ab1 commit 0edbb15

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

core/LLMClient.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,16 @@ def completion(
5656
}
5757
})
5858

59-
messages = [
60-
{"role": "system", "content": system_prompt or ""},
61-
{"role": "user", "content": user_content}
62-
]
59+
messages = []
60+
if system_prompt:
61+
messages = [
62+
{"role": "system", "content": system_prompt},
63+
{"role": "user", "content": user_content}
64+
]
65+
else:
66+
messages = [
67+
{"role": "user", "content": user_content}
68+
]
6369

6470
try:
6571
response = None

main.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,22 @@ def convert_image_to_markdown(image_path):
6767
Returns:
6868
str: Converted Markdown string
6969
"""
70+
system_prompt = """
71+
You are a helpful assistant that can convert images to Markdown format. You are given an image, and you need to convert it to Markdown format. Please output the Markdown content only, without any other text.
72+
"""
7073
user_prompt = """
71-
Please read the content in the image and transcribe it into plain Markdown format. Please note:
72-
1. Maintain the format of headings, text, formulas, and table rows and columns
74+
Below is the image of one page of a document, please read the content in the image and transcribe it into plain Markdown format. Please note:
75+
1. Identify heading levels, text styles, formulas, and the format of table rows and columns
7376
2. Mathematical formulas should be transcribed using LaTeX syntax, ensuring consistency with the original
74-
3. No additional explanation is needed, and no content outside the original text should be added.
75-
"""
77+
3. Please output the Markdown content only, without any other text.
78+
79+
Output Example:
80+
```markdown
81+
{example}
82+
```
83+
"""
7684

77-
response = completion(message=user_prompt, model="", image_paths=[image_path], temperature=0.3, max_tokens=8192)
85+
response = completion(message=user_prompt, system_prompt=system_prompt, image_paths=[image_path], temperature=0.3, max_tokens=8192)
7886
response = remove_markdown_warp(response, "markdown")
7987
return response
8088

0 commit comments

Comments
 (0)