Add the LLM API key in settings.php:



// API key for LLM connection.
$settings['llm_enhanced_search'] = [
  'llm_api_key' => 'abcdefghijklmnopqrst',
];

// Example of request local ollama inside docker
// The website is inside a container and it can access ollama from host via 7869
// That means curl -s http://host.docker.internal:7869/api/tags works from
// the website container.
// Fill the setting form with http://host.docker.internal:7869/v1
// Fill token with non empty string even if local ollama doesn't need it.
$settings['llm_enhanced_search'] = [
  'llm_api_key' => 'nonempty',
];


Enable the module.

Configure the LLM endpoint URL, model and timeout at:

/admin/config/llm_enhanced_search/llm

The module supports OpenAI-compatible APIs. Configure the endpoint
according to your LLM provider.

Configure the taxonomy vocabulary at:

/admin/config/llm_enhanced_search/vocabulary

This vocabulary provides the terms used to enhance search queries.

Use a Search API-powered View with an exposed full-text search filter.

Configure the View to be enhanced at:

/admin/config/llm_enhanced_search/searchview

Search using the exposed filter. The module sends the query to the LLM
and adds a matching term from the configured vocabulary to the query.

For example, portable computer can be enhanced with the term Laptop.

The LLM result is validated against the vocabulary before being added.
Terms already present in the query are not added again.

Other exposed filters are preserved. If no valid term is identified,
the original query is left unchanged.

The selected taxonomy term can be found in the results page URL.



Troubleshooting
===============
Check /admin/reports/status to verify that the configuration can communicate with the configured LLM.

This module works better when the search form uses OR instead of AND.

For example, old persons may be expanded to
old persons senior. With OR, results can match senior without
necessarily containing old or person.
