AI Assistant on Flutter

Nutrient AI Assistant brings AI chat capabilities to your documents, enabling users to ask questions in natural language and get answers without sifting through pages of text. AI Assistant is ideal for summarizing, translating, and finding certain information in documents. Users can tap links in the chat to jump to the part of the document information came from.

To use this feature, run Nutrient AI Assistant(opens in a new tab) on your server.

Setting up AI Assistant on Flutter

To get started, either implement AI Assistant in your own app by following the steps below, or check out the nutrient_ai_assistant_example in our Catalog app(opens in a new tab).

  1. Set up Nutrient AI Assistant on your server, or run the server locally. The easiest way to get started is to clone our AI Assistant demo repository(opens in a new tab) and follow the instructions in the README.

  2. Set an AIAssistantConfiguration in your main PdfConfiguration. This configuration specifies the URL where your AI Assistant server can be accessed, a JSON Web Token (JWT) for authentication, a session identifier, and an optional user identifier. It’s best practice for the JWT to be generated by your own server:

// Create the AI Assistant configuration.
final aiConfig = AIAssistantConfiguration(
serverUrl: 'https://your-ai-assistant-server.com',
jwt: 'your-jwt-token', // Generate this from your server.
sessionId: 'unique-session-id',
userId: 'optional-user-id',
);
// Add to the PDF configuration.
final pdfConfig = PdfConfiguration(
aiAssistantConfiguration: aiConfig,
androidEnableAiAssistant: true,
iOSLeftBarButtonItems: ['aiAssistantButtonItem'],
);
  1. Add AI Assistant to your platform-specific UI.

    • iOS — Add 'aiAssistantButtonItem' to iOSLeftBarButtonItems or iOSRightBarButtonItems
    • Android — Set androidEnableAiAssistant: true
    • Web — Add the AI Assistant button to your toolbar:
webConfiguration: PdfWebConfiguration(
toolbarItems: [
PspdfkitWebToolbarItem(type: PspdfkitWebToolbarItemType.aiAssistant),
...Pspdfkit.defaultWebToolbarItems,
],
),

When users tap the AI Assistant button, the document data will be uploaded to AI Assistant on your server, and the chat UI will be presented.