Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions core/LLMClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ def completion(
}
})

messages = [
{"role": "system", "content": system_prompt or ""},
{"role": "user", "content": user_content}
]
messages = []
if system_prompt:
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_content}
]
else:
messages = [
{"role": "user", "content": user_content}
]

try:
response = None
Expand Down
18 changes: 13 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,22 @@ def convert_image_to_markdown(image_path):
Returns:
str: Converted Markdown string
"""
system_prompt = """
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.
"""
user_prompt = """
Please read the content in the image and transcribe it into plain Markdown format. Please note:
1. Maintain the format of headings, text, formulas, and table rows and columns
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:
1. Identify heading levels, text styles, formulas, and the format of table rows and columns
2. Mathematical formulas should be transcribed using LaTeX syntax, ensuring consistency with the original
3. No additional explanation is needed, and no content outside the original text should be added.
"""
3. Please output the Markdown content only, without any other text.

Output Example:
```markdown
{example}
```
"""

response = completion(message=user_prompt, model="", image_paths=[image_path], temperature=0.3, max_tokens=8192)
response = completion(message=user_prompt, system_prompt=system_prompt, image_paths=[image_path], temperature=0.3, max_tokens=8192)
response = remove_markdown_warp(response, "markdown")
return response

Expand Down
Loading