Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get PDFs to jump to their pages again #1283

Merged
merged 4 commits into from
Feb 17, 2024
Merged

Get PDFs to jump to their pages again #1283

merged 4 commits into from
Feb 17, 2024

Conversation

pamelafox
Copy link
Collaborator

Purpose

Fixes #1245

This PR has a few fixes, but the biggest one is a fix for regression introduced by #1160 which replaced citation URLs with blob URLs. My fix remembers the hash and adds it to the blob URL after, which seems to work correctly in Edge. I couldn't find any documentation as to whether blob URLs formally support hash fragments, but they seem to!

Does this introduce a breaking change?

[ ] Yes
[X] No

Pull Request Type

What kind of change does this Pull Request introduce?

[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Click on citations in answers that have #page= hash, see PDF viewer jump to that page
  • Switch to GPT4V env, click on citations with no hash, see them open fine

@@ -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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was caught by a reader of my blog post today-https://blog.pamelafox.org/2024/02/rag-techniques-cleaning-user-questions.html

Doubt it affects anything as GPTs dont mind lil errors.

return (
<li className={styles.tListItem}>
<li className={styles.tListItem} key={ind}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were getting a bunch of React errors locally from missing key= values. An index isnt the best thing to use but it should be okay for our situation.

export const SupportingContent = ({ supportingContent }: Props) => {
const textItems = Array.isArray(supportingContent) ? supportingContent : supportingContent.text;
const imageItems = !Array.isArray(supportingContent) ? supportingContent?.images : [];
return (
<ul className={styles.supportingContentNavList}>
{textItems.map(c => {
{textItems.map((c, ind) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, this was just fixing index. And I moved the HTML inside the class as I couldn't deal with writing the correct Typescript for the separate component. :)

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense since we download the full object url. Appreciate your fix

@pamelafox pamelafox merged commit 33bc505 into Azure-Samples:main Feb 17, 2024
10 checks passed
@pamelafox pamelafox deleted the page-fix branch February 17, 2024 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jump to the right page
2 participants