-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Add batch uploader and document re-parsing tools to Python SDK #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CHLK
wants to merge
4
commits into
oceanbase:main
Choose a base branch
from
CHLK:feat/sdk_batch_tools
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,11 +14,13 @@ | |||||
| # limitations under the License. | ||||||
| # | ||||||
| import datetime | ||||||
| import io | ||||||
| import json | ||||||
| import logging | ||||||
| import pathlib | ||||||
| import re | ||||||
| from io import BytesIO | ||||||
| import time | ||||||
|
|
||||||
| import xxhash | ||||||
| from quart import request, send_file | ||||||
|
|
@@ -34,7 +36,7 @@ | |||||
| from api.db.services.knowledgebase_service import KnowledgebaseService | ||||||
| from api.db.services.llm_service import LLMBundle | ||||||
| from api.db.services.tenant_llm_service import TenantLLMService | ||||||
| from api.db.services.task_service import TaskService, queue_tasks, cancel_all_task_of | ||||||
| from api.db.services.task_service import TaskService, queue_tasks, cancel_all_task_of, queue_tasks_batch | ||||||
|
||||||
| from api.db.services.task_service import TaskService, queue_tasks, cancel_all_task_of, queue_tasks_batch | |
| from api.db.services.task_service import cancel_all_task_of, queue_tasks_batch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # ragflow-sdk | ||
|
|
||
| RAGFlow Python SDK 提供了与 RAGFlow 服务交互的 Python 接口,包括数据集管理、文档上传、对话等功能。 | ||
|
|
||
| ## 安装 | ||
|
|
||
| ```shell | ||
| pip install ragflow-sdk | ||
| ``` | ||
|
|
||
| ## 快速开始 | ||
|
|
||
| ```python | ||
| from ragflow_sdk import RAGFlow | ||
|
|
||
| # 初始化客户端 | ||
| rag = RAGFlow(api_key="YOUR_API_KEY", base_url="http://localhost:9380") | ||
|
|
||
| # 创建数据集 | ||
| dataset = rag.create_dataset(name="My Dataset") | ||
|
|
||
| # 上传文档 | ||
| documents = dataset.upload_documents_with_meta([ | ||
| { | ||
| "title": "Document Title", | ||
| "content": "Document content...", | ||
| "metadata": { | ||
| "tags": ["tag1", "tag2"] | ||
| } | ||
| } | ||
| ]) | ||
| ``` | ||
|
|
||
| ## 文档 | ||
|
|
||
| - [工具模块 API 参考](ragflow_sdk/tools/README.md) - FileReader, DocumentExtractor, FieldMapper, BatchUploader 等工具的详细 API 文档 | ||
| - [示例脚本](examples/README.md) - 批量上传等示例脚本的使用说明 | ||
|
|
||
| ## 工具模块 | ||
|
|
||
| SDK 提供了强大的工具模块,用于批量处理和文档管理: | ||
|
|
||
| - **FileReader**: 支持多种文件格式的文件读取器 | ||
| - **DocumentExtractor**: 从文件/目录中提取文档 | ||
| - **FieldMapper**: 灵活的字段映射器,支持自动字段检测 | ||
| - **BatchUploader**: 批量上传器,支持断点续传和自动重试 | ||
|
|
||
| 详细文档请参考 [工具模块 API 参考](ragflow_sdk/tools/README.md)。 | ||
|
|
||
| ## 构建和发布 | ||
|
|
||
| ### 构建 Python SDK | ||
|
|
||
| ```shell | ||
| uv build | ||
| ``` | ||
|
|
||
| ### 发布到 PyPI | ||
|
|
||
| ```shell | ||
| uv pip install twine | ||
| export TWINE_USERNAME="__token__" | ||
| export TWINE_PASSWORD=$YOUR_PYPI_API_TOKEN | ||
| twine upload dist/*.whl | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module 'io' is imported with both 'import' and 'import from'.