[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-emcf--thepipe":3,"tool-emcf--thepipe":61},[4,18,28,37,45,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":24,"last_commit_at":25,"category_tags":26,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",155373,2,"2026-04-14T11:34:08",[14,13,27],"语言模型",{"id":29,"name":30,"github_repo":31,"description_zh":32,"stars":33,"difficulty_score":24,"last_commit_at":34,"category_tags":35,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[36,13,15,14],"插件",{"id":38,"name":39,"github_repo":40,"description_zh":41,"stars":42,"difficulty_score":24,"last_commit_at":43,"category_tags":44,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[36,14],{"id":46,"name":47,"github_repo":48,"description_zh":49,"stars":50,"difficulty_score":10,"last_commit_at":51,"category_tags":52,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[27,15,13,14],{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":24,"last_commit_at":59,"category_tags":60,"status":17},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[14,27],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":77,"owner_email":76,"owner_twitter":76,"owner_website":78,"owner_url":79,"languages":80,"stars":108,"forks":109,"last_commit_at":110,"license":111,"difficulty_score":24,"env_os":112,"env_gpu":113,"env_ram":112,"env_deps":114,"category_tags":126,"github_topics":128,"view_count":24,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":142,"updated_at":143,"faqs":144,"releases":175},7458,"emcf\u002Fthepipe","thepipe","Get clean data from tricky documents, powered by vision-language models ⚡","thepipe 是一款专为处理复杂文档而设计的开源数据提取工具。面对 PDF、Word、PPT、代码笔记本甚至音视频等非结构化或格式混乱的文件，传统解析方式往往难以保留原始布局或提取出干净的数据。thepipe 通过集成视觉 - 语言模型（VLM），能够像人类一样“看懂”文档内容，从中精准提取格式整洁的 Markdown、表格、图片及多模态媒体资源。\n\n它主要解决了从多样化来源中高质量获取结构化数据的难题，特别适用于构建检索增强生成（RAG）系统、向量数据库索引或大模型训练数据清洗等场景。无论是开发者、AI 研究人员还是数据工程师，都能利用 thepipe 快速将杂乱文档转化为机器可读的优质语料。\n\nthepipe 的技术亮点在于其原生的 AI 文件类型检测与布局分析能力，支持开箱即用地对接各类大语言模型和向量库。安装灵活，既提供轻量级的 CPU 版本以适应受限环境，也支持按需加载音频转录、语义分块等高级功能模块。只需几分钟配置，即可让繁琐的文档预处理工作变得高效可靠。","\u003Cdiv align=\"center\">\r\n  \u003Ca href=\"https:\u002F\u002Fthepi.pe\u002F\">\r\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Femcf_thepipe_readme_8c602661cb5c.png\" alt=\"Pipeline Illustration\" style=\"width:96px; height:72px; vertical-align:middle;\">\r\n    \u003Ch1>thepi.pe\u003C\u002Fh1>\r\n  \u003C\u002Fa>\r\n  \u003Ca>\r\n    \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Factions\u002Fworkflows\u002Fpython-ci.yml\u002Fbadge.svg\" alt=\"python-gh-action\">\r\n  \u003C\u002Fa>\r\n    \u003Ca href=\"https:\u002F\u002Fcodecov.io\u002Fgh\u002Femcf\u002Fthepipe\">\r\n    \u003Cimg src=\"https:\u002F\u002Fcodecov.io\u002Fgh\u002Femcf\u002Fthepipe\u002Fgraph\u002Fbadge.svg?token=OE7CUEFUL9\" alt=\"codecov\">\r\n  \u003C\u002Fa>\r\n  \u003Ca href=\"https:\u002F\u002Fraw.githubusercontent.com\u002Femcf\u002Fthepipe\u002Fmain\u002FLICENSE\">\r\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green\" alt=\"MIT license\">\r\n  \u003C\u002Fa>\r\n  \u003Ca href=\"https:\u002F\u002Fwww.pepy.tech\u002Fprojects\u002Fthepipe-api\">\r\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Femcf_thepipe_readme_8580daf15142.png\" alt=\"PyPI\">\r\n  \u003C\u002Fa>\r\n\u003C\u002Fdiv>\r\n\r\n## Extract clean data from tricky documents ⚡\r\n\r\nthepi.pe is a package that can scrape clean markdown, multimodal media, and structured data from complex documents. It uses vision-language models (VLMs) under the hood for superior output quality, and works out-of-the-box with any LLM, VLM, or vector database. It can extract well-formatted data from a wide range of sources, including PDFs, URLs, Word docs, Powerpoints, Python notebooks, videos, audio, and more.\r\n\r\n## Features 🌟\r\n\r\n- Scrape clean markdown, tables, and images from any document\r\n- Scrape text, images, video, and audio from any file or URL\r\n- Works out-of-the-box with vision-language models, vector databases, and RAG frameworks\r\n- AI-native file-type detection, layout analysis, and structured data extraction\r\n- Accepts a wide range of sources, including PDFs, URLs, Word docs, Powerpoints, Python notebooks, GitHub repos, videos, audio, and more\r\n\r\n## Get started in 5 minutes 🚀\r\n\r\nThepipe can be installed via the command line:\r\n\r\n```bash\r\npip install thepipe-api\r\n```\r\n\r\nThe default install only pulls in CPU-friendly dependencies so it is suitable for constrained environments and CI systems. GPU-enabled libraries such as PyTorch and Triton are left as optional extras.\r\n\r\n### Optional extras\r\n\r\nThe package exposes a set of extras so you can opt-in to heavier dependencies on demand:\r\n\r\n| Extra                      | Installs                                  | When to use it                                        |\r\n| -------------------------- | ----------------------------------------- | ----------------------------------------------------- |\r\n| `thepipe-api[audio]`       | `openai-whisper`                          | Local audio\u002Fvideo transcription via Whisper.          |\r\n| `thepipe-api[semantic]`    | `sentence-transformers`                   | Semantic chunking with transformer embeddings.        |\r\n| `thepipe-api[llama-index]` | `llama-index`                             | `Chunk.to_llamaindex()` conversions.                  |\r\n| `thepipe-api[gpu]`         | PyTorch + Whisper + Sentence Transformers | Full GPU acceleration with VLM fine-tuning workloads. |\r\n\r\nIf you are targeting CPU-only machines but still need the extras that depend on PyTorch, install the CPU wheels directly from the PyTorch index first and then add the extra. For example:\r\n\r\n```bash\r\npip install torch==2.5.1+cpu torchvision==0.20.1+cpu torchaudio==2.5.1+cpu \\\r\n  --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\r\npip install thepipe-api[semantic]\r\n```\r\n\r\nIf you need full functionality with media-rich sources such as webpages, video, and audio, you can choose to install the following system dependencies:\r\n\r\n```bash\r\napt-get update && apt-get install -y git ffmpeg\r\npython -m playwright install --with-deps chromium\r\n```\r\n\r\nand use the global installation with pip:\r\n\r\n```bash\r\npip install thepipe-api[all]\r\n```\r\n\r\n### Default setup (OpenAI)\r\n\r\nBy default, thepipe uses the [OpenAI API](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Foverview), so VLM features will work out-of-the-box provided you pass in an OpenAI client.\r\n\r\n### Custom VLM server setup (OpenRouter, OpenLLM, etc.)\r\n\r\nIf you wish to use a local vision-language model or a different cloud provider, you can provide a custom OpenAI client, for example, by setting the base url to `https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1` for [OpenRouter](https:\u002F\u002Fopenrouter.ai\u002F), or `http:\u002F\u002Flocalhost:3000\u002Fv1` for a local server such as [OpenLLM](https:\u002F\u002Fgithub.com\u002Fbentoml\u002FOpenLLM). Note that uou must also pass the api key to your non-OpenAI cloud provider into the OpenAI client. The model name can be changed with the `model` parameter. By default, the model will be `gpt-4o`.\r\n\r\n### Scraping\r\n\r\n```python\r\nfrom thepipe.scraper import scrape_file\r\n\r\n# scrape text and page images from a PDF\r\nchunks = scrape_file(filepath=\"paper.pdf\")\r\n```\r\n\r\nFor enhanced scraping with a vision-language model, you can pass in an OpenAI-compatible client and a model name.\r\n\r\n```python\r\nfrom openai import OpenAI\r\nfrom thepipe.scraper import scrape_file\r\n\r\n# create an OpenAI-compatible client\r\nclient = OpenAI()\r\n\r\n# scrape clean markdown and page images from a PDF\r\nchunks = scrape_file(\r\n  filepath=\"paper.pdf\",\r\n  openai_client=client,\r\n  model=\"gpt-4o\"\r\n)\r\n```\r\n\r\n### Chunking\r\n\r\nTo satisfy token-limit constraints, the following chunking methods are available to split the content into smaller chunks.\r\n\r\n- `chunk_by_document`: Returns one chunk with the entire content of the file.\r\n- `chunk_by_page`: Returns one chunk for each page (for example: each webpage, PDF page, or PowerPoint slide).\r\n- `chunk_by_length`: Splits chunks by length.\r\n- `chunk_by_section`: Splits chunks by markdown section.\r\n- `chunk_by_keyword`: Splits chunks at keywords.\r\n- `chunk_semantic` (experimental, requires [sentence-transformers](https:\u002F\u002Fpypi.org\u002Fproject\u002Fsentence-transformers\u002F)): Returns chunks split by spikes in semantic changes, with a configurable threshold.\r\n- `chunk_agentic` (experimental, requires [OpenAI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fopenai\u002F)): Returns chunks split by an LLM agent that attempts to find semantically meaningful sections.\r\n\r\nFor example,\r\n\r\n```python\r\nfrom thepipe.scraper import scrape_file\r\nfrom thepipe.chunker import chunk_by_document, chunk_by_page\r\n\r\n# optionally, pass in chunking_method\r\n# chunk_by_document returns one chunk for the entire document\r\nchunks = scrape_file(\r\n  filepath=\"paper.pdf\",\r\n  chunking_method=chunk_by_document\r\n)\r\n\r\n# you can also re-chunk later.\r\n# chunk_by_page returns one chunk for each page (for example: each webpage, PDF page, or PowerPoint slide).\r\nchunks = chunk_by_page(chunks)\r\n```\r\n\r\n### OpenAI Chat Integration 🤖\r\n\r\n```python\r\nfrom openai import OpenAI\r\nfrom thepipe.core import chunks_to_messages\r\n\r\n# Initialize OpenAI client\r\nclient = OpenAI()\r\n\r\n# Use OpenAI-formatted chat messages\r\nmessages = [{\r\n  \"role\": \"user\",\r\n  \"content\": [{\r\n      \"type\": \"text\",\r\n      \"text\": \"What is the paper about?\"\r\n    }]\r\n}]\r\n\r\n# Simply add the scraped chunks to the messages\r\nmessages += chunks_to_messages(chunks)\r\n\r\n# Call LLM\r\nresponse = client.chat.completions.create(\r\n    model=\"gpt-4o\",\r\n    messages=messages,\r\n)\r\n```\r\n\r\n`chunks_to_messages` takes in an optional `text_only` parameter to only output text from the source document. This is useful for downstream use with LLMs that lack multimodal capabilities.\r\n\r\n> ⚠️ **It is important to be mindful of your model's token limit.**\r\n> Be sure your prompt is within the token limit of your model. You can use chunking to split your messages into smaller chunks.\r\n\r\n### LLamaIndex Integration 🦙\r\n\r\nInstall the optional extra and then call `.to_llamaindex`:\r\n\r\n```bash\r\npip install thepipe-api[llama-index]\r\n```\r\n\r\nAfter installation, a chunk can be converted to LlamaIndex `Document`\u002F`ImageDocument` with `.to_llamaindex`. Without the extra, a helpful error is raised instead of failing at import time.\r\n\r\n### Structured extraction 🗂️\r\n\r\nNote that structured extraction is being deprecated and will be removed in future releases. The current implementation is a simple wrapper around OpenAI's chat API, which is not ideal for structured data extraction. We recommend OpenAI's [structured outputs](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Fstructured-outputs?api-mode=chat) for structured data extraction, or using [Trellis AI](https:\u002F\u002Fruntrellis.com\u002F) for automated workflows with structured data.\r\n\r\n```python\r\nfrom thepipe.extract import extract\r\nfrom openai import OpenAI\r\n\r\nclient = OpenAI()\r\n\r\nschema = {\r\n  \"description\": \"string\",\r\n  \"amount_usd\": \"float\"\r\n}\r\n\r\nresults, tokens_used = extract(\r\n    chunks=chunks,\r\n    schema=schema,\r\n    multiple_extractions=True,  # extract multiple rows of data per chunk\r\n    openai_client=client\r\n)\r\n```\r\n\r\n## Running the test suite 🧪\r\n\r\nInstall the base requirements plus any extras you rely on, then execute:\r\n\r\n```bash\r\npip install -r requirements.txt\r\npython -m unittest discover\r\n```\r\n\r\nTests that depend on optional extras (Whisper, Sentence Transformers, LlamaIndex) or an OpenAI API key are skipped automatically when the corresponding dependency is unavailable.\r\n\r\n## Sponsors\r\n\r\nPlease consider supporting thepipe by [becoming a sponsor](mailto:emmett@thepi.pe).\r\nYour support helps me maintain and improve the project while helping the open-source community discover your work.\r\n\r\nVisit [Cal.com](https:\u002F\u002Fcal.com\u002F) for an open-source scheduling tool that helps you book meetings with ease. It's the perfect solution for busy professionals who want to streamline their scheduling process.\r\n\r\n\u003Ca href=\"https:\u002F\u002Fcal.com\u002Femmett-mcf\u002F30min\">\u003Cimg alt=\"Book us with Cal.com\" src=\"https:\u002F\u002Fcal.com\u002Fbook-with-cal-dark.svg\" \u002F>\u003C\u002Fa>\r\n\r\nLooking for enterprise-ready document processing and intelligent automation? Discover how [Trellis AI](https:\u002F\u002Fruntrellis.com\u002F) can streamline your workflows and enhance productivity.\r\n\r\n## How it works 🛠️\r\n\r\nthepipe uses a combination of computer-vision models and heuristics to scrape clean content from the source and process it for downstream use with [large language models](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FLarge_language_model), or [vision-language models](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FVision_transformer). You can feed these messages directly into the model, or alternatively you can chunk these messages for downstream storage in a vector database such as ChromaDB, LLamaIndex, or an equivalent RAG framework.\r\n\r\n## Supported File Types 📚\r\n\r\n| Source                       | Input types                                                                          | Multimodal | Notes                                                                                                                                                                                                                                         |\r\n| ---------------------------- | ------------------------------------------------------------------------------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\r\n| Webpage                      | URLs starting with `http`, `https`, `ftp`                                            | ✔️         | Scrapes markdown, images, and tables from web pages. AI extraction available by passing an OpenAI client for screenshot analysis                                                                                                              |\r\n| PDF                          | `.pdf`                                                                               | ✔️         | Extracts page markdown and page images. AI extraction available when an OpenAI client is supplied for complex or scanned documents                                                                                                            |\r\n| Word Document                | `.docx`                                                                              | ✔️         | Extracts text, tables, and images                                                                                                                                                                                                             |\r\n| PowerPoint                   | `.pptx`                                                                              | ✔️         | Extracts text and images from slides                                                                                                                                                                                                          |\r\n| Video                        | `.mp4`, `.mov`, `.wmv`                                                               | ✔️         | Uses Whisper for transcription and extracts frames                                                                                                                                                                                            |\r\n| Audio                        | `.mp3`, `.wav`                                                                       | ✔️         | Uses Whisper for transcription                                                                                                                                                                                                                |\r\n| Jupyter Notebook             | `.ipynb`                                                                             | ✔️         | Extracts markdown, code, outputs, and images                                                                                                                                                                                                  |\r\n| Spreadsheet                  | `.csv`, `.xls`, `.xlsx`                                                              | ❌         | Converts each row to JSON format, including row index for each                                                                                                                                                                                |\r\n| Plaintext                    | `.txt`, `.md`, `.rtf`, etc                                                           | ❌         | Simple text extraction                                                                                                                                                                                                                        |\r\n| Image                        | `.jpg`, `.jpeg`, `.png`                                                              | ✔️         | Uses VLM for OCR in text-only mode                                                                                                                                                                                                            |\r\n| ZIP File                     | `.zip`                                                                               | ✔️         | Extracts and processes contained files                                                                                                                                                                                                        |\r\n| Directory                    | any `path\u002Fto\u002Ffolder`                                                                 | ✔️         | Recursively processes all files in directory. Optionally use `inclusion_pattern` to pass regex strings for file inclusion rules.                                                                                                              |\r\n| YouTube Video (known issues) | YouTube video URLs starting with `https:\u002F\u002Fyoutube.com` or `https:\u002F\u002Fwww.youtube.com`. | ✔️         | Uses pytube for video download and Whisper for transcription. For consistent extraction, you may need to modify your `pytube` installation to send a valid user-agent header (see [this issue](https:\u002F\u002Fgithub.com\u002Fpytube\u002Fpytube\u002Fissues\u002F399)). |\r\n| Tweet                        | URLs starting with `https:\u002F\u002Ftwitter.com` or `https:\u002F\u002Fx.com`                          | ✔️         | Uses unofficial API, may break unexpectedly                                                                                                                                                                                                   |\r\n| GitHub Repository            | GitHub repo URLs starting with `https:\u002F\u002Fgithub.com` or `https:\u002F\u002Fwww.github.com`      | ✔️         | Requires `GITHUB_TOKEN` environment variable                                                                                                                                                                                                  |\r\n\r\n## Configuration & Environment\r\n\r\nSet these environment variables to control API keys, hosting, and model defaults:\r\n\r\n```bash\r\n# If you want longer-term image storage and hosting (saves to .\u002Fimages and serves via HOST_URL)\r\nexport HOST_IMAGES=true\r\n\r\n# GitHub token for scraping private\u002Fpublic repos via `scrape_url`\r\nexport GITHUB_TOKEN=ghp_...\r\n\r\n# Control scraping defaults\r\nexport DEFAULT_AI_MODEL=gpt-4o\r\nexport DEFAULT_EMBEDDING_MODEL=sentence-transformers\u002Fall-MiniLM-L6-v2\r\nexport FILESIZE_LIMIT_MB=50\r\n\r\n# Max duration (in seconds) for audio transcription\r\nexport MAX_WHISPER_DURATION=600\r\n\r\n# Filesize limit for webpages in mb\r\nexport FILESIZE_LIMIT_MB = 50\r\n\r\n# Credientials for scraping repositories\r\nexport GITHUB_TOKEN=...\r\n```\r\n\r\n## CLI Usage\r\n\r\n`thepipe \u003Csource> [options]`\r\n\r\n### AI scraping options\r\n\r\n`--openai-api-key=KEY` To enable VLM scraping, pass in your OpenAI API key\r\n\r\n`--openai-model=MODEL` Model to use for scraping (default is `DEFAULT_AI_MODEL`, currently `gpt-4o`)\r\n\r\n`--openai-base-url=URL` Custom LLM endpoint, for local LLMs or hosted APIs like OpenRouter (default: https:\u002F\u002Fapi.openai.com\u002Fv1)\r\n\r\n`--ai_extraction` ⚠️ DEPRECATED; will get API key from `OPENAI_API_KEY` environment variable\r\n\r\n### General scraping options\r\n\r\n`--text_only` Output text only (suppress images)\r\n\r\n`--inclusion_pattern=REGEX` Include only files whose \\_full path\\* matches REGEX (for dirs\u002Fzips)\r\n\r\n`--verbose` Print detailed progress messages\r\n\r\n## Contributing\r\n\r\nThis package is quite opinionated in its design and implementation. Some modules are tightly coupled to the overall architecture, while others are designed to be hacked.\r\n\r\nBefore contributing, please create an issue on GitHub to discuss your ideas and how to best implement them. Pull requests that do not follow this process will be closed.\r\n","\u003Cdiv align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fthepi.pe\u002F\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Femcf_thepipe_readme_8c602661cb5c.png\" alt=\"Pipeline Illustration\" style=\"width:96px; height:72px; vertical-align:middle;\">\n    \u003Ch1>thepi.pe\u003C\u002Fh1>\n  \u003C\u002Fa>\n  \u003Ca>\n    \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Factions\u002Fworkflows\u002Fpython-ci.yml\u002Fbadge.svg\" alt=\"python-gh-action\">\n  \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fcodecov.io\u002Fgh\u002Femcf\u002Fthepipe\">\n    \u003Cimg src=\"https:\u002F\u002Fcodecov.io\u002Fgh\u002Femcf\u002Fthepipe\u002Fgraph\u002Fbadge.svg?token=OE7CUEFUL9\" alt=\"codecov\">\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fraw.githubusercontent.com\u002Femcf\u002Fthepipe\u002Fmain\u002FLICENSE\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green\" alt=\"MIT license\">\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fwww.pepy.tech\u002Fprojects\u002Fthepipe-api\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Femcf_thepipe_readme_8580daf15142.png\" alt=\"PyPI\">\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n## 从复杂文档中提取干净数据 ⚡\n\nthepi.pe 是一个能够从复杂文档中抓取干净的 Markdown、多模态媒体和结构化数据的工具包。它在底层使用视觉语言模型（VLM）以实现更高质量的输出，并且可以与任何 LLM、VLM 或向量数据库开箱即用。它可以从多种来源中提取格式良好的数据，包括 PDF、URL、Word 文档、PowerPoint 演示文稿、Python 笔记本、视频、音频等。\n\n## 特性 🌟\n\n- 从任何文档中抓取干净的 Markdown、表格和图片\n- 从任何文件或 URL 中抓取文本、图片、视频和音频\n- 可与视觉语言模型、向量数据库和 RAG 框架开箱即用\n- 原生 AI 的文件类型检测、布局分析和结构化数据提取\n- 支持广泛的输入源，包括 PDF、URL、Word 文档、PowerPoint 演示文稿、Python 笔记本、GitHub 仓库、视频、音频等\n\n## 5 分钟快速入门 🚀\n\n可以通过命令行安装 thepipe：\n\n```bash\npip install thepipe-api\n```\n\n默认安装仅包含对 CPU 友好的依赖项，因此适用于资源受限的环境和 CI 系统。而像 PyTorch 和 Triton 这样的 GPU 加速库则作为可选依赖项提供。\n\n### 可选依赖\n\n该包提供了一系列可选依赖，允许用户按需选择更重的依赖：\n\n| 选项                      | 安装内容                                  | 适用场景                                        |\n| -------------------------- | ----------------------------------------- | ----------------------------------------------------- |\n| `thepipe-api[audio]`       | `openai-whisper`                          | 使用 Whisper 进行本地音频\u002F视频转录。          |\n| `thepipe-api[semantic]`    | `sentence-transformers`                   | 使用 Transformer 嵌入进行语义分块。        |\n| `thepipe-api[llama-index]` | `llama-index`                             | 将 `Chunk` 转换为 `LlamaIndex` 格式。                  |\n| `thepipe-api[gpu]`         | PyTorch + Whisper + Sentence Transformers | 全面 GPU 加速，适用于 VLM 微调任务。 |\n\n如果您使用的机器仅支持 CPU，但仍需要依赖 PyTorch 的功能，请先从 PyTorch 官方索引直接安装 CPU 版本的轮子，然后再添加相应的额外依赖。例如：\n\n```bash\npip install torch==2.5.1+cpu torchvision==0.20.1+cpu torchaudio==2.5.1+cpu \\\n  --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\npip install thepipe-api[semantic]\n```\n\n如果需要处理包含丰富媒体的来源，如网页、视频和音频，您可以选择安装以下系统依赖：\n\n```bash\napt-get update && apt-get install -y git ffmpeg\npython -m playwright install --with-deps chromium\n```\n\n然后使用全局安装方式通过 pip 安装：\n\n```bash\npip install thepipe-api[all]\n```\n\n### 默认设置（OpenAI）\n\n默认情况下，thepi.pe 使用 [OpenAI API](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Foverview)，因此只要传入 OpenAI 客户端，VLM 功能即可开箱即用。\n\n### 自定义 VLM 服务器设置（OpenRouter、OpenLLM 等）\n\n如果您希望使用本地视觉语言模型或其他云服务提供商，可以提供自定义的 OpenAI 客户端。例如，将基础 URL 设置为 `https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1` 以使用 [OpenRouter](https:\u002F\u002Fopenrouter.ai\u002F)；或者设置为 `http:\u002F\u002Flocalhost:3000\u002Fv1` 来连接本地服务器，如 [OpenLLM](https:\u002F\u002Fgithub.com\u002Fbentoml\u002FOpenLLM)。请注意，您还需要将非 OpenAI 云服务提供商的 API 密钥传递给 OpenAI 客户端。模型名称可以通过 `model` 参数进行更改，默认为 `gpt-4o`。\n\n### 抓取\n\n```python\nfrom thepipe.scraper import scrape_file\n\n# 从 PDF 中抓取文本和页面图片\nchunks = scrape_file(filepath=\"paper.pdf\")\n```\n\n若要使用视觉语言模型增强抓取效果，可以传入兼容 OpenAI 的客户端和模型名称。\n\n```python\nfrom openai import OpenAI\nfrom thepipe.scraper import scrape_file\n\n# 创建一个兼容 OpenAI 的客户端\nclient = OpenAI()\n\n# 从 PDF 中抓取干净的 Markdown 和页面图片\nchunks = scrape_file(\n  filepath=\"paper.pdf\",\n  openai_client=client,\n  model=\"gpt-4o\"\n)\n```\n\n### 分块\n\n为了满足 token 数量限制，提供了以下几种分块方法，可以将内容拆分为更小的片段：\n\n- `chunk_by_document`: 返回包含整个文件内容的一个块。\n- `chunk_by_page`: 按每页返回一个块（例如：每个网页、PDF 页面或 PowerPoint 幻灯片）。\n- `chunk_by_length`: 按长度分割块。\n- `chunk_by_section`: 按 Markdown 段落分割块。\n- `chunk_by_keyword`: 在关键词处分割块。\n- `chunk_semantic`（实验性功能，需安装 [sentence-transformers](https:\u002F\u002Fpypi.org\u002Fproject\u002Fsentence-transformers\u002F)）：根据语义变化的突变点分割块，可配置阈值。\n- `chunk_agentic`（实验性功能，需安装 [OpenAI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fopenai\u002F)）：由 LLM 代理尝试找到语义上有意义的部分来分割块。\n\n例如：\n\n```python\nfrom thepipe.scraper import scrape_file\nfrom thepipe.chunker import chunk_by_document, chunk_by_page\n\n# 可选地指定分块方法\n# chunk_by_document 返回整个文档的一个块\nchunks = scrape_file(\n  filepath=\"paper.pdf\",\n  chunking_method=chunk_by_document\n)\n\n# 也可以稍后再重新分块。\n# chunk_by_page 每页返回一个块（例如：每个网页、PDF 页面或 PowerPoint 幻灯片）。\nchunks = chunk_by_page(chunks)\n```\n\n### OpenAI 聊天集成 🤖\n\n```python\nfrom openai import OpenAI\nfrom thepipe.core import chunks_to_messages\n\n# 初始化 OpenAI 客户端\nclient = OpenAI()\n\n# 使用 OpenAI 格式的聊天消息\nmessages = [{\n  \"role\": \"user\",\n  \"content\": [{\n      \"type\": \"text\",\n      \"text\": \"这篇论文讲的是什么？\"\n    }]\n}]\n\n# 直接将抓取到的块添加到消息中\nmessages += chunks_to_messages(chunks)\n\n# 调用大语言模型\nresponse = client.chat.completions.create(\n    model=\"gpt-4o\",\n    messages=messages,\n)\n```\n\n\n`chunks_to_messages` 接受一个可选的 `text_only` 参数，用于仅输出源文档中的文本内容。这对于下游使用缺乏多模态能力的大语言模型非常有用。\n\n> ⚠️ **务必注意模型的令牌限制。**\n> 请确保您的提示词在模型的令牌限制范围内。您可以通过分块将消息拆分为更小的片段。\n\n### LLamaIndex 集成 🦙\n\n安装可选的额外依赖项，然后调用 `.to_llamaindex`：\n\n```bash\npip install thepipe-api[llama-index]\n```\n\n安装完成后，可以使用 `.to_llamaindex` 将分块转换为 LlamaIndex 的 `Document` 或 `ImageDocument`。如果没有安装该额外依赖，系统会抛出一条友好的错误信息，而不是在导入时直接失败。\n\n### 结构化提取 🗂️\n\n请注意，结构化提取功能即将弃用，并将在未来的版本中移除。当前的实现只是对 OpenAI 聊天 API 的简单封装，这并不适合用于结构化数据的提取。我们建议使用 OpenAI 的 [结构化输出](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Fstructured-outputs?api-mode=chat) 功能来进行结构化数据提取，或者使用 [Trellis AI](https:\u002F\u002Fruntrellis.com\u002F) 来构建基于结构化数据的自动化工作流。\n\n```python\nfrom thepipe.extract import extract\nfrom openai import OpenAI\n\nclient = OpenAI()\n\nschema = {\n  \"description\": \"string\",\n  \"amount_usd\": \"float\"\n}\n\nresults, tokens_used = extract(\n    chunks=chunks,\n    schema=schema,\n    multiple_extractions=True,  # 每个分块提取多行数据\n    openai_client=client\n)\n```\n\n## 运行测试套件 🧪\n\n安装基础依赖以及您所依赖的任何额外依赖，然后执行以下命令：\n\n```bash\npip install -r requirements.txt\npython -m unittest discover\n```\n\n依赖于可选额外组件（如 Whisper、Sentence Transformers、LlamaIndex）或 OpenAI API 密钥的测试，在相应依赖不可用时会自动跳过。\n\n## 赞助商\n\n请考虑通过 [成为赞助商](mailto:emmett@thepi.pe) 来支持 thepipe。您的支持不仅有助于我维护和改进该项目，还能帮助开源社区发现您的工作成果。\n\n访问 [Cal.com](https:\u002F\u002Fcal.com\u002F)，这是一款开源的日程安排工具，可帮助您轻松预约会议。对于希望简化日程安排流程的繁忙专业人士来说，它是一个理想的解决方案。\n\n\u003Ca href=\"https:\u002F\u002Fcal.com\u002Femmett-mcf\u002F30min\">\u003Cimg alt=\"使用 Cal.com 与我们预约\" src=\"https:\u002F\u002Fcal.com\u002Fbook-with-cal-dark.svg\" \u002F>\u003C\u002Fa>\n\n如果您正在寻找企业级的文档处理和智能自动化解决方案，请了解 [Trellis AI](https:\u002F\u002Fruntrellis.com\u002F) 如何优化您的工作流程并提升生产力。\n\n## 工作原理 🛠️\n\nthepipe 结合计算机视觉模型和启发式规则，从源文档中提取干净的内容，并将其处理以供下游使用，例如大型语言模型（LLM）或视觉-语言模型（VLM）。您可以将这些消息直接输入到模型中，也可以先对其进行分块，然后存储到向量数据库中，比如 ChromaDB、LLamaIndex 或其他类似的 RAG 框架。\n\n## 支持的文件类型 📚\n\n| 来源                       | 输入类型                                                                          | 多模态 | 备注                                                                                                                                                                                                                                         |\n| ---------------------------- | ------------------------------------------------------------------------------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| 网页                      | 以 `http`、`https`、`ftp` 开头的 URL                                            | ✔️         | 从网页中抓取 Markdown、图片和表格。通过传递 OpenAI 客户端进行截图分析，可实现 AI 提取功能                                                                                                              |\n| PDF                          | `.pdf`                                                                               | ✔️         | 提取页面的 Markdown 和页面图片。在处理复杂或扫描文档时，若提供 OpenAI 客户端，则可进行 AI 提取                                                                                                            |\n| Word 文档                | `.docx`                                                                              | ✔️         | 提取文本、表格和图片                                                                                                                                                                                                             |\n| PowerPoint                   | `.pptx`                                                                              | ✔️         | 提取幻灯片中的文本和图片                                                                                                                                                                                                          |\n| 视频                        | `.mp4`、`.mov`、`.wmv`                                                               | ✔️         | 使用 Whisper 进行转录，并提取视频帧                                                                                                                                                                                            |\n| 音频                        | `.mp3`、`.wav`                                                                       | ✔️         | 使用 Whisper 进行转录                                                                                                                                                                                                                |\n| Jupyter Notebook             | `.ipynb`                                                                             | ✔️         | 提取 Markdown、代码、输出和图片                                                                                                                                                                                                  |\n| 电子表格                  | `.csv`、`.xls`、`.xlsx`                                                              | ❌         | 将每一行转换为 JSON 格式，包括每行的索引号                                                                                                                                                                                |\n| 纯文本                    | `.txt`、`.md`、`.rtf` 等                                                           | ❌         | 简单的文本提取                                                                                                                                                                                                                        |\n| 图片                        | `.jpg`、`.jpeg`、`.png`                                                              | ✔️         | 在纯文本模式下使用 VLM 进行 OCR                                                                                                                                                                                                            |\n| ZIP 文件                     | `.zip`                                                                               | ✔️         | 解压并处理其中的文件                                                                                                                                                                                                        |\n| 目录                    | 任何 `path\u002Fto\u002Ffolder`                                                                 | ✔️         | 递归处理目录中的所有文件。可选地使用 `inclusion_pattern` 传入正则表达式字符串，以指定包含文件的规则。                                                                                                              |\n| YouTube 视频（已知问题） | 以 `https:\u002F\u002Fyoutube.com` 或 `https:\u002F\u002Fwww.youtube.com` 开头的 YouTube 视频 URL      | ✔️         | 使用 pytube 下载视频，并使用 Whisper 进行转录。为确保提取的一致性，可能需要修改 `pytube` 的安装，以发送有效的用户代理头（参见 [此问题](https:\u002F\u002Fgithub.com\u002Fpytube\u002Fpytube\u002Fissues\u002F399)）。 |\n| 推文                        | 以 `https:\u002F\u002Ftwitter.com` 或 `https:\u002F\u002Fx.com` 开头的 URL                          | ✔️         | 使用非官方 API，可能会意外中断                                                                                                                                                                                                   |\n| GitHub 仓库            | 以 `https:\u002F\u002Fgithub.com` 或 `https:\u002F\u002Fwww.github.com` 开头的 GitHub 仓库 URL      | ✔️         | 需要设置 `GITHUB_TOKEN` 环境变量                                                                                                                                                                                                  |\n\n## 配置与环境\n\n通过设置以下环境变量来控制 API 密钥、托管服务和模型默认值：\n\n```bash\n# 如果希望长期存储和托管图片（保存到 .\u002Fimages 并通过 HOST_URL 提供服务）\nexport HOST_IMAGES=true\n\n# 用于通过 `scrape_url` 抓取私有\u002F公共仓库的 GitHub Token\nexport GITHUB_TOKEN=ghp_...\n\n# 控制抓取的默认设置\nexport DEFAULT_AI_MODEL=gpt-4o\nexport DEFAULT_EMBEDDING_MODEL=sentence-transformers\u002Fall-MiniLM-L6-v2\nexport FILESIZE_LIMIT_MB=50\n\n# 音频转录的最大时长（单位：秒）\nexport MAX_WHISPER_DURATION=600\n\n# 网页文件大小限制（单位：MB）\nexport FILESIZE_LIMIT_MB = 50\n\n# 用于爬取仓库的凭据\nexport GITHUB_TOKEN=...\n```\n\n\n## CLI 使用方法\n\n`thepipe \u003Csource> [options]`\n\n### AI 爬取选项\n\n`--openai-api-key=KEY` 要启用 VLM 爬取，请传入您的 OpenAI API 密钥。\n\n`--openai-model=MODEL` 用于爬取的模型（默认为 `DEFAULT_AI_MODEL`，当前为 `gpt-4o`）。\n\n`--openai-base-url=URL` 自定义 LLM 端点，适用于本地 LLM 或像 OpenRouter 这样的托管 API（默认：https:\u002F\u002Fapi.openai.com\u002Fv1）。\n\n`--ai_extraction` ⚠️ 已弃用；将从 `OPENAI_API_KEY` 环境变量中获取 API 密钥。\n\n### 通用爬取选项\n\n`--text_only` 仅输出文本（禁用图片）\n\n`--inclusion_pattern=REGEX` 只包含其\\_完整路径\\*匹配正则表达式的文件（适用于目录\u002F压缩包）。\n\n`--verbose` 打印详细的进度信息。\n\n## 贡献说明\n\n本包在设计和实现上具有较强的主观性。部分模块与整体架构紧密耦合，而另一些模块则被设计为可灵活修改的。\n\n在贡献代码之前，请先在 GitHub 上创建一个议题，讨论您的想法以及最佳实现方式。未遵循此流程的拉取请求将被关闭。","# thepipe 快速上手指南\n\nthepipe 是一个能够从复杂文档（如 PDF、URL、Word、PPT、视频等）中提取干净 Markdown、多模态媒体和结构化数据的 Python 库。它底层利用视觉语言模型（VLM）确保输出质量，并原生支持各类 LLM、VLM 及向量数据库。\n\n## 环境准备\n\n### 系统要求\n- **Python**: 建议 Python 3.8+\n- **操作系统**: Linux, macOS, Windows\n- **硬件**: 默认安装仅依赖 CPU，适合受限环境。若需 GPU 加速或处理多媒体，需额外配置。\n\n### 前置依赖\n若需完整功能（特别是处理网页、视频和音频），建议在安装前配置以下系统级依赖：\n\n**Linux (Debian\u002FUbuntu):**\n```bash\napt-get update && apt-get install -y git ffmpeg\npython -m playwright install --with-deps chromium\n```\n\n**注意**: 国内用户若遇到 `playwright` 下载慢的问题，可配置国内镜像或使用代理。\n\n## 安装步骤\n\n### 1. 基础安装（推荐）\n默认安装仅包含 CPU 友好的依赖，适合大多数场景：\n\n```bash\npip install thepipe-api\n```\n\n*国内加速建议*:\n```bash\npip install thepipe-api -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 2. 可选扩展安装\n根据需求按需安装重型依赖：\n\n| 扩展名称 | 命令 | 用途 |\n| :--- | :--- | :--- |\n| **音频处理** | `pip install thepipe-api[audio]` | 本地音视频转录 (Whisper) |\n| **语义分块** | `pip install thepipe-api[semantic]` | 基于 Transformer 的语义分块 |\n| **LlamaIndex** | `pip install thepipe-api[llama-index]` | 转换为 LlamaIndex 格式 |\n| **全套功能** | `pip install thepipe-api[all]` | 包含所有上述功能及 GPU 支持 |\n\n**GPU 环境特别说明**:\n若在纯 CPU 机器上需要 PyTorch 相关功能，请先安装 CPU 版 PyTorch：\n```bash\npip install torch==2.5.1+cpu torchvision==0.20.1+cpu torchaudio==2.5.1+cpu --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\npip install thepipe-api[semantic]\n```\n\n## 基本使用\n\n### 1. 配置 API Key\nthepipe 默认使用 OpenAI 兼容接口。请确保环境变量中已设置 `OPENAI_API_KEY`，或在代码中传入客户端。若使用国内大模型或其他兼容接口（如 OpenRouter），可自定义 `base_url`。\n\n### 2. 提取文档内容\n以下示例展示如何从 PDF 中提取干净的 Markdown 和图片块：\n\n```python\nfrom openai import OpenAI\nfrom thepipe.scraper import scrape_file\n\n# 初始化 OpenAI 兼容客户端\n# 若使用非 OpenAI 服务，可指定 base_url，例如: base_url=\"https:\u002F\u002Fapi.moonshot.cn\u002Fv1\"\nclient = OpenAI()\n\n# 提取内容\nchunks = scrape_file(\n    filepath=\"paper.pdf\",       # 支持 pdf, docx, url, mp4 等\n    openai_client=client,       # 传入客户端以启用 VLM 增强提取\n    model=\"gpt-4o\"              # 指定模型，默认为 gpt-4o\n)\n\n# 打印提取结果\nfor chunk in chunks:\n    print(chunk.text)\n    if chunk.images:\n        print(f\"Found {len(chunk.images)} images\")\n```\n\n### 3. 对接 LLM 进行问答\n将提取的内容直接转换为 Chat 消息格式，发送给大模型：\n\n```python\nfrom openai import OpenAI\nfrom thepipe.core import chunks_to_messages\n\nclient = OpenAI()\n\n# 构建提示词\nmessages = [{\n    \"role\": \"user\",\n    \"content\": [{\"type\": \"text\", \"text\": \"这篇论文主要讲了什么？\"}]\n}]\n\n# 将提取的块转换为消息格式并追加\nmessages += chunks_to_messages(chunks)\n\n# 调用大模型\nresponse = client.chat.completions.create(\n    model=\"gpt-4o\",\n    messages=messages,\n)\n\nprint(response.choices[0].message.content)\n```\n\n### 4. 内容分块 (Chunking)\n为避免超出 Token 限制，可使用内置方法对内容进行分块：\n\n```python\nfrom thepipe.chunker import chunk_by_page\n\n# 按页分块（适用于 PDF、PPT 或网页）\npaginated_chunks = chunk_by_page(chunks)\n```","某金融风控团队需要每天从数百份格式各异的招股说明书、扫描版财报 PDF 及嵌入图表的 PPT 中提取关键财务数据，以构建企业知识图谱。\n\n### 没有 thepipe 时\n- 传统 OCR 工具无法识别复杂排版，导致表格行列错乱，数字与对应科目经常错位，人工校验耗时极长。\n- 遇到扫描件中的手写批注或模糊图表时，提取程序直接报错或输出乱码，大量非结构化数据被迫丢弃。\n- 为处理不同文件格式（PDF、PPT、图片），团队需维护多套独立的解析脚本，代码耦合度高且难以扩展。\n- 提取后的文本缺乏语义结构，直接存入向量数据库后，RAG 检索经常返回无关片段，严重影响问答准确率。\n\n### 使用 thepipe 后\n- thepipe 利用视觉语言模型精准还原文档布局，即使面对复杂的跨页表格和混合图文，也能输出格式完美的 Markdown。\n- 能够“看懂”模糊图表和手写注释，自动将其转化为详细的文字描述或结构化数据，显著提升了数据利用率。\n- 一套接口即可统一处理 PDF、URL、Office 文档甚至视频音频，无需针对不同文件类型编写重复的解析逻辑。\n- 原生支持语义分块并直接对接主流向量数据库，生成的数据自带清晰结构，使 RAG 系统的检索命中率大幅提升。\n\nthepipe 将原本需要数天的人工清洗工作缩短至分钟级，让团队能专注于高价值的风险分析而非数据预处理。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Femcf_thepipe_572e81c3.png","emcf","Emmett McFarlane","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Femcf_a1111edc.png","I throw lots of cores at hard problems.",null,"Toronto","emcf.xyz","https:\u002F\u002Fgithub.com\u002Femcf",[81,85,89,93,97,101,104],{"name":82,"color":83,"percentage":84},"Python","#3572A5",96.8,{"name":86,"color":87,"percentage":88},"HTML","#e34c26",2.2,{"name":90,"color":91,"percentage":92},"Jupyter Notebook","#DA5B0B",0.5,{"name":94,"color":95,"percentage":96},"TypeScript","#3178c6",0.3,{"name":98,"color":99,"percentage":100},"CSS","#663399",0.1,{"name":102,"color":103,"percentage":100},"C++","#f34b7d",{"name":105,"color":106,"percentage":107},"C","#555555",0,1522,98,"2026-04-11T10:12:05","MIT","未说明","非必需。默认安装仅包含 CPU 依赖。如需 GPU 加速（运行 VLM 微调、Whisper 或 Sentence Transformers），需额外安装 PyTorch GPU 版本。",{"notes":115,"python":112,"dependencies":116},"1. 默认安装 ('pip install thepipe-api') 仅包含 CPU 友好型依赖，适合受限环境和 CI 系统。\n2. GPU 相关库（PyTorch, Triton 等）作为可选额外依赖，需手动安装（例如：thepipe-api[gpu]）。\n3. 若在纯 CPU 机器上需要使用依赖 PyTorch 的功能，建议先从 PyTorch 索引安装 CPU 版本的 wheel，再安装 extras。\n4. 处理富媒体源（网页、视频、音频）时，需预先安装系统级依赖：git, ffmpeg 以及 playwright (含 chromium)。\n5. 默认使用 OpenAI API 进行视觉语言模型 (VLM) 处理，也支持配置自定义兼容 OpenAI 接口的本地或云端服务（如 OpenRouter, OpenLLM）。",[117,118,119,120,121,122,123,124,125],"openai-whisper (可选，音频处理)","sentence-transformers (可选，语义分块)","llama-index (可选，框架集成)","torch (可选，GPU 加速)","torchvision (可选，GPU 加速)","torchaudio (可选，GPU 加速)","playwright (系统依赖，用于网页抓取)","ffmpeg (系统依赖，用于媒体处理)","git (系统依赖)",[16,27,127,36],"其他",[129,130,131,132,133,134,135,136,137,138,139,140,141],"multimodal","pdf","vision-transformer","large-language-models","web","scrapers","document","openai","python","scraping","vision-language-model","structured-data","unstructured-data","2026-03-27T02:49:30.150509","2026-04-15T06:12:45.521431",[145,150,155,160,165,170],{"id":146,"question_zh":147,"answer_zh":148,"source_url":149},33726,"ThePipe 是否支持音频文件（如 mp3、wav）的转录？","已支持。通过 PR #12 实现了对 mp3 和 wav 等音频格式的支持，底层使用 Whisper 模型将音频转录为文本。用户可以直接使用 thepipe 命令处理音频文件进行转录。","https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Fissues\u002F8",{"id":151,"question_zh":152,"answer_zh":153,"source_url":154},33721,"设置 THEPIPE_API_KEY 环境变量后仍然报错找不到变量怎么办？","必须设置系统级的环境变量，而不是仅在 .env 文件中设置。在 Linux\u002FMac 上，需要在终端执行 `export THEPIPE_API_KEY=yourkeyhere` 或将其添加到 .bashrc 中并重启终端。如果密钥无效也会报此错误，请确保密钥格式正确。项目特定的密钥支持正在改进中，目前建议使用系统级变量。","https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Fissues\u002F9",{"id":156,"question_zh":157,"answer_zh":158,"source_url":159},33722,"使用 extract_from_chunk() 函数时遇到 'list' object has no attribute 'to_message' 错误如何解决？","该错误是因为传递了列表而不是单个 chunk 对象，且 schema 参数传入了字符串而非字典。解决方法：1) 确保传递给 extract_from_chunk 的是单个 chunk 对象；2) schema 参数必须是字典格式，例如 `{\"section_title\": \"string\", \"content\": \"string\"}`。推荐直接在提取函数中指定分块方法，示例代码：\nfrom thepipe.chunker import chunk_by_page\nresults = extract_from_file(\"example.pdf\", schema={\"section_title\": \"string\", \"content\": \"string\"}, chunking_method=chunk_by_page)","https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Fissues\u002F31",{"id":161,"question_zh":162,"answer_zh":163,"source_url":164},33723,"如何从 PDF 文档中提取图片并在生成的 Markdown 中引用它们的位置？","ThePipe 目前的文档已过时，该功能已变更不再直接支持。维护者推荐使用 Vik Parachuri 开发的 Surya 包（https:\u002F\u002Fgithub.com\u002FVikParuchuri\u002Fsurya）来实现高质量的图片提取功能。","https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Fissues\u002F30",{"id":166,"question_zh":167,"answer_zh":168,"source_url":169},33724,"批量提取目录文件时，如果其中一个文件失败会导致整个任务中断吗？","早期版本存在此问题，但已在 commit 09ac89f037913a7ca1ce60fbc9febc22ea083da0 中修复。现在即使部分文件处理失败，程序也会继续处理其他文件并输出已成功提取的内容，不会因单个文件错误而终止整个目录提取任务。","https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Fissues\u002F25",{"id":171,"question_zh":172,"answer_zh":173,"source_url":174},33725,"本地使用 OpenAI API 处理图像时报错消息语法不正确怎么办？","此问题在主分支中已解决。如果遇到类似问题，需确保 process_page() 函数中构建的 messages 符合 OpenAI 的多模态输入格式：content 字段应为列表，包含 text 类型和 image_url 类型的对象。image_url 的值需是 base64 编码的图片数据。建议更新到最新版本以获取修复。","https:\u002F\u002Fgithub.com\u002Femcf\u002Fthepipe\u002Fissues\u002F33",[]]