更新gemini支持
This commit is contained in:
1 parent
0298bd58c6
commit
0891d4f0b2
3 files changed
+19
-8
No files matched your search
@@ -11,15 +11,15 @@
|
||||
|
||||
新版架构采用 **工作流(Workflow)** 为核心,为不同类型的翻译任务提供了高度可配置和可扩展的解决方案。
|
||||
|
||||
- ✅ **支持多种格式**:能翻译 `.pdf`, `.docx`, `.md`, `.txt`, `.jpg` ,`json`等多种文件。
|
||||
- ✅ **支持多种格式**:能翻译 `.pdf`, `.docx`, `xlsx`,`.md`, `.txt`, `.jpg`、`html` 等多种文件。
|
||||
- ✅ **表格、公式、代码识别**:凭借`docling`、`mineru`实现对学术论文中经常出现的表格、公式、代码的识别与翻译
|
||||
- ✅ **json翻译**:支持通过json路径(`jsonpath-ng`语法规范)指定json中需要被翻译的值。
|
||||
- ✅ **Excel翻译**:支持`.xlsx`文件(暂不支持`.xls`文件)的翻译,保持原格式进行翻译。
|
||||
- ✅ **Word/Excel高保真翻译**:支持`.docx`、`.xlsx`文件(暂不支持`.doc`、.xls`文件)的翻译,保持原格式进行翻译。
|
||||
- ✅ **多ai平台支持**:支持绝大部分的ai平台,可以实现自定义提示词的并发高性能ai翻译。
|
||||
- ✅ **异步支持**:专为高性能场景设计,提供完整的异步支持,实现了可以多任务并行的服务接口。
|
||||
- ✅ **交互式Web界面**:提供开箱即用的 Web UI 和 RESTful API,方便集成与使用。
|
||||
|
||||
> 在翻译`.pdf`、`.docx`等文件时会先转换为markdown,这会**丢失**原先的排版,对排版有要求的用户请注意
|
||||
> 在翻译`.pdf`、`html`等文件时会先转换为markdown,这会**丢失**原先的排版,对排版有要求的用户请注意
|
||||
|
||||
> QQ交流群:1047781902
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
## 整合包
|
||||
|
||||
对于希望快速上手的用户,我们仍在 [GitHub Releases](https://github.com/xunbu/docutranslate/releases) 上提供整合包。您只需下载、解压,并填入您的
|
||||
对于希望快速上手的用户,我们在 [GitHub Releases](https://github.com/xunbu/docutranslate/releases) 上提供整合包。您只需下载、解压,并填入您的
|
||||
AI 平台 API-Key 即可开始使用。
|
||||
|
||||
- **DocuTranslate**: 标准版,使用在线的 `minerU` 引擎解析文档,推荐大多数用户使用。
|
||||
@@ -87,9 +87,11 @@ uv add docutranslate[docling]
|
||||
| **`MarkdownBasedWorkflow`** | 处理富文本文档,如PDF、Word、图片等。流程为:`文件 -> Markdown -> 翻译 -> 导出`。 | `.pdf`, `.docx`, `.md`, `.png`, `.jpg` 等 | `.md`, `.zip`, `.html` | `MarkdownBasedWorkflowConfig` |
|
||||
| **`TXTWorkflow`** | 处理纯文本文档。流程为:`txt -> 翻译 -> 导出`。 | `.txt` 及其他纯文本格式 | `.txt`, `.html` | `TXTWorkflowConfig` |
|
||||
| **`JsonWorkflow`** | 处理json文件。流程为:`json -> 翻译 -> 导出`。 | `.json` | `.json`, `.html` | `JsonWorkflowConfig` |
|
||||
| **`DocxWorkflow`** | 处理docx文件。流程为:`docx -> 翻译 -> 导出`。 | `.docx` | `.docx`, `.html` | `docxWorkflowConfig` |
|
||||
| **`XlsxWorkflow`** | 处理xlsx文件。流程为:`xlsx -> 翻译 -> 导出`。 | `.xlsx` | `.xlsx`, `.html` | `XlsxWorkflowConfig` |
|
||||
|
||||
> 在交互式界面中可以导出pdf格式
|
||||
|
||||
## 使用方式
|
||||
|
||||
### 示例 1: 翻译一个 PDF 文件 (使用 `MarkdownBasedWorkflow`)
|
||||
@@ -352,6 +354,7 @@ async def main():
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
## 启动 Web UI 和 API 服务
|
||||
|
||||
为了方便使用,DocuTranslate 提供了一个功能齐全的 Web 界面和 RESTful API。
|
||||
@@ -379,14 +382,16 @@ docutranslate -i
|
||||
|
||||
翻译功能依赖于大型语言模型,您需要从相应的 AI 平台获取 `base_url`, `api_key` 和 `model_id`。
|
||||
|
||||
> 推荐模型:智谱的`glm-4-flash`,阿里云的 `qwen-plus`,``qwen-turbo`,deepseek的`deepseek-chat`等。
|
||||
> 推荐模型:火山引擎的`doubao-seed-1-6-flash-250715`、智谱的`glm-4-flash`,阿里云的 `qwen-plus`,``qwen-turbo`,deepseek的`
|
||||
> deepseek-chat`等。
|
||||
|
||||
| 平台名称 | 获取APIkey | baseurl |
|
||||
|------------|---------------------------------------------------------------------------------------|---------------------------------------------------|
|
||||
|------------|---------------------------------------------------------------------------------------|----------------------------------------------------------|
|
||||
| ollama | | http://127.0.0.1:11434/v1 |
|
||||
| lm studio | | http://127.0.0.1:1234/v1 |
|
||||
| openrouter | [点击获取](https://openrouter.ai/settings/keys) | https://openrouter.ai/api/v1 |
|
||||
| openai | [点击获取](https://platform.openai.com/api-keys) | https://api.openai.com/v1/ |
|
||||
| gemini | [点击获取](https://aistudio.google.com/u/0/apikey) | https://generativelanguage.googleapis.com/v1beta/openai/ |
|
||||
| deepseek | [点击获取](https://platform.deepseek.com/api_keys) | https://api.deepseek.com/v1 |
|
||||
| 智谱ai | [点击获取](https://open.bigmodel.cn/usercenter/apikeys) | https://open.bigmodel.cn/api/paas/v4 |
|
||||
| 腾讯混元 | [点击获取](https://console.cloud.tencent.com/hunyuan/api-key) | https://api.hunyuan.cloud.tencent.com/v1 |
|
||||
@@ -411,19 +416,25 @@ docutranslate -i
|
||||
**网络问题解决方案:**
|
||||
|
||||
1. **设置 Hugging Face 镜像 (推荐)**:
|
||||
|
||||
* **方法 A (环境变量)**: 设置系统环境变量 `HF_ENDPOINT` 并重启您的IDE或终端。
|
||||
```
|
||||
HF_ENDPOINT=https://hf-mirror.com
|
||||
```
|
||||
* **方法 B (代码中设置)**: 在您的 Python 脚本开头添加以下代码。
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
|
||||
```
|
||||
|
||||
2. **离线使用 (提前下载模型包)**:
|
||||
|
||||
* 从 [GitHub Releases](https://github.com/xunbu/docutranslate/releases) 下载 `docling_artifact.zip`。
|
||||
* 将其解压到您的项目目录中。
|
||||
* 在配置中指定模型路径:
|
||||
|
||||
```python
|
||||
from docutranslate.converter.x2md.converter_docling import ConverterDoclingConfig
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__="0.4.1"
|
||||
__version__="1.0.0b1"
|
||||
@@ -1 +1 @@
|
||||
<!DOCTYPE html>
<html lang="zh-CN" data-bs-theme="auto">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DocuTranslate - 交互式文档翻译</title>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<!-- Bootstrap CSS -->
<link href="/static/bootstrap.css" rel="stylesheet" crossorigin="anonymous">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="/static/bootstrap-icons.css">
<style>
body {
background-color: var(--bs-body-bg);
}
.main-container {
display: flex;
flex-direction: column;
height: 100vh;
padding-top: 1rem;
padding-bottom: 1rem;
}
.settings-panel {
height: calc(100vh - 2rem);
overflow-y: auto;
padding-right: 15px; /* for scrollbar */
}
.task-area {
height: calc(100vh - 2rem);
overflow-y: auto;
}
.task-card {
transition: all 0.3s ease-in-out;
}
.task-id-placeholder {
color: var(--bs-secondary-color);
font-style: italic;
}
.log-area {
height: 150px;
background-color: var(--bs-tertiary-bg);
border: 1px solid var(--bs-border-color);
border-radius: .375rem;
font-family: monospace;
font-size: 0.8rem;
padding: 10px;
overflow-y: auto;
white-space: pre-wrap;
word-break: break-all;
}
.file-drop-area {
border: 2px dashed var(--bs-secondary-bg);
border-radius: .375rem;
padding: 2rem;
text-align: center;
cursor: pointer;
transition: all 0.2s ease-in-out;
background-color: var(--bs-body-bg);
}
.file-drop-area.drag-over {
border-color: var(--bs-primary);
background-color: var(--bs-secondary-bg);
}
.file-drop-area.file-selected {
border-style: solid;
border-color: var(--bs-success);
background-color: var(--bs-success-bg-subtle);
}
.file-drop-area.input-error {
border-color: var(--bs-danger);
}
.file-name-display.input-error-text {
color: var(--bs-danger);
font-weight: bold;
}
#printFrame, #translatedPreviewFrame {
border: none;
width: 100%;
}
#previewOffcanvas {
--bs-offcanvas-width: 95vw;
max-width: 1600px;
}
.preview-split-container {
display: flex;
flex-direction: row;
height: 100%;
}
.preview-pane-wrapper {
display: flex;
flex-direction: column;
overflow: hidden; /* Important for split.js */
}
.preview-pane-wrapper h6 {
flex-shrink: 0;
padding: 0.25rem;
}
.preview-pane-wrapper .preview-pane {
flex-grow: 1; /* Make the inner pane grow */
border: 1px solid var(--bs-border-color);
border-radius: .375rem;
overflow: auto;
}
.gutter {
background-color: var(--bs-tertiary-bg);
background-repeat: no-repeat;
background-position: 50%;
}
.gutter.gutter-horizontal {
cursor: col-resize;
border-left: 1px solid var(--bs-border-color);
border-right: 1px solid var(--bs-border-color);
}
.gutter.gutter-vertical {
cursor: row-resize;
border-top: 1px solid var(--bs-border-color);
border-bottom: 1px solid var(--bs-border-color);
}
.preview-pane iframe, .preview-pane pre {
width: 100%;
height: 95%;
border: none;
margin: 0;
padding: 0;
overflow: auto;
background-color: var(--bs-body-bg);
}
.slider-reset-btn {
visibility: hidden;
}
.theme-switch {
position: fixed;
bottom: 1rem;
left: 1rem;
z-index: 1050;
}
@media (max-width: 991.98px) {
.main-container {
height: auto;
padding-bottom: 6rem;
}
.settings-panel, .task-area {
height: auto;
overflow-y: visible;
}
.settings-panel {
padding-right: 0;
margin-bottom: 2rem;
}
}
@media (max-width: 767.98px) {
.task-card .col-md-7 {
margin-top: 1.5rem;
}
#previewOffcanvas {
--bs-offcanvas-width: 100vw;
}
Line truncated
|
||||
<!DOCTYPE html>
<html lang="zh-CN" data-bs-theme="auto">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DocuTranslate - 交互式文档翻译</title>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<!-- Bootstrap CSS -->
<link href="/static/bootstrap.css" rel="stylesheet" crossorigin="anonymous">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="/static/bootstrap-icons.css">
<style>
body {
background-color: var(--bs-body-bg);
}
.main-container {
display: flex;
flex-direction: column;
height: 100vh;
padding-top: 1rem;
padding-bottom: 1rem;
}
.settings-panel {
height: calc(100vh - 2rem);
overflow-y: auto;
padding-right: 15px; /* for scrollbar */
}
.task-area {
height: calc(100vh - 2rem);
overflow-y: auto;
}
.task-card {
transition: all 0.3s ease-in-out;
}
.task-id-placeholder {
color: var(--bs-secondary-color);
font-style: italic;
}
.log-area {
height: 150px;
background-color: var(--bs-tertiary-bg);
border: 1px solid var(--bs-border-color);
border-radius: .375rem;
font-family: monospace;
font-size: 0.8rem;
padding: 10px;
overflow-y: auto;
white-space: pre-wrap;
word-break: break-all;
}
.file-drop-area {
border: 2px dashed var(--bs-secondary-bg);
border-radius: .375rem;
padding: 2rem;
text-align: center;
cursor: pointer;
transition: all 0.2s ease-in-out;
background-color: var(--bs-body-bg);
}
.file-drop-area.drag-over {
border-color: var(--bs-primary);
background-color: var(--bs-secondary-bg);
}
.file-drop-area.file-selected {
border-style: solid;
border-color: var(--bs-success);
background-color: var(--bs-success-bg-subtle);
}
.file-drop-area.input-error {
border-color: var(--bs-danger);
}
.file-name-display.input-error-text {
color: var(--bs-danger);
font-weight: bold;
}
#printFrame, #translatedPreviewFrame {
border: none;
width: 100%;
}
#previewOffcanvas {
--bs-offcanvas-width: 95vw;
max-width: 1600px;
}
.preview-split-container {
display: flex;
flex-direction: row;
height: 100%;
}
.preview-pane-wrapper {
display: flex;
flex-direction: column;
overflow: hidden; /* Important for split.js */
}
.preview-pane-wrapper h6 {
flex-shrink: 0;
padding: 0.25rem;
}
.preview-pane-wrapper .preview-pane {
flex-grow: 1; /* Make the inner pane grow */
border: 1px solid var(--bs-border-color);
border-radius: .375rem;
overflow: auto;
}
.gutter {
background-color: var(--bs-tertiary-bg);
background-repeat: no-repeat;
background-position: 50%;
}
.gutter.gutter-horizontal {
cursor: col-resize;
border-left: 1px solid var(--bs-border-color);
border-right: 1px solid var(--bs-border-color);
}
.gutter.gutter-vertical {
cursor: row-resize;
border-top: 1px solid var(--bs-border-color);
border-bottom: 1px solid var(--bs-border-color);
}
.preview-pane iframe, .preview-pane pre {
width: 100%;
height: 95%;
border: none;
margin: 0;
padding: 0;
overflow: auto;
background-color: var(--bs-body-bg);
}
.slider-reset-btn {
visibility: hidden;
}
.theme-switch {
position: fixed;
bottom: 1rem;
left: 1rem;
z-index: 1050;
}
@media (max-width: 991.98px) {
.main-container {
height: auto;
padding-bottom: 6rem;
}
.settings-panel, .task-area {
height: auto;
overflow-y: visible;
}
.settings-panel {
padding-right: 0;
margin-bottom: 2rem;
}
}
@media (max-width: 767.98px) {
.task-card .col-md-7 {
margin-top: 1.5rem;
}
#previewOffcanvas {
--bs-offcanvas-width: 100vw;
}
Line truncated
|
||||
Reference in new issue
Block a user