Skip to content

Commit

Permalink
Merge pull request #688 from pkandarpa-cs/md-download
Browse files Browse the repository at this point in the history
add support for markdown file download from UI
  • Loading branch information
assafelovic authored Jul 19, 2024
2 parents b818e4b + 3e860fc commit 05584a4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.git
output/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ USER gpt-researcher
COPY --chown=gpt-researcher:gpt-researcher ./ ./

EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
2 changes: 1 addition & 1 deletion backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def write_text_to_md(text: str, filename: str = "") -> str:
"""
file_path = f"outputs/{filename[:60]}.md"
await write_to_file(file_path, text)
return file_path
return urllib.parse.quote(file_path)

async def write_md_to_pdf(text: str, filename: str = "") -> str:
"""Converts Markdown text to a PDF file and returns the file path.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ services:
- ./multi_agents/frontend:/app
restart: always
ports:
- 3000:3000
- 3000:3000
4 changes: 3 additions & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ <h2>Research Report</h2>
<div id="reportActions">
<div class="alert alert-info" role="alert" id="status"></div>
<a id="copyToClipboard" onclick="GPTResearcher.copyToClipboard()" class="btn btn-secondary mt-3"
style="margin-right: 10px;">Copy to clipboard</a>
style="margin-right: 10px;">Copy to clipboard (markdown)</a>
<a id="downloadLinkMd" href="#" class="btn btn-secondary mt-3" style="margin-right: 10px;"
target="_blank">Download as Markdown</a>
<a id="downloadLink" href="#" class="btn btn-secondary mt-3" style="margin-right: 10px;"
target="_blank">Download as PDF</a>
<a id="downloadLinkWord" href="#" class="btn btn-secondary mt-3" target="_blank">Download as Docx</a>
Expand Down
6 changes: 4 additions & 2 deletions frontend/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ const GPTResearcher = (() => {
const updateDownloadLink = (data) => {
const pdf_path = data.output.pdf
const docx_path = data.output.docx
document.getElementById('downloadLink').setAttribute('href', pdf_path)
document.getElementById('downloadLinkWord').setAttribute('href', docx_path)
const md_path = data.output.md;
document.getElementById('downloadLink').setAttribute('href', pdf_path);
document.getElementById('downloadLinkWord').setAttribute('href', docx_path);
document.getElementById("downloadLinkMd").setAttribute("href", md_path);
}

const updateScroll = () => {
Expand Down

0 comments on commit 05584a4

Please sign in to comment.