[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-yihong0618--bilingual_book_maker":3,"tool-yihong0618--bilingual_book_maker":64},[4,17,27,35,44,52],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},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 真正成长为懂上",153609,2,"2026-04-13T11:34:59",[13,14,15],"开发框架","Agent","语言模型","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":10,"last_commit_at":23,"category_tags":24,"status":16},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",[25,14,26,13],"插件","图像",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":10,"last_commit_at":33,"category_tags":34,"status":16},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",[25,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":41,"last_commit_at":42,"category_tags":43,"status":16},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,3,"2026-04-06T11:19:32",[15,26,14,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":16},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",[13,15],{"id":53,"name":54,"github_repo":55,"description_zh":56,"stars":57,"difficulty_score":10,"last_commit_at":58,"category_tags":59,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",85092,"2026-04-10T11:13:16",[26,60,61,25,14,62,15,13,63],"数据工具","视频","其他","音频",{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":81,"owner_email":82,"owner_twitter":76,"owner_website":83,"owner_url":84,"languages":85,"stars":97,"forks":98,"last_commit_at":99,"license":100,"difficulty_score":10,"env_os":101,"env_gpu":102,"env_ram":102,"env_deps":103,"category_tags":112,"github_topics":113,"view_count":10,"oss_zip_url":113,"oss_zip_packed_at":113,"status":16,"created_at":114,"updated_at":115,"faqs":116,"releases":157},7192,"yihong0618\u002Fbilingual_book_maker","bilingual_book_maker","Make bilingual epub books Using AI translate","bilingual_book_maker 是一款利用人工智能技术，帮助用户轻松制作双语电子书的开源工具。它能自动读取 epub、txt、srt 甚至 pdf 格式的文档，调用大语言模型进行翻译，并生成保留原文与译文对照的双语版本文件。\n\n对于想要阅读外文原著但受限于语言能力的读者，或是希望快速本地化公开领域作品的爱好者来说，它解决了传统人工翻译耗时费力、机器翻译结果难以排版对齐的痛点。用户无需具备深厚的编程背景，只需简单的命令行操作，即可将《动物农场》等公版书籍转化为适合自己的双语学习资料。\n\n这款工具特别适合普通读者、语言学习者以及关注公版作品数字化的社区成员使用。其核心亮点在于广泛的模型兼容性：不仅支持 OpenAI 的 GPT-4\u002F3.5 系列，还通过 liteLLM 架构无缝集成了 Claude、Gemini、通义千问等多种主流模型，甚至包含 DeepL 和彩云小译等专业翻译接口。此外，它智能设计了 API 密钥轮询机制，能有效平衡请求负载，避免因调用频率限制导致的中断，让长文档的翻译过程更加稳定流畅。无论是为了个人学习还是知识分享，bilingual_book_maker 都","bilingual_book_maker 是一款利用人工智能技术，帮助用户轻松制作双语电子书的开源工具。它能自动读取 epub、txt、srt 甚至 pdf 格式的文档，调用大语言模型进行翻译，并生成保留原文与译文对照的双语版本文件。\n\n对于想要阅读外文原著但受限于语言能力的读者，或是希望快速本地化公开领域作品的爱好者来说，它解决了传统人工翻译耗时费力、机器翻译结果难以排版对齐的痛点。用户无需具备深厚的编程背景，只需简单的命令行操作，即可将《动物农场》等公版书籍转化为适合自己的双语学习资料。\n\n这款工具特别适合普通读者、语言学习者以及关注公版作品数字化的社区成员使用。其核心亮点在于广泛的模型兼容性：不仅支持 OpenAI 的 GPT-4\u002F3.5 系列，还通过 liteLLM 架构无缝集成了 Claude、Gemini、通义千问等多种主流模型，甚至包含 DeepL 和彩云小译等专业翻译接口。此外，它智能设计了 API 密钥轮询机制，能有效平衡请求负载，避免因调用频率限制导致的中断，让长文档的翻译过程更加稳定流畅。无论是为了个人学习还是知识分享，bilingual_book_maker 都让跨语言阅读变得触手可及。","**[中文](.\u002FREADME-CN.md) | English**\n[![litellm](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%20%F0%9F%9A%85%20liteLLM-OpenAI%7CAzure%7CAnthropic%7CPalm%7CCohere%7CReplicate%7CHugging%20Face-blue?color=green)](https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm)\n\n# bilingual_book_maker\n\nThe bilingual_book_maker is an AI translation tool that uses ChatGPT to assist users in creating multi-language versions of epub\u002Ftxt\u002Fsrt\u002Fpdf files and books. This tool is exclusively designed for translating epub and other public domain works and is not intended for copyrighted works. Before using this tool, please review the project's **[disclaimer](.\u002Fdisclaimer.md)**.\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyihong0618_bilingual_book_maker_readme_a27146aa5a7e.png)\n\n## Supported Models\n\ngpt-5-mini, gpt-4, gpt-3.5-turbo, claude-2, palm, llama-2, azure-openai, command-nightly, gemini, qwen-mt-turbo, qwen-mt-plus\nFor using Non-OpenAI models, use class `liteLLM()` - liteLLM supports all models above.\nFind more info here for using liteLLM: https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm\u002Fblob\u002Fmain\u002Fsetup.py\n\n## Preparation\n\n1. ChatGPT or OpenAI token [^token]\n2. epub\u002Ftxt\u002Fpdf books\n3. Environment with internet access or proxy\n4. Python 3.8+\n\n## Quick Start\n\nA sample book, `test_books\u002Fanimal_farm.epub`, is provided for testing purposes.\n\n```shell\npip install -r requirements.txt\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --test\nOR\npip install -U bbook_maker\nbbook --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --test\n```\n\n## Translate Service\n\n- Use `--openai_key` option to specify OpenAI API key. If you have multiple keys, separate them by commas (xxx,xxx,xxx) to reduce errors caused by API call limits.\n  Or, just set environment variable `BBM_OPENAI_API_KEY` instead.\n- A sample book, `test_books\u002Fanimal_farm.epub`, is provided for testing purposes.\n- The default underlying model is [GPT-3.5-turbo](https:\u002F\u002Fopenai.com\u002Fblog\u002Fintroducing-chatgpt-and-whisper-apis), which is used by ChatGPT currently. Use `--model gpt4` to change the underlying model to `GPT4`. You can also use `GPT4omini`.\n- Important to note that `gpt-4` is significantly more expensive than `gpt-4-turbo`, but to avoid bumping into rate limits, we automatically balance queries across `gpt-4-1106-preview`, `gpt-4`, `gpt-4-32k`, `gpt-4-0613`,`gpt-4-32k-0613`.\n- If you want to use a specific model alias with OpenAI (eg `gpt-4-1106-preview` or `gpt-3.5-turbo-0125`), you can use `--model openai --model_list gpt-4-1106-preview,gpt-3.5-turbo-0125`. `--model_list` takes a comma-separated list of model aliases.\n- If using chatgptapi, you can add `--use_context` to add a context paragraph to each passage sent to the model for translation (see below).\n\n* DeepL\n  Support DeepL model [DeepL Translator](https:\u002F\u002Frapidapi.com\u002FsplintPRO\u002Fapi\u002Fdpl-translator) need pay to get the token\n\n  ```\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model deepl --deepl_key ${deepl_key}\n  ```\n\n* DeepL free\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model deeplfree\n  ```\n\n* [Claude](https:\u002F\u002Fconsole.anthropic.com\u002Fdocs)\n\n  Use [Claude](https:\u002F\u002Fconsole.anthropic.com\u002Fdocs) model to translate\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model claude --claude_key ${claude_key}\n  ```\n\n* Google Translate\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model google\n  ```\n\n* Caiyun Translate\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model caiyun --caiyun_key ${caiyun_key}\n  ```\n\n* Gemini\n\n  Support Google [Gemini](https:\u002F\u002Faistudio.google.com\u002Fapp\u002Fapikey) model, use `--model gemini` for Gemini Flash or `--model geminipro` for Gemini Pro.\n  If you want to use a specific model alias with Gemini (eg `gemini-1.5-flash-002` or `gemini-1.5-flash-8b-exp-0924`), you can use `--model gemini --model_list gemini-1.5-flash-002,gemini-1.5-flash-8b-exp-0924`. `--model_list` takes a comma-separated list of model aliases.\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model gemini --gemini_key ${gemini_key}\n  ```\n\n* Qwen\n\n  Support Alibaba Cloud [Qwen-MT](https:\u002F\u002Fbailian.console.aliyun.com\u002F) specialized translation model. Supports 92 languages with features like terminology intervention and translation memory.\n  Use `--model qwen-mt-turbo` for faster\u002Fcheaper translation, or `--model qwen-mt-plus` for higher quality.\n\n  Use `source_lang` to specify the source language explicitly, or leave it empty for auto-detection.\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --qwen_key ${qwen_key} --model qwen-mt-turbo --language \"Simplified Chinese\"\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --qwen_key ${qwen_key} --model qwen-mt-plus --language \"Japanese\" --source_lang \"English\"\n  ```\n\n* [Tencent TranSmart](https:\u002F\u002Ftransmart.qq.com)\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model tencentransmart\n  ```\n\n* [xAI](https:\u002F\u002Fx.ai)\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model xai --xai_key ${xai_key}\n  ```\n\n* [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama)\n\n  Support [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama) self-host models,\n  If ollama server is not running on localhost, use `--api_base http:\u002F\u002Fx.x.x.x:port\u002Fv1` to point to the ollama server address\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --ollama_model ${ollama_model_name}\n  ```\n\n* [groq](https:\u002F\u002Fconsole.groq.com\u002Fkeys)\n\n  GroqCloud currently supports models: you can find from [Supported Models](https:\u002F\u002Fconsole.groq.com\u002Fdocs\u002Fmodels)\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --groq_key [your_key] --model groq --model_list llama3-8b-8192\n  ```\n\n## Use\n\n- Once the translation is complete, a bilingual book named `${book_name}_bilingual.epub` would be generated for EPUB inputs; for TXT\u002FMD\u002FSRT inputs a bilingual text (or subtitle) file named `${book_name}_bilingual.txt` (or `_bilingual.srt`) will be generated. For **PDF inputs** the tool will produce a bilingual `.txt` fallback and will also attempt to create `${book_name}_bilingual.epub` — if EPUB creation fails, the TXT fallback remains so you do not need to retranslate.\n- If there are any errors or you wish to interrupt the translation by pressing `CTRL+C`, a temporary bilingual file (for example `{book_name}_bilingual_temp.epub` or `{book_name}_bilingual_temp.txt`) would be generated. You can simply rename it to any desired name.\n\n## Params\n\n- `--test`:\n\n  Use `--test` option to preview the result if you haven't paid for the service. Note that there is a limit and it may take some time.\n\n- `--language`:\n\n  Set the target language like `--language \"Simplified Chinese\"`. Default target language is `\"Simplified Chinese\"`.\n  Read available languages by helper message: `python make_book.py --help`\n\n- `--proxy`:\n\n  Use `--proxy` option to specify proxy server for internet access. Enter a string such as `http:\u002F\u002F127.0.0.1:7890`.\n\n- `--resume`:\n\n  Use `--resume` option to manually resume the process after an interruption.\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model google --resume\n  ```\n\n- `--translate-tags`:\n\n  epub is made of html files. By default, we only translate contents in `\u003Cp>`.\n  Use `--translate-tags` to specify tags need for translation. Use comma to separate multiple tags.\n  For example: `--translate-tags h1,h2,h3,p,div`\n\n- `--exclude-translate-tags`:\n\n  Use `--exclude-translate-tags` to exclude content within specified HTML tags from translation. This is useful for preserving code blocks, preformatted text, or other special content. Use comma to separate multiple tags.\n  Default: `sup,code`.\n  For example: `--exclude-translate-tags code,pre`\n\n  **Tip**: Use `--exclude-translate-tags \"\"` to translate all content including code blocks (overrides the default exclusion).\n\n- `--book_from`:\n\n  Use `--book_from` option to specify e-reader type (Now only `kobo` is available), and use `--device_path` to specify the mounting point.\n\n- `--api_base`:\n\n  If you want to change api_base like using Cloudflare Workers, use `--api_base \u003CURL>` to support it.\n  **Note: the api url should be '`https:\u002F\u002Fxxxx\u002Fv1`'. Quotation marks are required.**\n\n- `--allow_navigable_strings`:\n\n  If you want to translate strings in an e-book that aren't labeled with any tags, you can use the `--allow_navigable_strings` parameter. This will add the strings to the translation queue. **Note that it's best to look for e-books that are more standardized if possible.**\n\n- `--prompt`:\n\n  To tweak the prompt, use the `--prompt` parameter. Valid placeholders for the `user` role template include `{text}` and `{language}`. It supports a few ways to configure the prompt:\n\n  - If you don't need to set the `system` role content, you can simply set it up like this: `--prompt \"Translate {text} to {language}.\"` or `--prompt prompt_template_sample.txt` (example of a text file can be found at [.\u002Fprompt_template_sample.txt](.\u002Fprompt_template_sample.txt)).\n\n  - If you need to set the `system` role content, you can use the following format: `--prompt '{\"user\":\"Translate {text} to {language}\", \"system\": \"You are a professional translator.\"}'` or `--prompt prompt_template_sample.json` (example of a JSON file can be found at [.\u002Fprompt_template_sample.json](.\u002Fprompt_template_sample.json)).\n  \n  - You can now use [PromptDown](https:\u002F\u002Fgithub.com\u002Fbtfranklin\u002Fpromptdown) format (`.md` files) for more structured prompts: `--prompt prompt_md.prompt.md`. PromptDown supports both traditional system messages and developer messages (used by newer AI models). Example:\n  \n      ```markdown\n      # Translation Prompt\n      \n      ## Developer Message\n      You are a professional translator who specializes in accurate translations.\n      \n      ## Conversation\n      \n      | Role | Content                                                        |\n      | ---- | -------------------------------------------------------------- |\n      | User | Please translate the following text into {language}:\\n\\n{text} |\n      ```\n\n  - You can also set the `user` and `system` role prompt by setting environment variables: `BBM_CHATGPTAPI_USER_MSG_TEMPLATE` and `BBM_CHATGPTAPI_SYS_MSG`.\n\n- `--batch_size`:\n\n  Use the `--batch_size` parameter to specify the number of lines for batch translation (default is 10, currently only effective for txt files).\n\n- `--accumulated_num`:\n\n  Wait for how many tokens have been accumulated before starting the translation. gpt3.5 limits the total_token to 4090. For example, if you use `--accumulated_num 1600`, maybe openai will output 2200 tokens and maybe 200 tokens for other messages in the system messages user messages, 1600+2200+200=4000, So you are close to reaching the limit. You have to choose your own\n  value, there is no way to know if the limit is reached before sending\n\n- `--use_context`:\n\n  prompts the model to create a three-paragraph summary. If it's the beginning of the translation, it will summarize the entire passage sent (the size depending on `--accumulated_num`).\n  For subsequent passages, it will amend the summary to include details from the most recent passage, creating a running one-paragraph context payload of the important details of the entire translated work. This improves consistency of flow and tone throughout the translation. This option is available for all ChatGPT-compatible models and Gemini models.\n\n- `--context_paragraph_limit`:\n\n  Use `--context_paragraph_limit` to set a limit on the number of context paragraphs when using the `--use_context` option.\n\n- `--parallel-workers`:\n\n  Use `--parallel-workers` to enable parallel EPUB chapter processing. Values greater than `1` spin up multiple workers (recommended: `2-4`) and automatically fall back to sequential mode for single-chapter books.\n\n- `--temperature`:\n\n  Use `--temperature` to set the temperature parameter for `chatgptapi`\u002F`gpt4`\u002F`claude` models.\n  For example: `--temperature 0.7`.\n\n- `--block_size`:\n\n  Use `--block_size` to merge multiple paragraphs into one block. This may increase accuracy and speed up the process.\n  For example: `--block_size 5`.\n\n- `--single_translate`:\n\n  Use `--single_translate` to output only the translated book without creating a bilingual version.\n\n- `--translation_style`:\n\n  example: `--translation_style \"color: #808080; font-style: italic;\"`\n\n- `--retranslate \"$translated_filepath\" \"file_name_in_epub\" \"start_str\" \"end_str\"(optional)`:\n\n  Retranslate from start_str to end_str's tag:\n\n  ```shell\n  python3 \"make_book.py\" --book_name \"test_books\u002Fanimal_farm.epub\" --retranslate 'test_books\u002Fanimal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' 'This kind of thing is not a good symptom. Obviously'\n  ```\n\n  Retranslate start_str's tag:\n\n  ```shell\n  python3 \"make_book.py\" --book_name \"test_books\u002Fanimal_farm.epub\" --retranslate 'test_books\u002Fanimal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which'\n  ```\n\n- `--extra_body`:\n\n  Pass additional JSON parameters to the API. This is useful for models that support extra configuration options. Provide a JSON string with the desired parameters.\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --extra_body '{\"chat_template_kwargs\": {\"enable_thinking\": false}}'\n  ```\n\n### Examples\n\n**Note if use `pip install bbook_maker` all commands can change to `bbook_maker args`**\n\n```shell\n# Test quickly\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key}  --test --language zh-hans\n\n# Test quickly for src\npython3 make_book.py --book_name test_books\u002FLex_Fridman_episode_322.srt --openai_key ${openai_key}  --test\n\n# Or translate the whole book\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --language zh-hans\n\n# Or translate the whole book using Gemini flash\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --gemini_key ${gemini_key} --model gemini\n\n# Translate an EPUB with parallel chapter processing\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --parallel-workers 4\n\n# Use a specific list of Gemini model aliases\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --gemini_key ${gemini_key} --model gemini --model_list gemini-1.5-flash-002,gemini-1.5-flash-8b-exp-0924\n\n# Set env OPENAI_API_KEY to ignore option --openai_key\nexport OPENAI_API_KEY=${your_api_key}\n\n# Use the GPT-4 model with context to Japanese\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model gpt4 --use_context --language ja\n\n# Use a specific OpenAI model alias\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model openai --model_list gpt-4-1106-preview --openai_key ${openai_key}\n\n**Note** you can use other `openai like` model in this way\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model openai --model_list yi-34b-chat-0205 --openai_key ${openai_key} --api_base \"https:\u002F\u002Fapi.lingyiwanwu.com\u002Fv1\"\n\n# Use a specific list of OpenAI model aliases\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model openai --model_list gpt-4-1106-preview,gpt-4-0125-preview,gpt-3.5-turbo-0125 --openai_key ${openai_key}\n\n# Use the DeepL model with Japanese\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model deepl --deepl_key ${deepl_key} --language ja\n\n# Use the Claude model with Japanese\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model claude --claude_key ${claude_key} --language ja\n\n# Use the CustomAPI model with Japanese\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model customapi --custom_api ${custom_api} --language ja\n\n# Translate contents in \u003Cdiv> and \u003Cp>\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --translate-tags div,p\n\n# Tweaking the prompt\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --prompt prompt_template_sample.txt\n# or\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --prompt prompt_template_sample.json\n# or\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --prompt \"Please translate \\`{text}\\` to {language}\"\n\n# Translate books download from Rakuten Kobo on kobo e-reader\npython3 make_book.py --book_from kobo --device_path \u002Ftmp\u002Fkobo\n\n# translate txt file\npython3 make_book.py --book_name test_books\u002Fthe_little_prince.txt --test --language zh-hans\n# aggregated translation txt file\npython3 make_book.py --book_name test_books\u002Fthe_little_prince.txt --test --batch_size 20\n\n# Using Caiyun model to translate\n# (the api currently only support: simplified chinese \u003C-> english, simplified chinese \u003C-> japanese)\n# the official Caiyun has provided a test token (3975l6lr5pcbvidl6jl2)\n# you can apply your own token by following this tutorial(https:\u002F\u002Fbobtranslate.com\u002Fservice\u002Ftranslate\u002Fcaiyun.html)\npython3 make_book.py --model caiyun --caiyun_key 3975l6lr5pcbvidl6jl2 --book_name test_books\u002Fanimal_farm.epub\n\n\n# Set env BBM_CAIYUN_API_KEY to ignore option --openai_key\nexport BBM_CAIYUN_API_KEY=${your_api_key}\n\n```\n\nMore understandable example\n\n```shell\npython3 make_book.py --book_name 'animal_farm.epub' --openai_key sk-XXXXX --api_base 'https:\u002F\u002Fxxxxx\u002Fv1'\n\n# Or python3 is not in your PATH\npython make_book.py --book_name 'animal_farm.epub' --openai_key sk-XXXXX --api_base 'https:\u002F\u002Fxxxxx\u002Fv1'\n```\n\nMicrosoft Azure Endpoints\n\n```shell\npython3 make_book.py --book_name 'animal_farm.epub' --openai_key XXXXX --api_base 'https:\u002F\u002Fexample-endpoint.openai.azure.com' --deployment_id 'deployment-name'\n\n# Or python3 is not in your PATH\npython make_book.py --book_name 'animal_farm.epub' --openai_key XXXXX --api_base 'https:\u002F\u002Fexample-endpoint.openai.azure.com' --deployment_id 'deployment-name'\n```\n\n## Docker\n\nYou can use [Docker](https:\u002F\u002Fwww.docker.com\u002F) if you don't want to deal with setting up the environment.\n\n```shell\n# Build image\ndocker build --tag bilingual_book_maker .\n\n# Run container\n# \"$folder_path\" represents the folder where your book file locates. Also, it is where the processed file will be stored.\n\n# Windows PowerShell\n$folder_path=your_folder_path # $folder_path=\"C:\\Users\\user\\mybook\\\"\n$book_name=your_book_name # $book_name=\"animal_farm.epub\"\n$openai_key=your_api_key # $openai_key=\"sk-xxx\"\n$language=your_language # see utils.py\n\ndocker run --rm --name bilingual_book_maker --mount type=bind,source=$folder_path,target='\u002Fapp\u002Ftest_books' bilingual_book_maker --book_name \"\u002Fapp\u002Ftest_books\u002F$book_name\" --openai_key $openai_key --language $language\n\n# Linux\nexport folder_path=${your_folder_path}\nexport book_name=${your_book_name}\nexport openai_key=${your_api_key}\nexport language=${your_language}\n\ndocker run --rm --name bilingual_book_maker --mount type=bind,source=${folder_path},target='\u002Fapp\u002Ftest_books' bilingual_book_maker --book_name \"\u002Fapp\u002Ftest_books\u002F${book_name}\" --openai_key ${openai_key} --language \"${language}\"\n```\n\nFor example:\n\n```shell\n# Linux\ndocker run --rm --name bilingual_book_maker --mount type=bind,source=\u002Fhome\u002Fuser\u002Fmy_books,target='\u002Fapp\u002Ftest_books' bilingual_book_maker --book_name \u002Fapp\u002Ftest_books\u002Fanimal_farm.epub --openai_key sk-XXX --test --test_num 1 --language zh-hant\n```\n\n## Notes\n\n1. API token from free trial has limit. If you want to speed up the process, consider paying for the service or use multiple OpenAI tokens\n2. PR is welcome\n\n# Thanks\n\n- @[yetone](https:\u002F\u002Fgithub.com\u002Fyetone)\n\n# Contribution\n\n- Any issues or PRs are welcome.\n- TODOs in the issue can also be selected.\n- Please run `black make_book.py`[^black] before submitting the code.\n\n# Others better\n\n- 书译 BookTranslator -> [Book Translator](https:\u002F\u002Fwww.booktranslator.app)\n\n## Appreciation\n\nThank you, that's enough.\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyihong0618_bilingual_book_maker_readme_449e55d5aa57.png)\n\n[^token]: https:\u002F\u002Fplatform.openai.com\u002Faccount\u002Fapi-keys\n[^black]: https:\u002F\u002Fgithub.com\u002Fpsf\u002Fblack\n","**[中文](.\u002FREADME-CN.md) | English**\n[![litellm](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%20%F0%9F%9A%85%20liteLLM-OpenAI%7CAzure%7CAnthropic%7CPalm%7CCohere%7CReplicate%7CHugging%20 Face-blue?color=green)](https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm)\n\n# bilingual_book_maker\n\nbilingual_book_maker 是一款基于 ChatGPT 的 AI 翻译工具，旨在帮助用户将 epub、txt、srt 和 pdf 格式的文件及书籍翻译成多种语言版本。本工具仅适用于翻译公共领域的 epub 文件及其他作品，不应用于受版权保护的作品。在使用本工具之前，请仔细阅读项目的 **[免责声明](.\u002Fdisclaimer.md)**。\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyihong0618_bilingual_book_maker_readme_a27146aa5a7e.png)\n\n## 支持的模型\n\ngpt-5-mini、gpt-4、gpt-3.5-turbo、claude-2、palm、llama-2、azure-openai、command-nightly、gemini、qwen-mt-turbo、qwen-mt-plus  \n对于非 OpenAI 模型，可以使用 `liteLLM()` 类——liteLLM 支持上述所有模型。更多关于 liteLLM 的使用信息，请参阅：https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm\u002Fblob\u002Fmain\u002Fsetup.py\n\n## 准备工作\n\n1. ChatGPT 或 OpenAI 的 API Token [^token]\n2. epub\u002Ftxt\u002Fpdf 格式的书籍\n3. 具有互联网连接或代理环境\n4. Python 3.8+\n\n## 快速开始\n\n我们提供了一个示例书籍 `test_books\u002Fanimal_farm.epub` 用于测试。\n\n```shell\npip install -r requirements.txt\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --test\n或者\npip install -U bbook_maker\nbbook --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --test\n```\n\n## 翻译服务\n\n- 使用 `--openai_key` 参数指定 OpenAI 的 API 密钥。如果您有多个密钥，可以用逗号分隔（xxx,xxx,xxx），以减少因 API 调用限制导致的错误。\n  或者，您也可以直接设置环境变量 `BBM_OPENAI_API_KEY`。\n- 我们提供了一个示例书籍 `test_books\u002Fanimal_farm.epub` 用于测试。\n- 默认底层模型是 [GPT-3.5-turbo](https:\u002F\u002Fopenai.com\u002Fblog\u002Fintroducing-chatgpt-and-whisper-apis)，这也是 ChatGPT 目前使用的模型。您可以使用 `--model gpt4` 将底层模型更改为 GPT4，也可以选择 GPT4omini。\n- 需要注意的是，GPT4 的成本远高于 GPT4-turbo，但为了避免触发速率限制，我们会自动在 `gpt-4-1106-preview`、`gpt-4`、`gpt-4-32k`、`gpt-4-0613` 和 `gpt-4-32k-0613` 之间均衡分配请求。\n- 如果您想使用 OpenAI 的特定模型别名（例如 `gpt-4-1106-preview` 或 `gpt-3.5-turbo-0125`），可以使用 `--model openai --model_list gpt-4-1106-preview,gpt-3.5-turbo-0125`。`--model_list` 接受一个由逗号分隔的模型别名列表。\n- 如果使用 chatgptapi，可以添加 `--use_context` 参数，为发送给模型进行翻译的每个段落添加一段上下文说明（见下文）。\n\n* DeepL  \n支持 DeepL 模型 [DeepL Translator](https:\u002F\u002Frapidapi.com\u002FsplintPRO\u002Fapi\u002Fdpl-translator)，需要付费获取 Token。\n\n  ```\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model deepl --deepl_key ${deepl_key}\n  ```\n\n* DeepL 免费版\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model deeplfree\n  ```\n\n* [Claude](https:\u002F\u002Fconsole.anthropic.com\u002Fdocs)\n\n  使用 [Claude](https:\u002F\u002Fconsole.anthropic.com\u002Fdocs) 模型进行翻译。\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model claude --claude_key ${claude_key}\n  ```\n\n* Google Translate\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model google\n  ```\n\n* Caiyun Translate\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model caiyun --caiyun_key ${caiyun_key}\n  ```\n\n* Gemini\n\n  支持 Google 的 [Gemini](https:\u002F\u002Faistudio.google.com\u002Fapp\u002Fapikey) 模型，使用 `--model gemini` 可以选择 Gemini Flash，或使用 `--model geminipro` 选择 Gemini Pro。\n  如果您想使用 Gemini 的特定模型别名（例如 `gemini-1.5-flash-002` 或 `gemini-1.5-flash-8b-exp-0924`），可以使用 `--model gemini --model_list gemini-1.5-flash-002,gemini-1.5-flash-8b-exp-0924`。`--model_list` 接受一个由逗号分隔的模型别名列表。\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model gemini --gemini_key ${gemini_key}\n  ```\n\n* Qwen\n\n  支持阿里云 [Qwen-MT](https:\u002F\u002Fbailian.console.aliyun.com\u002F) 专业翻译模型。该模型支持 92 种语言，并具备术语干预和翻译记忆等功能。\n  使用 `--model qwen-mt-turbo` 可以获得更快、更经济的翻译；而使用 `--model qwen-mt-plus` 则可以获得更高品质的翻译。\n\n  您可以使用 `source_lang` 显式指定源语言，或者留空以启用自动检测功能。\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --qwen_key ${qwen_key} --model qwen-mt-turbo --language \"简体中文\"\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --qwen_key ${qwen_key} --model qwen-mt-plus --language \"日语\" --source_lang \"英语\"\n  ```\n\n* [腾讯 TranSmart](https:\u002F\u002Ftransmart.qq.com)\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model tencentransmart\n  ```\n\n* [xAI](https:\u002F\u002Fx.ai)\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model xai --xai_key ${xai_key}\n  ```\n\n* [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama)\n\n  支持 [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama) 自托管模型。如果 Ollama 服务器未运行在本地主机上，可以使用 `--api_base http:\u002F\u002Fx.x.x.x:port\u002Fv1` 指向 Ollama 服务器地址。\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --ollama_model ${ollama_model_name}\n  ```\n\n* [groq](https:\u002F\u002Fconsole.groq.com\u002Fkeys)\n\n  GroqCloud 目前支持多种模型，具体可参考 [Supported Models](https:\u002F\u002Fconsole.groq.com\u002Fdocs\u002Fmodels)。\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --groq_key [your_key] --model groq --model_list llama3-8b-8192\n  ```\n\n## 使用方法\n\n- 翻译完成后，对于 EPUB 输入文件，将生成名为 `${book_name}_bilingual.epub` 的双语文本；对于 TXT\u002FMD\u002FSRT 输入文件，则会生成名为 `${book_name}_bilingual.txt`（或 `_bilingual.srt`）的双语文本（或字幕文件）。对于 **PDF 输入文件**，工具会先生成一个双语 `.txt` 备份文件，并尝试创建 `${book_name}_bilingual.epub` —— 如果 EPUB 创建失败，TXT 备份文件仍然可用，因此无需重新翻译。\n- 如果在翻译过程中出现任何错误，或者您希望中断翻译并按下 `CTRL+C`，系统会生成一个临时的双语文件（例如 `{book_name}_bilingual_temp.epub` 或 `{book_name}_bilingual_temp.txt`）。您可以将其重命名为所需的文件名。\n\n## 参数\n\n- `--test`:\n\n  使用 `--test` 选项可在未付费的情况下预览结果。请注意，此功能有使用限制，并且可能需要一些时间。\n\n- `--language`:\n\n  设置目标语言，例如 `--language \"简体中文\"`。默认目标语言为“简体中文”。可通过帮助信息查看支持的语言：`python make_book.py --help`。\n\n- `--proxy`:\n\n  使用 `--proxy` 选项指定用于访问互联网的代理服务器。输入类似 `http:\u002F\u002F127.0.0.1:7890` 的字符串。\n\n- `--resume`:\n\n  使用 `--resume` 选项可在中断后手动恢复进程。\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model google --resume\n  ```\n\n- `--translate-tags`:\n\n  EPUB 文件由 HTML 文件组成。默认情况下，我们仅翻译 `\u003Cp>` 标签内的内容。使用 `--translate-tags` 可指定需要翻译的标签，多个标签之间用逗号分隔。例如：`--translate-tags h1,h2,h3,p,div`。\n\n- `--exclude-translate-tags`:\n\n  使用 `--exclude-translate-tags` 可将指定 HTML 标签内的内容排除在翻译之外。这对于保留代码块、预格式化文本或其他特殊内容非常有用。多个标签之间用逗号分隔。默认值为 `sup,code`。例如：`--exclude-translate-tags code,pre`。\n\n  **提示**：使用 `--exclude-translate-tags \"\"` 可翻译所有内容，包括代码块（覆盖默认的排除设置）。\n\n- `--book_from`:\n\n  使用 `--book_from` 选项可指定电子阅读器类型（目前仅支持 `kobo`），并使用 `--device_path` 指定挂载点。\n\n- `--api_base`:\n\n  如果您希望更改 API 基础 URL（例如使用 Cloudflare Workers），可以使用 `--api_base \u003CURL>` 来实现支持。**注意：API URL 应为 '`https:\u002F\u002Fxxxx\u002Fv1`'，且需使用引号。**\n\n- `--allow_navigable_strings`:\n\n  如果您希望翻译电子书中未标记任何标签的字符串，可以使用 `--allow_navigable_strings` 参数。这会将这些字符串添加到翻译队列中。**请注意，最好尽可能选择格式更规范的电子书。**\n\n- `--prompt`:\n\n  要调整提示模板，可以使用 `--prompt` 参数。`user` 角色模板中的有效占位符包括 `{text}` 和 `{language}`。支持以下几种配置方式：\n\n  - 如果无需设置 `system` 角色内容，可以直接这样设置：`--prompt \"Translate {text} to {language}.\"` 或 `--prompt prompt_template_sample.txt`（示例文本文件可在 [.\u002Fprompt_template_sample.txt](.\u002Fprompt_template_sample.txt) 中找到）。\n\n  - 如果需要设置 `system` 角色内容，可以使用以下格式：`--prompt '{\"user\":\"Translate {text} to {language}\", \"system\": \"You are a professional translator.\"}'` 或 `--prompt prompt_template_sample.json`（示例 JSON 文件可在 [.\u002Fprompt_template_sample.json](.\u002Fprompt_template_sample.json) 中找到）。\n\n  - 现在还可以使用 [PromptDown](https:\u002F\u002Fgithub.com\u002Fbtfranklin\u002Fpromptdown) 格式（`.md` 文件）来提供更结构化的提示：`--prompt prompt_md.prompt.md`。PromptDown 同时支持传统的系统消息和开发者消息（由较新的 AI 模型使用）。示例如下：\n\n      ```markdown\n      # 翻译提示\n      \n      ## 开发者消息\n      您是一位专业译员，擅长准确的翻译工作。\n      \n      ## 对话\n      \n      | 角色   | 内容                                                        |\n      | ------ | ---------------------------------------------------------- |\n      | 用户   | 请将以下文本翻译成 {language}:\\n\\n{text}                 |\n      ```\n\n  - 此外，还可以通过设置环境变量来定义 `user` 和 `system` 角色的提示：`BBM_CHATGPTAPI_USER_MSG_TEMPLATE` 和 `BBM_CHATGPTAPI_SYS_MSG`。\n\n- `--batch_size`:\n\n  使用 `--batch_size` 参数可指定批量翻译的行数（默认为 10，目前仅对 txt 文件有效）。\n\n- `--accumulated_num`:\n\n  在开始翻译之前，等待累积多少个 token。gpt3.5 将总 token 数限制为 4090。例如，如果您使用 `--accumulated_num 1600`, OpenAI 可能会输出 2200 个 token，而系统消息和用户消息可能会占用 200 个 token，因此 1600+2200+200=4000，接近上限。您需要自行选择合适的值，因为在发送请求前无法确定是否已达到限制。\n\n- `--use_context`:\n\n  提示模型生成三段摘要。如果是翻译的开头部分，它会总结整个已发送的内容（大小取决于 `--accumulated_num`）。对于后续内容，它会更新摘要，加入最新片段的细节，从而形成一个持续更新的单段上下文摘要，包含整部译作的重要信息。这有助于在整个翻译过程中保持语流和语气的一致性。此选项适用于所有兼容 ChatGPT 和 Gemini 的模型。\n\n- `--context_paragraph_limit`:\n\n  使用 `--context_paragraph_limit` 可以在使用 `--use_context` 选项时设置上下文段落的数量限制。\n\n- `--parallel-workers`:\n\n  使用 `--parallel-workers` 可启用 EPUB 章节的并行处理。数值大于 1 时会启动多个工作进程（建议设置为 2–4），而对于单章节书籍则会自动回退到串行模式。\n\n- `--temperature`:\n\n  使用 `--temperature` 可为 `chatgptapi`、`gpt4` 和 `claude` 模型设置温度参数。例如：`--temperature 0.7`。\n\n- `--block_size`:\n\n  使用 `--block_size` 可将多个段落合并为一个块。这可能会提高准确性并加快处理速度。例如：`--block_size 5`。\n\n- `--single_translate`:\n\n  使用 `--single_translate` 可仅输出翻译后的书籍，而不创建双语文本版本。\n\n- `--translation_style`:\n\n  示例：`--translation_style \"color: #808080; font-style: italic;\"`\n\n- `--retranslate \"$translated_filepath\" \"file_name_in_epub\" \"start_str\" \"end_str\"(optional)`:\n\n  从 start_str 到 end_str 的标签范围进行重译：\n\n  ```shell\n  python3 \"make_book.py\" --book_name \"test_books\u002Fanimal_farm.epub\" --retranslate 'test_books\u002Fanimal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' 'This kind of thing is not a good symptom. Obviously'\n  ```\n\n  仅从 start_str 的标签开始重译：\n\n  ```shell\n  python3 \"make_book.py\" --book_name \"test_books\u002Fanimal_farm.epub\" --retranslate 'test_books\u002Fanimal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which'\n  ```\n\n- `--extra_body`:\n\n  向 API 传递额外的 JSON 参数。这对于支持额外配置选项的模型非常有用。提供包含所需参数的 JSON 字符串。\n\n  ```shell\n  python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --extra_body '{\"chat_template_kwargs\": {\"enable_thinking\": false}}'\n  ```\n\n### 示例\n\n**注意：如果使用 `pip install bbook_maker` 安装，则所有命令均可改为 `bbook_maker args`**\n\n```shell\n# 快速测试\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key}  --test --language zh-hans\n\n# 针对源文件的快速测试\npython3 make_book.py --book_name test_books\u002FLex_Fridman_episode_322.srt --openai_key ${openai_key}  --test\n\n# 或者翻译整本书\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --language zh-hans\n\n# 或者使用 Gemini Flash 模型翻译整本书\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --gemini_key ${gemini_key} --model gemini\n\n# 使用并行章节处理翻译 EPUB 文件\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${openai_key} --parallel-workers 4\n\n# 使用特定的 Gemini 模型别名列表\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --gemini_key ${gemini_key} --model gemini --model_list gemini-1.5-flash-002,gemini-1.5-flash-8b-exp-0924\n\n# 设置环境变量 OPENAI_API_KEY 以忽略 --openai_key 选项\nexport OPENAI_API_KEY=${your_api_key}\n\n# 使用 GPT-4 模型并结合上下文翻译成日语\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model gpt4 --use_context --language ja\n\n# 使用特定的 OpenAI 模型别名\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model openai --model_list gpt-4-1106-preview --openai_key ${openai_key}\n\n**注意**：您也可以以这种方式使用其他“类似 OpenAI”的模型。\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model openai --model_list yi-34b-chat-0205 --openai_key ${openai_key} --api_base \"https:\u002F\u002Fapi.lingyiwanwu.com\u002Fv1\"\n\n# 使用特定的 OpenAI 模型别名列表\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model openai --model_list gpt-4-1106-preview,gpt-4-0125-preview,gpt-3.5-turbo-0125 --openai_key ${openai_key}\n\n# 使用 DeepL 模型翻译成日语\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model deepl --deepl_key ${deepl_key} --language ja\n\n# 使用 Claude 模型翻译成日语\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model claude --claude_key ${claude_key} --language ja\n\n# 使用 CustomAPI 模型翻译成日语\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model customapi --custom_api ${custom_api} --language ja\n\n# 翻译 \u003Cdiv> 和 \u003Cp> 中的内容\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --translate-tags div,p\n\n# 调整提示词\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --prompt prompt_template_sample.txt\n# 或\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --prompt prompt_template_sample.json\n# 或\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --prompt \"请将 \\`{text}\\` 翻译成 {language}\"\n\n# 翻译从 Rakuten Kobo 下载并在 Kobo 电子阅读器上阅读的书籍\npython3 make_book.py --book_from kobo --device_path \u002Ftmp\u002Fkobo\n\n# 翻译 TXT 文件\npython3 make_book.py --book_name test_books\u002Fthe_little_prince.txt --test --language zh-hans\n# 批量翻译 TXT 文件\npython3 make_book.py --book_name test_books\u002Fthe_little_prince.txt --test --batch_size 20\n\n# 使用彩云模型进行翻译\n# （该 API 目前仅支持：简体中文 \u003C-> 英语，简体中文 \u003C-> 日本语）\n# 彩云官方提供了一个测试令牌（3975l6lr5pcbvidl6jl2）\n# 您可以按照此教程申请自己的令牌（https:\u002F\u002Fbobtranslate.com\u002Fservice\u002Ftranslate\u002Fcaiyun.html）\npython3 make_book.py --model caiyun --caiyun_key 3975l6lr5pcbvidl6jl2 --book_name test_books\u002Fanimal_farm.epub\n\n\n# 设置环境变量 BBM_CAIYUN_API_KEY 以忽略 --openai_key 选项\nexport BBM_CAIYUN_API_KEY=${your_api_key}\n\n```\n\n更易理解的示例\n\n```shell\npython3 make_book.py --book_name 'animal_farm.epub' --openai_key sk-XXXXX --api_base 'https:\u002F\u002Fxxxxx\u002Fv1'\n\n# 如果您的 PATH 中没有 python3\npython make_book.py --book_name 'animal_farm.epub' --openai_key sk-XXXXX --api_base 'https:\u002F\u002Fxxxxx\u002Fv1'\n```\n\nMicrosoft Azure 终端节点\n\n```shell\npython3 make_book.py --book_name 'animal_farm.epub' --openai_key XXXXX --api_base 'https:\u002F\u002Fexample-endpoint.openai.azure.com' --deployment_id 'deployment-name'\n\n# 如果您的 PATH 中没有 python3\npython make_book.py --book_name 'animal_farm.epub' --openai_key XXXXX --api_base 'https:\u002F\u002Fexample-endpoint.openai.azure.com' --deployment_id 'deployment-name'\n```\n\n## Docker\n\n如果您不想手动配置环境，可以使用 [Docker](https:\u002F\u002Fwww.docker.com\u002F)。\n\n```shell\n# 构建镜像\ndocker build --tag bilingual_book_maker .\n\n# 运行容器\n# \"$folder_path\" 表示您的图书文件所在的文件夹，也是处理后文件将被保存的位置。\n\n# Windows PowerShell\n$folder_path=your_folder_path # $folder_path=\"C:\\Users\\user\\mybook\\\"\n$book_name=your_book_name # $book_name=\"animal_farm.epub\"\n$openai_key=your_api_key # $openai_key=\"sk-xxx\"\n$language=your_language # 参见 utils.py\n\ndocker run --rm --name bilingual_book_maker --mount type=bind,source=$folder_path,target='\u002Fapp\u002Ftest_books' bilingual_book_maker --book_name \"\u002Fapp\u002Ftest_books\u002F$book_name\" --openai_key $openai_key --language $language\n\n# Linux\nexport folder_path=${your_folder_path}\nexport book_name=${your_book_name}\nexport openai_key=${your_api_key}\nexport language=${your_language}\n\ndocker run --rm --name bilingual_book_maker --mount type=bind,source=${folder_path},target='\u002Fapp\u002Ftest_books' bilingual_book_maker --book_name \"\u002Fapp\u002Ftest_books\u002F${book_name}\" --openai_key ${openai_key} --language \"${language}\"\n```\n\n例如：\n\n```shell\n# Linux\ndocker run --rm --name bilingual_book_maker --mount type=bind,source=\u002Fhome\u002Fuser\u002Fmy_books,target='\u002Fapp\u002Ftest_books' bilingual_book_maker --book_name \u002Fapp\u002Ftest_books\u002Fanimal_farm.epub --openai_key sk-XXX --test --test_num 1 --language zh-hant\n```\n\n## 注意事项\n\n1. 免费试用的 API 令牌有使用限制。如果您希望加快处理速度，可以考虑付费或使用多个 OpenAI 令牌。\n2. 欢迎提交 PR。\n\n# 感谢\n\n- @[yetone](https:\u002F\u002Fgithub.com\u002Fyetone)\n\n# 贡献\n\n- 欢迎任何问题或 PR。\n- 也可以选择 issue 中的待办事项。\n- 请在提交代码前运行 `black make_book.py`[^black]。\n\n# 其他优秀工具\n\n- 书译 BookTranslator -> [Book Translator](https:\u002F\u002Fwww.booktranslator.app)\n\n## 致谢\n\n感谢至此。\n\n![image](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyihong0618_bilingual_book_maker_readme_449e55d5aa57.png)\n\n[^token]: https:\u002F\u002Fplatform.openai.com\u002Faccount\u002Fapi-keys\n[^black]: https:\u002F\u002Fgithub.com\u002Fpsf\u002Fblack","# bilingual_book_maker 快速上手指南\n\n`bilingual_book_maker` 是一款利用 AI（如 ChatGPT、Claude、Gemini 等）将 epub\u002Ftxt\u002Fsrt\u002Fpdf 书籍翻译为双语版本的开源工具。\n\n## 环境准备\n\n在开始之前，请确保满足以下条件：\n\n*   **操作系统**：Linux, macOS 或 Windows\n*   **Python 版本**：Python 3.8 或更高版本\n*   **网络环境**：需要能够访问外网，或配置好代理服务器\n*   **API Key**：准备好对应模型的 API Key（如 OpenAI Key, DeepL Key, Claude Key 等）\n*   **源文件**：待翻译的 epub, txt, pdf 或 srt 文件\n\n## 安装步骤\n\n你可以选择从源码安装或直接通过 pip 安装工具包。\n\n### 方式一：直接安装（推荐）\n\n```bash\npip install -U bbook_maker\n```\n\n### 方式二：源码安装\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fbilingual-book-maker\u002Fbilingual_book_maker.git\ncd bilingual_book_maker\npip install -r requirements.txt\n```\n\n> **提示**：国内用户若下载缓慢，可使用国内镜像源加速安装：\n> `pip install -U bbook_maker -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`\n\n## 基本使用\n\n以下以使用 OpenAI 模型翻译测试书籍《动物农场》为例。\n\n### 1. 准备测试文件\n项目自带测试文件 `test_books\u002Fanimal_farm.epub`（源码安装方式），或直接指定你自己的书籍路径。\n\n### 2. 执行翻译命令\n\n**如果是通过 pip 安装的包：**\n\n```bash\nbbook --book_name test_books\u002Fanimal_farm.epub --openai_key ${your_openai_key} --test\n```\n\n**如果是源码运行：**\n\n```bash\npython3 make_book.py --book_name test_books\u002Fanimal_farm.epub --openai_key ${your_openai_key} --test\n```\n\n### 参数说明\n*   `--book_name`: 输入文件的路径。\n*   `--openai_key`: 你的 OpenAI API Key。若有多个 Key 可用逗号分隔（如 `key1,key2,key3`）以规避频率限制。也可设置环境变量 `BBM_OPENAI_API_KEY` 代替。\n*   `--test`: **重要**。首次使用时建议加上此参数，它会仅翻译少量内容用于预览效果和测试 Key 是否有效，避免产生高额费用。\n*   `--language`: 目标语言，默认为 `\"Simplified Chinese\"`。例如：`--language \"Japanese\"`。\n*   `--model`: 指定模型。默认使用 `gpt-3.5-turbo`。支持 `gpt4`, `claude`, `gemini`, `deepl`, `google` 等。\n\n### 输出结果\n翻译完成后，将在同目录下生成名为 `${book_name}_bilingual.epub` (或 `.txt`\u002F`.srt`) 的双语文件。\n\n若中途按下 `CTRL+C` 中断或发生错误，会生成临时文件（如 `${book_name}_bilingual_temp.epub`），重命名该文件即可保留已翻译部分。下次运行时可添加 `--resume` 参数从中断处继续。","一位外语系研究生急需阅读英文原版公版小说《动物庄园》以完成比较文学论文，但其中大量的生僻词汇和长难句严重阻碍了理解效率。\n\n### 没有 bilingual_book_maker 时\n- **查阅中断心流**：每读几行就要停下来查字典或复制句子去翻译网站，阅读思路频繁被打断，难以把握全书脉络。\n- **对照排版混乱**：手动将译文粘贴到原文档中时，格式经常错乱，无法实现左右段落或上下句的精准对齐，复习时极不方便。\n- **成本高昂耗时**：若寻求人工翻译或购买昂贵的双语实体书，不仅经济成本高，且等待周期长，无法满足紧急的科研需求。\n- **语境丢失风险**：使用普通机器翻译整段输入时，往往缺乏上下文关联，导致对书中讽刺隐喻的理解出现偏差。\n\n### 使用 bilingual_book_maker 后\n- **一键生成双语**：只需一条命令调用 GPT-4 或 Claude 模型，即可自动将 epub 文件转换为原文与译文完美对照的双语版本。\n- **格式完整保留**：工具智能解析书籍结构，生成的电子书保留了原有的章节、段落和排版样式，直接在阅读器中即可流畅翻阅。\n- **上下文精准翻译**：利用大模型的上下文理解能力，准确还原了原著的修辞色彩和深层含义，显著提升了学术研读的准确性。\n- **低成本高效率**：几分钟内即可完成整本书的处理，仅需支付极少的 API 费用，让个人研究者也能轻松拥有定制化的双语学习资料。\n\nbilingual_book_maker 将繁琐的文献预处理工作自动化，让研究者能从语言障碍中解放出来，专注于内容本身的深度思考。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyihong0618_bilingual_book_maker_449e55d5.png","yihong0618","yihong","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fyihong0618_4790516a.png","The best is yet to come.","@apache","China","yihong0618@apache.org","yihong.run","https:\u002F\u002Fgithub.com\u002Fyihong0618",[86,90,94],{"name":87,"color":88,"percentage":89},"Python","#3572A5",99.9,{"name":91,"color":92,"percentage":93},"Makefile","#427819",0.1,{"name":95,"color":96,"percentage":93},"Dockerfile","#384d54",9133,1226,"2026-04-13T09:16:27","MIT","Linux, macOS, Windows","未说明",{"notes":104,"python":105,"dependencies":106},"该工具主要调用云端 API（如 OpenAI、Claude、Gemini 等）进行翻译，本地无需高性能 GPU 或大内存。需确保网络畅通或配置代理服务器（--proxy）。若使用 Ollama 等本地自托管模型，则需满足对应模型的本地运行环境要求。支持多种输入格式（epub\u002Ftxt\u002Fsrt\u002Fpdf），中断后可通过 --resume 参数恢复任务。","3.8+",[107,108,109,110,111],"litellm","requests","beautifulsoup4","ebooklib","tiktoken",[15,25],null,"2026-03-27T02:49:30.150509","2026-04-14T03:10:34.867031",[117,122,127,132,137,142,147,152],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},32271,"设置中文参数后翻译结果仍然是英文，如何解决？","默认情况下工具已设置为简体中文。如果遇到问题，请检查命令参数是否正确，确保使用了 `--language 'zh-hans'`。如果仍然无效，请确认书籍文件本身没有格式问题，并尝试使用其他书籍测试。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F54",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},32272,"为什么使用 gpt-4 模型时报错提示模型不存在？","这通常是因为 API Key 权限不足或模型名称配置错误。虽然你有 ChatGPT Plus 订阅，但需确保 API Key 已开通 GPT-4 访问权限。此外，由于 GPT-4 成本较高，建议尝试使用优化版的 `gpt-3.5-turbo` 模型，命令中指定 `--model gpt-3.5-turbo` 即可。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F298",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},32273,"翻译后的文本行首行末自动添加了双引号，如何去除？","这是模型生成的格式问题。解决方法是在自定义 prompt 中明确指示 GPT 不要使用引号。例如，在 prompt 文件中添加“不要在任何行的开头或结尾使用双引号”的指令。如果使用的是 JSON 模式，也需检查相关配置是否导致了引号包裹。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F199",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},32274,"翻译进度显示 100% 完成，但生成的 EPUB 文件内容仍是原文或未完全翻译，怎么办？","首先确认使用的 API Key 是否有效且对应正确的模型（如默认的 `gpt-3.5-turbo`）。如果是免费 Key 或受限 Key，可能导致部分请求失败但未报错。尝试更换为可用的付费 Key，并在命令中显式指定模型，例如：`python3 make_book.py --book_name book.epub --model gpt-3.5-turbo --openai_key YOUR_KEY`。此外，某些特定格式的书籍可能存在兼容性问题，建议换一本书测试以排查是否是源文件问题。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F183",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},32275,"使用 Gemini 模型时频繁遇到 429 资源耗尽错误，如何解决？","429 错误是由于请求频率超过了 API 限制。可以通过增加请求间隔来解决。修改源码 `gemini_translator.py` 文件，找到 `time.sleep` 函数，将等待时间从默认值改为 3 秒（即 `time.sleep(3)`）。这样可以有效降低请求频率，避免触发限流。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F406",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},32276,"运行时报错 `No module named 'google.generativeai.types.generation_types'` 怎么办？","这是因为 `google-generativeai` 库版本不兼容或未正确安装。首先尝试升级库：`pip install -U google-generativeai`。如果问题依旧，可能是 Python 版本问题（该库可能不支持过旧的 Python 3.8.2），建议升级 Python 环境至 3.9 或更高版本。另外，网络问题也可能导致模块加载失败，国内用户可能需要配置代理。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F398",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},32277,"读取 EPUB 文件时报错 `AttributeError: 'NoneType' object has no attribute 'get_name'`，如何修复？","该错误通常是由于 EPUB 文件结构不完整或缺少必要的目录文件（NCX）导致的。解决方案是拉取项目的最新代码，维护者已在最新版本中修复了对此类文件的处理逻辑。请在终端执行 `git pull` 更新代码后重试。如果问题仍存在，尝试使用其他标准的 EPUB 文件进行测试。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F71",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},32278,"如何使用 Gemini 模型时解决 404 错误或连接失败的问题？","出现 404 错误或无法连接通常是因为网络限制或 API Key 无效。首先确保你从 Google AI Studio 获取了有效的 API Key。其次，由于网络原因，国内用户可能需要配置科学上网（代理）才能访问 Gemini 服务。如果仍然不行，可以尝试切换其他可用的 AI 模型（如 GPT 或 Claude）进行翻译。","https:\u002F\u002Fgithub.com\u002Fyihong0618\u002Fbilingual_book_maker\u002Fissues\u002F457",[158,163,168,173,178],{"id":159,"version":160,"summary_zh":161,"released_at":162},247099,"v0.9.8","- 支持 xai","2024-11-06T13:26:58",{"id":164,"version":165,"summary_zh":166,"released_at":167},247100,"v0.9.7","**Gemini 翻译器改进：**\n\n* **默认模型：** 切换至 `gemini-1.5-flash`。\n* **新增选项：** 增加了对 `use_context`、`temperature`、`prompt`、自定义模型列表（`--model_list`）以及密钥\u002F模型轮转的支持，与其他翻译工具保持一致。\n* **输出限制：** 将 `max_output_tokens` 由 2048 提升至 8192。\n* **安全设置：** 放宽了阈值（`BLOCK_NONE`），以减少 `BlockedPromptException` 异常的发生（但并未完全消除）。\n* **指数退避：** 实现了重试机制。\n\n**重试策略：** 重试机制在首次重试时优先使用密钥轮转，仅在后续重试中才切换到模型轮转，以尽量减少翻译质量的不一致性。\n\n**新增选项：**\n\n* **间隔选项：** 新增 `--interval [float]`（秒）选项，用于控制请求频率。虽然已实现指数退避机制，但仍保留了原有的固定休眠时间。此举旨在应对 Gemini 的较低 RPM 限制（1000–2000，而 OpenAI 为 10,000）以及免费层级的限制。建议值：对于 Gemini Flash（2000 RPM 限制）可设为 0.03 秒；对于免费层级（15 RPM）则设为 4 秒。\n\n**测试：**\n\n1. 解注释 `gemini_translator.py` 文件第 90 行（`# print(model)`），以检查模型对象并验证参数变更。\n2. **默认（Gemini Flash）：** `python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model gemini --test`\n3. **Gemini Pro：** `python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model geminipro --test`\n4. **所有选项（免费层级 API，含重试）：** `python3 make_book.py --book_name test_books\u002Fanimal_farm.epub --model gemini --model_list gemini-1.5-pro-002,gemini-1.5-flash-002 --test --test_num 30 --use_context --temperature 0.5 --prompt prompt_template_sample.json --interval 0.1`\n\n感谢 @risin42","2024-10-21T05:44:40",{"id":169,"version":170,"summary_zh":171,"released_at":172},247101,"v0.9.6","- 支持批量 API\n- 启用上下文标志，并添加上下文段落限制\n\n特别感谢 @mkXultra","2024-08-20T13:36:03",{"id":174,"version":175,"summary_zh":176,"released_at":177},247102,"v0.9.5","支持GPT-4o","2024-08-09T10:34:02",{"id":179,"version":180,"summary_zh":113,"released_at":181},247103,"v0.9.4","2024-05-28T06:04:13"]