📚 e-llm-studio/citation
BPA AI monorepo: this package is consumed locally as
@e-llm-studio/citation with the dependency version workspace:*.
The remaining content is retained from the original library documentation.
Table of Contents
- Project Overview
- Installation
- Available Components
- Citation Components
- BookCitation
- ChatCitation
- CitationRenderer
- EmailCitation
- CognitiveDecisioningCard
- CognitiveCompare
- CognitiveInternalGPTReasoning
- GptWebCitation
- PdfTableCitation
- CodeCitation
- ChatDrawer
- CitationsViewer
- PdfEditorCitation
- RequirementAICitation
- VideoCitationContent
- MarkdownWithImageCitation
- ScannedDocCitation
- InstantLearningCitationComponent
- CitationOrchestratorComponent
- Other Components
- Bookemon
- DatagestMon
- DataSelector
- PaginatedTable
- PdfViewer
- ProjectAccordion
- UploadData
- ReviewPanel
- TableCitationContent
- SplitterCitationsComponent
- RuleBookCitationWrapper
-ManageReminders
- PromptemonBlockViewer
- PromptemonViewer
- SPBAnalysisPanel
- Common Use Cases
- Development & Contribution
- License
Project Overview
The @e-llm-studio/citation library is a comprehensive React component library designed to render various types of citations and related UI elements within the e-LLM Studio ecosystem. It provides a robust set of reusable, production-ready components that enable developers to display citations, reasoning chains, code snippets, PDFs, and other content types with rich interactive features and highly customizable styling.
This library serves as a foundational building block for applications that need to present complex information in an organized, user-friendly manner. Whether you're displaying book citations with highlighted passages, rendering AI reasoning with confidence scores, showcasing code with syntax highlighting, or managing large datasets with pagination, the citation library offers flexible, well-documented components that integrate seamlessly into modern React applications.
The library emphasizes developer experience through comprehensive documentation, TypeScript support, and extensive customization options. Each component is designed with accessibility and performance in mind, ensuring that applications built with these components provide excellent user experiences across different devices and use cases.
Installation
Prerequisites
Before you begin, ensure you have the following installed on your system:
- Node.js & npm - Required for package management and running build scripts
- Git - Required for cloning the repository
- Basic familiarity with Git and the command line
Installation Steps
1. Clone the Repository
Start by cloning the citation library repository to your local machine:
git clone https://github.com/e-llm-studio/citation.git
cd citation
2. Install Dependencies
Install all required dependencies using npm:
npm install
Alternatively, you can use yarn if you prefer:
yarn install
3. Link the Library Locally (Optional)
If you want to test the library in another project before publishing, you can link it locally:
# In the citation library folder
npm link
# In your test project folder
cd ../your-project
npm link @e-llm-studio/citation
This allows you to test changes in your local library without publishing to npm.
4. Build the Library
Build the library to compile TypeScript and prepare distribution files:
npm run build
5. Test Locally
After building, you can test the library in your project:
# In your test project
npm start
# or
npm run build
Import the library components and verify that your changes work as expected.
Quick Installation for End Users
If you're installing the published package from npm:
# Using npm
npm install @e-llm-studio/citation
# Using yarn
yarn add @e-llm-studio/citation
# Using pnpm
pnpm add @e-llm-studio/citation
Citation Components
PdfTableCitation
PdfTableCitation is the reusable data layer for citations that reference
tables inside PDF documents. It parses citation anchors, requests citation data
on demand, selects the matching response, and normalizes PDF page coordinates.
The consuming application remains responsible for rendering the PDF and signing
private artifact URLs.
Public API
import {
buildPdfTableCitationPayload,
fetchPdfTableCitation,
normalizePdfTableCitation,
parsePdfTableCitationHref,
resolveUniqueCitationRequestId,
selectPdfTableCitation,
usePdfTableCitation,
type PdfTableCitationConfig,
type PdfTableCitationDescriptor,
type NormalizedPdfTableCitation,
} from "@e-llm-studio/citation";
Anchor format
The href must start with pdf_table_citation$ and provide a positive citation
number in the path or query string.
pdf_table_citation$3?citationNumber=3&citationSource=table&artifact_id=temp-123
Supported parameters are citationNumber/citation_number,
citationSource/citation_source, citation_type, and artifact_id.
Hook usage
The application must render the hook under a TanStack Query
QueryClientProvider.
const descriptor = parsePdfTableCitationHref(href);
if (!descriptor) {
return null;
}
const config: PdfTableCitationConfig = {
baseURL: assistantUrl,
organizationName,
accessToken,
citationAssistantProcessingName: "citationsprocessing",
citationAgentName: "ProcessCitationsAgent",
};
const {
citation,
isLoading,
isFetching,
errorMessage,
canFetch,
refetch,
} = usePdfTableCitation({
descriptor,
requestId,
citedText,
config,
enabled: true,
});
baseURL, organizationName, requestId, and a positive citation number are
required before the query is enabled. Prefer the citation-specific request ID
from the citation map. Use resolveUniqueCitationRequestId(steps) only as a
fallback when all workflow steps share one request ID.
API contract
The hook sends the following request through fetchPdfTableCitation:
POST {config.baseURL}/api/chat/chatResponse
Content-Type: application/json
Authorization: Bearer {config.accessToken} # when provided
{
"name": "citationsprocessing",
"organizationName": "example-organization",
"prompt": "",
"useAgent": {
"agent_name": "ProcessCitationsAgent",
"arguments": {
"citation_type": "pdf_table_citation",
"is_primary_agent_request": false,
"check_possible_citation_payload": true,
"ui_request_body": {
"request_id": "workflow-request-id",
"citation_id": "pdf_table_citation_3",
"cited_text": "optional cited HTML"
}
}
}
}
The request uses credentials and a five-minute timeout. cited_text is omitted
when empty. Assistant and agent names fall back to citationsprocessing and
ProcessCitationsAgent.
Normalized result
citation is a NormalizedPdfTableCitation containing the citation number,
artifact ID, artifact URL, title, format, raw response, and normalized pages:
type PdfTableCitationPage = {
page_no: number;
highlighted_coordinates: Array<{
xmin: number;
ymin: number;
xmax: number;
ymax: number;
}>;
};
Coordinates are values from 0 to 1; percentage-based viewers should
multiply them by 100. Current and legacy response fields are supported,
including customMetaData/customMetadata, bundle_gs_url, segment_gs_url,
gs_url, gcs_url, gcs_signed_url, artifact_url, and
artifact_id_mapping.
Caching and signed URLs
The query key includes the request ID, citation number, citation source, and
temporary artifact ID. Successful results remain fresh and are not refetched on
mount or focus. Automatic retry is disabled; consumers can call refetch().
The hook does not call a URL-signing endpoint. Consumers must reuse URLs that
are already signed, sign private gs:// or unsigned Google Cloud Storage URLs,
and pass the resolved URL to their PDF viewer. Signed URLs can expire, so
long-lived caches should support expiration or invalidation.
BookCitation
Overview
The BookCitation component is designed to display book citations with an interactive and expandable interface. It provides a rich, user-friendly way to present quoted text from books with support for highlighting, citation details management, and book cover images. The component enables readers to explore citations in context while maintaining a clean, organized presentation.
Features
- Text highlighting with partial and full match support - Highlights specific text passages within citations using flexible matching algorithms
- Automatic cleaning of scanned text to remove artifacts - Intelligently removes OCR artifacts, page numbers, headers, and footers
- Expandable/collapsible view of citation details - Toggle between collapsed citation button and expanded view
- Blur effect for non-highlighted text - Applies visual blur to non-highlighted portions to focus reader attention
- Scroll-to-highlight functionality - Automatically scrolls to and centers highlighted text when expanded
- Support for book cover images and external links - Displays book cover images and provides clickable external links
- Customizable styling through the customStyle prop - Allows fine-grained control over component appearance
Usage:
import BookCitation from '@e-llm-studio/citation/BookCitation'
<BookCitation
citationTitle="Sample Book"
paragraphs={['<p>Highlighted text example</p>']}
textToHighlight={['example']}
partialMatch={true}
/>
Props:
| Prop Name |
Type |
Description |
title |
string |
Optional title of the book or publication being cited |
author |
string \| string[] |
Optional author name(s) of the book or publication |
pageNumber |
string |
Optional current page number where the citation is located |
totalPageNumber |
string |
Optional total number of pages in the book or publication |
paragraphs |
string[] |
Required array of HTML strings containing the text content |
citationTitle |
string |
Required title or label for the citation |
textToHighlight |
string[] |
Required array of text strings to highlight within the paragraphs |
bookCoverImage |
string |
Optional URL or path to the book cover image |
handleExternalLinkClick |
() => void |
Optional callback function triggered when external link is clicked |
externalLinkComponent |
React.ReactNode |
Optional React component to render as an external link button |
citationNumber |
number |
Optional citation number displayed in the citation button |
partialMatch |
boolean |
Optional flag to enable partial text matching when highlighting |
defaultState |
boolean |
Optional flag to set the initial expanded/collapsed state |
isNonHighlightedBlur |
boolean |
Optional flag to enable blur effect on non-highlighted text |
customStyle |
object |
Optional object for overriding default styles |
useDropdown |
boolean |
Optional flag to render the citation as a dropdown (default: true) |