fix end of string
This commit is contained in:
parent
f0c802eb3d
commit
5b9eafdf6a
17
app.py
17
app.py
|
|
@ -116,11 +116,24 @@ def model_inference(
|
|||
buffer += html.escape(new_text)
|
||||
yield buffer
|
||||
|
||||
# After finishing the streamer loop:
|
||||
cleaned_output = full_output.replace("<end_of_utterance>", "").strip()
|
||||
final_output = cleaned_output
|
||||
|
||||
if cleaned_output:
|
||||
# If markdown conversion is needed, combine it with cleaned_output
|
||||
if any(tag in cleaned_output for tag in ["<doctag>", "<otsl>", "<code>", "<chart>", "<formula>"]):
|
||||
doctag_output = cleaned_output
|
||||
yield cleaned_output
|
||||
if "<chart>" in doctag_output:
|
||||
doctag_output = doctag_output.replace("<chart>", "<otsl>").replace("</chart>", "</otsl>")
|
||||
doctag_output = re.sub(r'(<loc_500>)(?!.*<loc_500>)<[^>]+>', r'\1', doctag_output)
|
||||
doc = DoclingDocument(name="Document")
|
||||
doctags_doc = DocTagsDocument.from_doctags_and_image_pairs([doctag_output], images)
|
||||
doc.load_from_doctags(doctags_doc)
|
||||
final_output += "\n\n**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>"]):
|
||||
doc = DoclingDocument(name="Document")
|
||||
|
|
|
|||
Loading…
Reference in New Issue