MCPcopy Create free account

hub / github.com/NatsUIJM/autoContents / functions

Functions74 in github.com/NatsUIJM/autoContents

↓ 37 callersFunctionwrite_log
写入日志到项目根目录的 log.txt
mainprogress/pdf_metadata_extractor.py:26
↓ 25 callersFunctionwrite_log
(message)
mainprogress/determine_toc_levels.py:63
↓ 11 callersFunctionwrite_log
(message)
mainprogress/qwen_vl_extract.py:73
↓ 4 callersFunctionget_encoded_image
(image_path: Path)
mainprogress/determine_toc_levels.py:123
↓ 3 callersFunctionextract_env_var_name
从 API KEY 值中提取环境变量名称 例如:$CHERRY_IN_API_KEY$ -> CHERRY_IN_API_KEY
app.py:79
↓ 3 callersFunctionis_valid_page
(p)
mainprogress/qwen_vl_extract.py:243
↓ 3 callersFunctionresolve_value
(val)
mainprogress/determine_toc_levels.py:93
↓ 3 callersFunctionresolve_value
(val)
mainprogress/qwen_vl_extract.py:103
↓ 2 callersFunctioncreate_concat_image_b64
将指定范围的 PDF 页面转换为横向拼接的 JPG,并在底部追加页码。
mainprogress/pdf_metadata_extractor.py:46
↓ 2 callersFunctionextract_book_title
从文件名中提取书名,取第一个下划线之前的内容
mainprogress/content_postprocessor.py:37
↓ 2 callersFunctionfetch_single_offset
调用 LLM 识别单页的页码偏移量
mainprogress/pdf_metadata_extractor.py:508
↓ 2 callersFunctionget_encoded_image
(image_path: Path)
mainprogress/qwen_vl_extract.py:137
↓ 2 callersFunctionnatural_sort_key
(s)
mainprogress/determine_toc_levels.py:107
↓ 2 callersFunctionparse_csv_response
将模型返回的 CSV 文本解析为目标 JSON 结构。 目标结构:[{"text": "...", "number": int, "level": int}, ...]
mainprogress/determine_toc_levels.py:184
↓ 1 callersFunctioncalculate_offset
自动计算正文偏移量。 逻辑优化: 1. 先随机取 5 页。 2. 统计众数,若众数数量 < 4,则再随机取 5 页(不重复),共 10 页一起统计。 3. 将所有过程的图片、原始响应、解析结果保存到 initial_data/offset_log.json。
mainprogress/pdf_metadata_extractor.py:561
↓ 1 callersFunctionconvert_pdf_to_jpg
()
mainprogress/pdf_to_image.py:9
↓ 1 callersFunctionconvert_to_pinyin
将中文字符转换为拼音
app.py:39
↓ 1 callersFunctioncreate_bookmark_tree
(items)
mainprogress/pdf_generator.py:116
↓ 1 callersFunctioncreate_data_folders
(session_id)
app.py:72
↓ 1 callersFunctionextract_book_name
提取 PDF 第一页并调用 LLM 识别书名
mainprogress/pdf_metadata_extractor.py:458
↓ 1 callersFunctionextract_toc_info
使用滑动窗口提取目录,并对冲突页进行单页投票
mainprogress/pdf_metadata_extractor.py:232
↓ 1 callersFunctionextract_toc_to_csv
提取PDF的目录并保存为CSV文件
contents_editor/extract.py:34
↓ 1 callersFunctionfetch_toc_from_image
调用 LLM 识别拼接图片中的目录范围,并保存原始响应
mainprogress/pdf_metadata_extractor.py:119
↓ 1 callersFunctionfind_available_port
(start_port=5000, max_port=6000)
app.py:449
↓ 1 callersFunctionfind_min_page_file
找到页码最小的_page_x_merged.json 文件
mainprogress/content_postprocessor.py:45
↓ 1 callersFunctionfix_null_page_numbers
处理页码为 null 的情况: 1. 若某标题页码为 null,则向下寻找第一个非 null 项填充。 2. 若下方全是 null,则向上寻找最近的非 null 项填充。
mainprogress/qwen_vl_extract.py:208
↓ 1 callersFunctiongenerate
()
app.py:291
↓ 1 callersFunctiongenerate_random_string
生成指定长度的随机字母数字组合
app.py:62
↓ 1 callersFunctiongenerate_session_id
()
app.py:67
↓ 1 callersFunctionget_api_key
解析 API Key,支持环境变量提取
mainprogress/pdf_metadata_extractor.py:39
↓ 1 callersFunctionget_pdf_file
获取脚本所在目录下的PDF文件
contents_editor/extract.py:8
↓ 1 callersFunctionhas_toc_in_range
检查指定范围内是否有被投票为目录的页
mainprogress/pdf_metadata_extractor.py:293
↓ 1 callersFunctionload_llm_config
()
mainprogress/determine_toc_levels.py:84
↓ 1 callersFunctionload_llm_config
()
mainprogress/qwen_vl_extract.py:94
↓ 1 callersFunctionmain
()
mainprogress/content_postprocessor.py:95
↓ 1 callersFunctionmain
()
mainprogress/pdf_metadata_extractor.py:712
↓ 1 callersFunctionmain
()
contents_editor/merge.py:45
↓ 1 callersFunctionmain
()
contents_editor/extract.py:70
↓ 1 callersFunctionmain_async
()
mainprogress/determine_toc_levels.py:484
↓ 1 callersFunctionmain_async
()
mainprogress/qwen_vl_extract.py:454
↓ 1 callersFunctionmerge_continuous_ranges
将分散的页码列表合并为最大的连续区间。 逻辑:排序后,如果相邻页码差值 <= 1,视为连续。 返回最大连续区间的 (start, end)。
mainprogress/pdf_metadata_extractor.py:190
↓ 1 callersFunctionnatural_sort_key
(s)
mainprogress/qwen_vl_extract.py:121
↓ 1 callersFunctionnormalize_levels
检查数据中 level 字段的最小值。 如果最小值不是 1,则将所有 level 减去 (min_level - 1),使最小值为 1。
mainprogress/content_postprocessor.py:64
↓ 1 callersFunctionnormalize_toc_levels
规范化 TOC 层级,确保: 1. 第一个条目 level 为 1 2. 层级跳跃不超过 1 (例如不能从 1 直接到 3)
contents_editor/merge.py:7
↓ 1 callersFunctionparse_toc_json
安全解析 LLM 输出的 JSON,剥离 Markdown 标记
mainprogress/pdf_metadata_extractor.py:175
↓ 1 callersFunctionpost_process_levels
(output_path: Path)
mainprogress/determine_toc_levels.py:409
↓ 1 callersFunctionprocess_first_page
专门处理第一张图片,获取 CSV 格式的响应,并缓存为 Few-shot 示例。
mainprogress/determine_toc_levels.py:242
↓ 1 callersFunctionprocess_image_async
使用 OpenAI SDK 发送请求,并包含后处理逻辑 修改点:增加对解析错误的详细日志记录,包含原始响应
mainprogress/qwen_vl_extract.py:293
↓ 1 callersFunctionprocess_level_async
处理除第一张以外的其他图片,使用首图的 CSV 结果作为 Few-shot 上下文。
mainprogress/determine_toc_levels.py:321
↓ 1 callersFunctionprocess_pdf_with_bookmarks
()
mainprogress/pdf_generator.py:12
↓ 1 callersFunctionprocess_window
(start_p, end_p)
mainprogress/pdf_metadata_extractor.py:244
↓ 1 callersFunctionread_json_file
读取 JSON 文件并返回数据,统一返回列表格式
mainprogress/content_postprocessor.py:28
↓ 1 callersFunctionresize_and_encode_image
(image_path: Path)
mainprogress/determine_toc_levels.py:110
↓ 1 callersFunctionresize_and_encode_image
(image_path: Path)
mainprogress/qwen_vl_extract.py:124
↓ 1 callersFunctionresolve_conflict
(p)
mainprogress/pdf_metadata_extractor.py:367
↓ 1 callersFunctionrun_batch
执行一个批次的滑动窗口扫描
mainprogress/pdf_metadata_extractor.py:271
↓ 1 callersFunctionrun_batch_processing
(image_files: list, output_path: Path)
mainprogress/determine_toc_levels.py:442
↓ 1 callersFunctionrun_batch_processing
(image_files: list, output_path: Path)
mainprogress/qwen_vl_extract.py:435
↓ 1 callersFunctionvalidate_and_fix_csv_content
验证并修复 CSV 内容(目标为 3 列:title, page_number, level)。 1. 若列数少于 3,尝试从右向左将全角逗号替换为半角逗号(最多替换两次)。 2. 若解析为 4 列以上,说明标题中包含了半角逗号,将前 n-2 列合并为 title。
mainprogress/determine_toc_levels.py:128
↓ 1 callersFunctionvalidate_and_fix_csv_content
验证 CSV 内容是否合法(2 列)。 若不合法,尝试修复: 1. 将每行最后一个全角逗号替换为半角逗号。 2. 若解析为 3 列以上,说明半角逗号没有被恰当处理,将前 n-1 列合并并用双引号包裹。 返回:(is_valid, fixed_content)
mainprogress/qwen_vl_extract.py:142
Functionapple_icon
()
app.py:34
Functionapple_icon_precomposed
()
app.py:30
Functiondownload_result
(session_id)
app.py:141
Functionfavicon
()
app.py:26
Functionget_llm_config
()
app.py:311
Functionhome
()
app.py:89
Functionnatural_sort_key
自然排序键函数
mainprogress/content_postprocessor.py:16
Functionopen_browser
()
app.py:468
Functionrun_script
(session_id, script_index, retry_count)
app.py:183
Functionsave_llm_config
()
app.py:331
Functionstream_log
()
app.py:290
Functiontest_llm_service
()
app.py:402
Functiontest_qwen_service
()
app.py:354
Functionupload_files
()
app.py:93