AI Search Block

Let users talk with your content without writing custom code. This module provides a powerful search interface that uses AI to query and interact with your Drupal content in real-time.

Streaming AI responses

Overview

Built on top of the AI module, this module allows users to query your content using natural language. Responses are streamed back in real-time, providing a seamless conversational experience directly within your site.

Important: This is not a virtual assistant. This module talks with your indexed data. If no relevant data is found, no response will be generated (by design).

Key Features

  • Real-time Streaming: Responses stream back to users as they're generated
  • Configurable Search Forms: Customize placeholder text, submit buttons, and input types
  • Multiple Data Sources: Query different content types and databases
  • User Feedback: Built-in scoring system for response quality
  • Copy to Clipboard: Easy sharing of AI-generated responses
  • Search Analytics: Optional logging submodule with comprehensive graphs and statistics
  • Performance Optimized: Database indices and caching for fast response times

Search Analytics & Logging

The optional AI Search Block Log submodule provides comprehensive analytics:

  • Track total searches per day with per-block breakdown
  • Monitor average quality scores over time
  • View score distribution trends
  • Analyze searches by user and block
  • Performance optimized with database indices and 1-hour caching
  • Interactive charts using Chart.js

Requirements

  • AI module installed and configured
  • AI embedding model configured
  • LLM (chat) model configured
  • Vector database installed and configured
  • Content indexed in your vector database

Installation

  1. Install the module: composer require drupal/ai_search_block
  2. Enable the module: drush en ai_search_block
  3. Optional: Enable logging: drush en ai_search_block_log
  4. Clear cache: drush cr

Configuration

Step 1: Add Blocks

Place the "AI Search" and "AI Search Response" blocks into your desired regions.

Add blocks to regions

Step 2: Configure the Search Block

Configure your AI search block settings including:

  • Input field type (text field or textarea)
  • Placeholder text and submit button labels
  • Loading and suffix messages
  • Enable/disable streaming responses
  • Enable/disable database results
  • Clear form after search option

Configure search block

Step 3: Select Your Data Source

Choose which content to query - select your configured vector database and content types.

Select data source

Step 4: Start Searching

Users can now search your content using natural language queries. Responses stream back in real-time.

Search interface

Step 5: View Analytics (Optional)

If you've enabled the AI Search Block Log submodule, visit /admin/config/ai/ai_search_block_log/graphs to view comprehensive search analytics and statistics.

Performance

The module is optimized for production use:

  • Database Indices: Composite indices on frequently queried columns
  • Query Caching: 1-hour cache for analytics data
  • Efficient Aggregations: Optimized SQL queries for statistics
  • Lazy Loading: Charts and data load efficiently

Permissions

  • access content - View and use the search interface
  • administer ai_search_block_log - Access analytics and graphs

Support

For issues, feature requests, or contributions, please visit the issue queue.

Credits

This module integrates with the AI module and uses Chart.js for visualizations.

Supporting organizations: 
Funding
Funding

Project information

Releases