fix: update new TOCBuilder interface
Browse files
app.py
CHANGED
|
@@ -223,7 +223,7 @@ def convert_document(
|
|
| 223 |
toc_text = (
|
| 224 |
"<details open='true'><summary><big>Table-of-Content</big></summary>\n\n"
|
| 225 |
)
|
| 226 |
-
new_chunks =
|
| 227 |
chunks,
|
| 228 |
use_llm=True,
|
| 229 |
model=MODEL_NAME,
|
|
@@ -232,17 +232,17 @@ def convert_document(
|
|
| 232 |
if chunk.ctype != CType.Header:
|
| 233 |
continue
|
| 234 |
|
| 235 |
-
chunk_page = chunk.origin
|
| 236 |
-
chunk_bbox = chunk.origin
|
| 237 |
chunk_text = (
|
| 238 |
-
"<
|
| 239 |
)
|
| 240 |
ref_link = (
|
| 241 |
f" <a class='chunk-ref' id='{chunk_page}-{chunk_bbox}'>[↗]</a>"
|
| 242 |
if add_reference_links
|
| 243 |
else ""
|
| 244 |
)
|
| 245 |
-
chunk_text += ref_link + "</
|
| 246 |
toc_text += chunk_text + "\n\n"
|
| 247 |
|
| 248 |
toc_text += "</details>\n\n---\n\n"
|
|
|
|
| 223 |
toc_text = (
|
| 224 |
"<details open='true'><summary><big>Table-of-Content</big></summary>\n\n"
|
| 225 |
)
|
| 226 |
+
new_chunks = TOCHierarchyBuilder.run(
|
| 227 |
chunks,
|
| 228 |
use_llm=True,
|
| 229 |
model=MODEL_NAME,
|
|
|
|
| 232 |
if chunk.ctype != CType.Header:
|
| 233 |
continue
|
| 234 |
|
| 235 |
+
chunk_page = chunk.origin.location["page"]
|
| 236 |
+
chunk_bbox = chunk.origin.location["bbox"]
|
| 237 |
chunk_text = (
|
| 238 |
+
"<h5>" + "".join([" "] * level) + chunk.content
|
| 239 |
)
|
| 240 |
ref_link = (
|
| 241 |
f" <a class='chunk-ref' id='{chunk_page}-{chunk_bbox}'>[↗]</a>"
|
| 242 |
if add_reference_links
|
| 243 |
else ""
|
| 244 |
)
|
| 245 |
+
chunk_text += ref_link + "</h5>"
|
| 246 |
toc_text += chunk_text + "\n\n"
|
| 247 |
|
| 248 |
toc_text += "</details>\n\n---\n\n"
|