diff --git a/app/backend/app.py b/app/backend/app.py index b22e817de9..e2b6cc60c7 100644 --- a/app/backend/app.py +++ b/app/backend/app.py @@ -94,10 +94,11 @@ async def content_file(path: str): This is also slow and memory hungry. """ # Remove page number from path, filename-1.txt -> filename.txt + # This shouldn't typically be necessary as browsers don't send hash fragments to servers if path.find("#page=") > 0: path_parts = path.rsplit("#page=", 1) path = path_parts[0] - logging.info("Opening file %s at page %s", path) + logging.info("Opening file %s", path) blob_container_client = current_app.config[CONFIG_BLOB_CONTAINER_CLIENT] try: blob = await blob_container_client.get_blob_client(path).download_blob() diff --git a/app/backend/approaches/chatapproach.py b/app/backend/approaches/chatapproach.py index b2a8e957ed..e3f2e492f3 100644 --- a/app/backend/approaches/chatapproach.py +++ b/app/backend/approaches/chatapproach.py @@ -37,7 +37,7 @@ class ChatApproach(Approach, ABC): Make sure the last question ends with ">>". """ - query_prompt_template = """Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge. + query_prompt_template = """Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base. You have access to Azure AI Search index with 100's of documents. Generate a search query based on the conversation and the new question. Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms. diff --git a/app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx b/app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx index 16c52cacc9..4ee405dbd7 100644 --- a/app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx +++ b/app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx @@ -34,12 +34,19 @@ export const AnalysisPanel = ({ answer, activeTab, activeCitation, citationHeigh const fetchCitation = async () => { const token = client ? await getToken(client) : undefined; if (activeCitation) { + // Get hash from the URL as it may contain #page=N + // which helps browser PDF renderer jump to correct page N + const originalHash = activeCitation.indexOf("#") ? activeCitation.split("#")[1] : ""; const response = await fetch(activeCitation, { method: "GET", headers: getHeaders(token) }); const citationContent = await response.blob(); - const citationObjectUrl = URL.createObjectURL(citationContent); + let citationObjectUrl = URL.createObjectURL(citationContent); + // Add hash back to the new blob URL + if (originalHash) { + citationObjectUrl += "#" + originalHash; + } setCitation(citationObjectUrl); } }; diff --git a/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx b/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx index 72bf5f7bac..fb7ce9e8d1 100644 --- a/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx +++ b/app/frontend/src/components/AnalysisPanel/ThoughtProcess.tsx @@ -12,9 +12,9 @@ interface Props { export const ThoughtProcess = ({ thoughts }: Props) => { return (