Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 214eb0f

Browse files
committed
update
1 parent 1d48f24 commit 214eb0f

4 files changed

Lines changed: 19 additions & 14 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ async def process_multimodal_content():
502502

503503
image_content = {
504504
"img_path": "path/to/image.jpg",
505-
"img_caption": ["Figure 1: Experimental results"],
506-
"img_footnote": ["Data collected in 2024"]
505+
"image_caption": ["Figure 1: Experimental results"],
506+
"image_footnote": ["Data collected in 2024"]
507507
}
508508

509509
description, entity_info = await image_processor.process_multimodal_content(
@@ -876,8 +876,8 @@ async def insert_content_list_example():
876876
{
877877
"type": "image",
878878
"img_path": "/absolute/path/to/figure1.jpg", # IMPORTANT: Use absolute path
879-
"img_caption": ["Figure 1: System Architecture"],
880-
"img_footnote": ["Source: Authors' original design"],
879+
"image_caption": ["Figure 1: System Architecture"],
880+
"image_footnote": ["Source: Authors' original design"],
881881
"page_idx": 1 # Page number where this image appears
882882
},
883883
{
@@ -947,7 +947,7 @@ if __name__ == "__main__":
947947
The `content_list` should follow the standard format with each item being a dictionary containing:
948948

949949
- **Text content**: `{"type": "text", "text": "content text", "page_idx": 0}`
950-
- **Image content**: `{"type": "image", "img_path": "/absolute/path/to/image.jpg", "img_caption": ["caption"], "img_footnote": ["note"], "page_idx": 1}`
950+
- **Image content**: `{"type": "image", "img_path": "/absolute/path/to/image.jpg", "image_caption": ["caption"], "image_footnote": ["note"], "page_idx": 1}`
951951
- **Table content**: `{"type": "table", "table_body": "markdown table", "table_caption": ["caption"], "table_footnote": ["note"], "page_idx": 2}`
952952
- **Equation content**: `{"type": "equation", "latex": "LaTeX formula", "text": "description", "page_idx": 3}`
953953
- **Generic content**: `{"type": "custom_type", "content": "any content", "page_idx": 4}`

README_zh.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ async def process_multimodal_content():
487487

488488
image_content = {
489489
"img_path": "path/to/image.jpg",
490-
"img_caption": ["图1:实验结果"],
491-
"img_footnote": ["数据收集于2024年"]
490+
"image_caption": ["图1:实验结果"],
491+
"image_footnote": ["数据收集于2024年"]
492492
}
493493

494494
description, entity_info = await image_processor.process_multimodal_content(
@@ -860,8 +860,8 @@ async def insert_content_list_example():
860860
{
861861
"type": "image",
862862
"img_path": "/absolute/path/to/figure1.jpg", # 重要:使用绝对路径
863-
"img_caption": ["图1:系统架构"],
864-
"img_footnote": ["来源:作者原创设计"],
863+
"image_caption": ["图1:系统架构"],
864+
"image_footnote": ["来源:作者原创设计"],
865865
"page_idx": 1 # 此图像出现的页码
866866
},
867867
{
@@ -931,7 +931,7 @@ if __name__ == "__main__":
931931
`content_list` 应遵循标准格式,每个项目都是包含以下内容的字典:
932932

933933
- **文本内容**: `{"type": "text", "text": "内容文本", "page_idx": 0}`
934-
- **图像内容**: `{"type": "image", "img_path": "/absolute/path/to/image.jpg", "img_caption": ["标题"], "img_footnote": ["注释"], "page_idx": 1}`
934+
- **图像内容**: `{"type": "image", "img_path": "/absolute/path/to/image.jpg", "image_caption": ["标题"], "image_footnote": ["注释"], "page_idx": 1}`
935935
- **表格内容**: `{"type": "table", "table_body": "markdown表格", "table_caption": ["标题"], "table_footnote": ["注释"], "page_idx": 2}`
936936
- **公式内容**: `{"type": "equation", "latex": "LaTeX公式", "text": "描述", "page_idx": 3}`
937937
- **通用内容**: `{"type": "custom_type", "content": "任何内容", "page_idx": 4}`

docs/context_aware_processing.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ Multimodal Content → Extract Surrounding Context → Enhanced LLM Analysis →
202202
{
203203
"type": "image",
204204
"img_path": "images/figure1.jpg",
205-
"img_caption": ["Figure 1: Architecture"],
205+
"image_caption": ["Figure 1: Architecture"],
206+
"image_footnote": [],
206207
"page_idx": 1
207208
}
208209
]

raganything/processor.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,12 @@ def _apply_chunk_template(
925925
try:
926926
if content_type == "image":
927927
image_path = original_item.get("img_path", "")
928-
captions = original_item.get("img_caption", [])
929-
footnotes = original_item.get("img_footnote", [])
928+
captions = original_item.get(
929+
"image_caption", original_item.get("img_caption", [])
930+
)
931+
footnotes = original_item.get(
932+
"image_footnote", original_item.get("img_footnote", [])
933+
)
930934

931935
return PROMPTS["image_chunk"].format(
932936
image_path=image_path,
@@ -1733,7 +1737,7 @@ async def insert_content_list(
17331737
Each item should be a dictionary with the following structure:
17341738
- Text: {"type": "text", "text": "content", "page_idx": 0}
17351739
- Image: {"type": "image", "img_path": "/absolute/path/to/image.jpg",
1736-
"img_caption": ["caption"], "img_footnote": ["note"], "page_idx": 1}
1740+
"image_caption": ["caption"], "image_footnote": ["note"], "page_idx": 1}
17371741
- Table: {"type": "table", "table_body": "markdown table",
17381742
"table_caption": ["caption"], "table_footnote": ["note"], "page_idx": 2}
17391743
- Equation: {"type": "equation", "latex": "LaTeX formula",

0 commit comments

Comments
 (0)