Skip to content

Commit 9ec8131

Browse files
Update doc research readme (#717)
1 parent 21849f8 commit 9ec8131

File tree

3 files changed

+159
-1
lines changed

3 files changed

+159
-1
lines changed

projects/doc_research/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- 🚀 **High Efficiency** - Leverage powerful LLMs for fast and accurate research, leveraging key information extraction techniques to further optimize token usage
2828
- ⚙️ **Flexible Deployment** - Support local run and [ModelScope Studio](https://modelscope.cn/studios) on both CPU and GPU environments.
2929
- 💰 **Free Model Inference** - Free LLM API inference calls for ModelScope users, refer to [ModelScope API-Inference](https://modelscope.cn/docs/model-service/API-Inference/intro)
30+
- 📚 **Export & Upload** - Support exporting research reports to PDF, PPTX, DOCX, HTML formats; support uploading reports to ModelScope, HuggingFace, GitHub
3031

3132

3233
<br>
@@ -102,6 +103,84 @@ ms-agent app --doc_research \
102103
> When running locally, the default address is http://0.0.0.0:7860/. If the page can't be accessed, try disabling proxy.
103104
104105

106+
### 4. Report Export
107+
DocResearch supports exporting markdown reports to various formats for easy archiving and sharing:
108+
- PDF
109+
- PPTX
110+
- HTML
111+
- DOCX
112+
113+
**Examples of exporting using Python script:**
114+
```python
115+
from ms_agent.utils.markdown_converter import MarkdownConverter
116+
117+
report_path: str = '/path/to/report_dir'
118+
output_path: str = '/path/to/output_dir'
119+
120+
# Call export functions
121+
MarkdownConverter.markdown_to_html(report_path, output_path + "/html")
122+
MarkdownConverter.markdown_to_docx(report_path, output_path + "/docx")
123+
MarkdownConverter.markdown_to_pptx(report_path, output_path + "/pptx")
124+
MarkdownConverter.markdown_to_pdf(report_path, output_path + "/pdf")
125+
```
126+
127+
128+
### 5. Report Uploading & Sharing
129+
DocResearch supports uploading generated markdown research reports to multiple platforms for easy sharing and collaboration:
130+
- **ModelScope**
131+
- **HuggingFace**
132+
- **GitHub**
133+
134+
**Upload to ModelScope:**
135+
```python
136+
from ms_agent.utils.push_to_hub import PushToModelScope
137+
138+
# Get the ModelScope token: https://modelscope.cn/my/myaccesstoken
139+
push_to_ms = PushToModelScope(token='ms-xxx')
140+
141+
push_to_ms.push(
142+
repo_id='your-username/your-repo-name',
143+
folder_path='/path/to/report_dir',
144+
path_in_repo='report',
145+
commit_message='Upload research report to ModelScope',
146+
)
147+
```
148+
149+
**Upload to HuggingFace:**
150+
```python
151+
from ms_agent.utils.push_to_hub import PushToHuggingFace
152+
153+
# Get the HuggingFace token: https://huggingface.co/settings/tokens
154+
push_to_hf = PushToHuggingFace(token='hf_xxx')
155+
156+
push_to_hf.push(
157+
repo_id='your-username/your-repo-name',
158+
folder_path='/path/to/report_dir',
159+
path_in_repo='report',
160+
commit_message='Upload research report to HuggingFace',
161+
)
162+
```
163+
164+
**Upload to GitHub:**
165+
```python
166+
from ms_agent.utils.push_to_hub import PushToGitHub
167+
168+
# Get the GitHub PAT(Personal Access Tokens): https://github.com/settings/tokens
169+
push_to_git = PushToGitHub(
170+
user_name = 'your-username',
171+
repo_name = 'your-repo-name',
172+
token = 'xxx',
173+
visibility = 'public', # `public` or `private`
174+
description = 'A repository for research reports generated by MS-Agent DocResearch',)
175+
176+
push_to_git.push(
177+
folder_path='/path/to/report_dir',
178+
path_in_repo='report',
179+
commit_message='Upload research report to GitHub',
180+
)
181+
```
182+
183+
105184
<br>
106185

107186
## Usage Instructions

projects/doc_research/README_zh.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- 🚀 **精准高效** - 利用强大的LLM进行快速准确的研究,采用关键信息抽取技术进一步优化了token使用
2828
- ⚙️ **灵活部署** - 支持本地运行和魔搭创空间运行模式(CPU-Only),同时也兼容GPU环境
2929
- 💰 **免费模型推理** - 魔搭ModelScope用户可免费调用LLM API推理,参考 [ModelScope API-Inference](https://modelscope.cn/docs/model-service/API-Inference/intro)
30+
- 📚 **导出与上传** - 支持将研究报告导出为PDF、PPTX、DOCX、HTML格式;支持将报告上传至ModelScope、HuggingFace、GitHub
3031

3132

3233
<br>
@@ -104,9 +105,86 @@ ms-agent app --doc_research \
104105
> 本地运行时,默认访问地址为 `http://0.0.0.0:7860/` ,如无法访问,可尝试关闭VPN <br>
105106
106107

108+
### 4. 报告导出
109+
DocResearch支持将markdown格式报告导出为多种格式,方便用户进行存档和分享:
110+
- PDF
111+
- PPTX
112+
- HTML
113+
- DOCX
114+
115+
**使用Python脚本导出示例:**
116+
```python
117+
from ms_agent.utils.markdown_converter import MarkdownConverter
118+
119+
report_path: str = '/path/to/report_dir'
120+
output_path: str = '/path/to/output_dir'
121+
122+
# Call export functions
123+
MarkdownConverter.markdown_to_html(report_path, output_path + "/html")
124+
MarkdownConverter.markdown_to_docx(report_path, output_path + "/docx")
125+
MarkdownConverter.markdown_to_pptx(report_path, output_path + "/pptx")
126+
MarkdownConverter.markdown_to_pdf(report_path, output_path + "/pdf")
127+
```
128+
129+
### 5. 报告上传分享
130+
DocResearch支持将生成的markdown格式研究报告上传至多个平台,方便用户进行分享和协作:
131+
- **ModelScope**
132+
- **HuggingFace**
133+
- **GitHub**
134+
135+
**上传到ModelScope:**
136+
```python
137+
from ms_agent.utils.push_to_hub import PushToModelScope
138+
139+
# ModelScope令牌获取: https://modelscope.cn/my/myaccesstoken
140+
push_to_ms = PushToModelScope(token='ms-xxx')
141+
142+
push_to_ms.push(
143+
repo_id='your-username/your-repo-name',
144+
folder_path='/path/to/report_dir',
145+
path_in_repo='report',
146+
commit_message='Upload research report to ModelScope',
147+
)
148+
```
149+
150+
**上传到HuggingFace:**
151+
```python
152+
from ms_agent.utils.push_to_hub import PushToHuggingFace
153+
154+
# HuggingFace令牌获取: https://huggingface.co/settings/tokens
155+
push_to_hf = PushToHuggingFace(token='hf_xxx')
156+
157+
push_to_hf.push(
158+
repo_id='your-username/your-repo-name',
159+
folder_path='/path/to/report_dir',
160+
path_in_repo='report',
161+
commit_message='Upload research report to HuggingFace',
162+
)
163+
```
164+
165+
**上传到GitHub:**
166+
```python
167+
from ms_agent.utils.push_to_hub import PushToGitHub
168+
169+
# 获取GitHub PAT(Personal Access Tokens): https://github.com/settings/tokens
170+
push_to_git = PushToGitHub(
171+
user_name = 'your-username',
172+
repo_name = 'your-repo-name',
173+
token = 'xxx',
174+
visibility = 'public', # `public` or `private`
175+
description = 'A repository for research reports generated by MS-Agent DocResearch',)
176+
177+
push_to_git.push(
178+
folder_path='/path/to/report_dir',
179+
path_in_repo='report',
180+
commit_message='Upload research report to GitHub',
181+
)
182+
```
183+
184+
107185
<br>
108186

109-
## 使用说明
187+
## Gradio UI使用说明
110188

111189
1. **用户提示**:在文本框中输入您的研究目标或问题
112190
2. **文件上传**:选择需要分析的文件(支持多选)

requirements/research.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exa-py
55
google-search-results
66
gradio>=5.0.0
77
json5
8+
markdown
89
mcp
910
modelscope
1011
openai

0 commit comments

Comments
 (0)