add support markdown download

This commit is contained in:
Prajna Kandarpa
2024-07-19 12:32:32 +05:30
parent 701d1d6dbb
commit 3e860fc30b
6 changed files with 11 additions and 6 deletions
+1
View File
@@ -1 +1,2 @@
.git
output/
+1 -1
View File
@@ -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"]
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -25,4 +25,4 @@ services:
- ./multi_agents/frontend:/app
restart: always
ports:
- 3000:3000
- 3000:3000
+3 -1
View File
@@ -141,7 +141,9 @@
<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>
+4 -2
View File
@@ -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 = () => {