-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
// 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); | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,9 @@ interface Props { | |
export const ThoughtProcess = ({ thoughts }: Props) => { | ||
return ( | ||
<ul className={styles.tList}> | ||
{thoughts.map(t => { | ||
{thoughts.map((t, ind) => { | ||
return ( | ||
<li className={styles.tListItem}> | ||
<li className={styles.tListItem} key={ind}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
<div className={styles.tStep}>{t.title}</div> | ||
{Array.isArray(t.description) ? ( | ||
<SyntaxHighlighter language="json" wrapLongLines className={styles.tCodeBlock}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,32 +6,23 @@ interface Props { | |
supportingContent: string[] | { text: string[]; images?: { url: string }[] }; | ||
} | ||
|
||
interface SupportingItemProps { | ||
title: string; | ||
content: string; | ||
} | ||
|
||
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) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. :) |
||
const parsed = parseSupportingContentItem(c); | ||
return <TextSupportingContent {...parsed} />; | ||
return ( | ||
<li className={styles.supportingContentItem} key={ind}> | ||
<h4 className={styles.supportingContentItemHeader}>{parsed.title}</h4> | ||
<p className={styles.supportingContentItemText} dangerouslySetInnerHTML={{ __html: parsed.content }} /> | ||
</li> | ||
); | ||
})} | ||
{imageItems?.map(i => { | ||
return <img className={styles.supportingContentItemImage} src={i.url} />; | ||
{imageItems?.map((img, ind) => { | ||
return <img className={styles.supportingContentItemImage} src={img.url} key={ind} />; | ||
})} | ||
</ul> | ||
); | ||
}; | ||
|
||
export const TextSupportingContent = ({ title, content }: SupportingItemProps) => { | ||
return ( | ||
<li className={styles.supportingContentItem}> | ||
<h4 className={styles.supportingContentItemHeader}>{title}</h4> | ||
<p className={styles.supportingContentItemText} dangerouslySetInnerHTML={{ __html: content }} /> | ||
</li> | ||
); | ||
}; |
There was a problem hiding this comment.
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.