MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / md_to_blocks

Function md_to_blocks

utils/poster_eval_utils.py:67–92  ·  view source on GitHub ↗
(
    md: str,
    base_dir=''
)

Source from the content-addressed store, hash-verified

65 return f"data:{mime};base64,{b64}"
66
67def md_to_blocks(
68 md: str,
69 base_dir=''
70):
71 blocks, pos = [], 0
72 pat = re.compile(r'!\[.*?\]\((.*?)\)', re.DOTALL)
73
74 for m in pat.finditer(md):
75 # --- text before this image ---------------------------------------
76 txt = md[pos : m.start()].strip()
77 if txt:
78 blocks.append({"type": "text", "text": txt})
79
80 # --- the image itself ---------------------------------------------
81 img_path = unquote(m.group(1))
82 img_path = os.path.join(base_dir, img_path)
83
84 blocks.append({"type": "image_url", "image_url": {"url": pil_to_data_uri(Image.open(img_path), fmt="PNG")}})
85 pos = m.end()
86
87 # --- any trailing text -------------------------------------------------
88 tail = md[pos:].strip()
89 if tail:
90 blocks.append({"type": "text", "text": tail})
91
92 return blocks
93
94def compute_vlm_ppl(content):
95 VLLM_BASE_URL = "http://localhost:7000/v1"

Callers 1

compute_interleaved_pplFunction · 0.70

Calls 2

pil_to_data_uriFunction · 0.70
startMethod · 0.45

Tested by

no test coverage detected