Skip to content

Instantly share code, notes, and snippets.

View alexander-densley's full-sized avatar

Alexander Densley alexander-densley

View GitHub Profile
export const tableOfContentsPrompt = `You are a document analyzer. Your task is to extract the table of contents from a document. This table of contents could be under the name "table of contents", "page schedule", "sheet list", or others. If there is no formal table of contents, you may need to just sift through all pages and return the page numbers and titles. The priorty should be to line up the page titles and the actual page numbers. If theres is a title on the page use that as the title, even if it conflicts with the table of contents on page 1. If you're unable to do any of this, you should return an error saying "Failed to return table of contents".
Return the table of contents as a JSON object with the following format:
\`\`\`json
{
"table_of_contents": [
{
"pageName": "page_name",
"pageNumber": page_number,
/* eslint-disable @typescript-eslint/no-explicit-any */
'use client'
import { WebViewerInstance } from '@pdftron/webviewer'
import { Ref, useEffect, useState, useRef } from 'react'
export default function Viewer({ urls }: { urls?: string[] }) {
const viewer: Ref<HTMLDivElement | any> = useRef(null)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [webviewerInstance, setWebViewerInstance] = useState<