From 3e860fc30b0a0d473608839afacd2901ea60cd72 Mon Sep 17 00:00:00 2001 From: Prajna Kandarpa Date: Fri, 19 Jul 2024 12:32:32 +0530 Subject: [PATCH] add support markdown download --- .dockerignore | 1 + Dockerfile | 2 +- backend/utils.py | 2 +- docker-compose.yml | 2 +- frontend/index.html | 4 +++- frontend/scripts.js | 6 ++++-- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 6b8710a71..53e88ba08 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ .git +output/ diff --git a/Dockerfile b/Dockerfile index 1d6e96d78..a0c410225 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/backend/utils.py b/backend/utils.py index c0678cc04..04ff27158 100644 --- a/backend/utils.py +++ b/backend/utils.py @@ -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. diff --git a/docker-compose.yml b/docker-compose.yml index f1a98b6c6..1bdc8b6f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,4 +25,4 @@ services: - ./multi_agents/frontend:/app restart: always ports: - - 3000:3000 \ No newline at end of file + - 3000:3000 diff --git a/frontend/index.html b/frontend/index.html index d42cf7176..ec1b30bb9 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -141,7 +141,9 @@

Research Report

Copy to clipboard + style="margin-right: 10px;">Copy to clipboard (markdown) + Download as Markdown Download as PDF Download as Docx diff --git a/frontend/scripts.js b/frontend/scripts.js index a28229744..23a75cdd7 100644 --- a/frontend/scripts.js +++ b/frontend/scripts.js @@ -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 = () => {