Add an AI-powered assistant to WebViewer, enabling chat-based Q&A, document and selected-text summarization, keyword extraction, and contextual prompts that lets users ask questions about their PDFs.
WebViewer is a powerful JavaScript-based PDF Library that is part of the Apryse SDK.
A license key is required to run WebViewer. You can obtain a trial key in our get started guides, or by signing-up on our developer portal.
Before you begin, make sure the development environment includes Node.js 20 or newer.
git clone --depth=1 https://github.com/ApryseSDK/webviewer-samples.git
cd webviewer-samples/webviewer-ask-ai
npm install
OpenAI is the default backend for this sample. To get started, rename .env.example file into .env and fill the following:
OPENAI_API_KEY=your-openai-api-key-here
OPENAI_MODEL=your-openai-model-here
OPENAI_MAX_TOKENS=your-openai-max-tokens-here
OPENAI_TEMPERATURE=your-openai-temperature-here
OPENAI_SEED=your-openai-seed-here
To use another model, replace the LangChain provider in server/llmManager.js, install the corresponding provider package, and update the .env variables for that model provider.
npm start
This will start a server that you can access the WebViewer client at http://localhost:4040/client/index.html, and manage the connection to the OpenAI on backend.
