fix
This commit is contained in:
parent
5b9eafdf6a
commit
2ffed2f71e
10
app.py
10
app.py
|
|
@ -118,21 +118,21 @@ def model_inference(
|
||||||
|
|
||||||
# After finishing the streamer loop:
|
# After finishing the streamer loop:
|
||||||
cleaned_output = full_output.replace("<end_of_utterance>", "").strip()
|
cleaned_output = full_output.replace("<end_of_utterance>", "").strip()
|
||||||
final_output = cleaned_output
|
|
||||||
|
|
||||||
# If markdown conversion is needed, combine it with cleaned_output
|
if cleaned_output:
|
||||||
|
yield cleaned_output
|
||||||
|
# Now, since cleaned_output exists, we can safely use it.
|
||||||
if any(tag in cleaned_output for tag in ["<doctag>", "<otsl>", "<code>", "<chart>", "<formula>"]):
|
if any(tag in cleaned_output for tag in ["<doctag>", "<otsl>", "<code>", "<chart>", "<formula>"]):
|
||||||
doctag_output = cleaned_output
|
doctag_output = cleaned_output
|
||||||
if "<chart>" in doctag_output:
|
if "<chart>" in doctag_output:
|
||||||
doctag_output = doctag_output.replace("<chart>", "<otsl>").replace("</chart>", "</otsl>")
|
doctag_output = doctag_output.replace("<chart>", "<otsl>").replace("</chart>", "</otsl>")
|
||||||
doctag_output = re.sub(r'(<loc_500>)(?!.*<loc_500>)<[^>]+>', r'\1', doctag_output)
|
doctag_output = re.sub(r'(<loc_500>)(?!.*<loc_500>)<[^>]+>', r'\1', doctag_output)
|
||||||
|
|
||||||
doc = DoclingDocument(name="Document")
|
doc = DoclingDocument(name="Document")
|
||||||
doctags_doc = DocTagsDocument.from_doctags_and_image_pairs([doctag_output], images)
|
doctags_doc = DocTagsDocument.from_doctags_and_image_pairs([doctag_output], images)
|
||||||
doc.load_from_doctags(doctags_doc)
|
doc.load_from_doctags(doctags_doc)
|
||||||
final_output += "\n\n**MD Output:**\n\n" + doc.export_to_markdown()
|
yield f"**MD Output:**\n\n{doc.export_to_markdown()}"
|
||||||
|
|
||||||
# Yield the final combined output only once
|
|
||||||
yield final_output
|
|
||||||
|
|
||||||
|
|
||||||
if any(tag in doctag_output for tag in ["<doctag>", "<otsl>", "<code>", "<chart>", "<formula>"]):
|
if any(tag in doctag_output for tag in ["<doctag>", "<otsl>", "<code>", "<chart>", "<formula>"]):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue