Configuration

Configure static search, indexing, and the AI assistant in DocLayer's Search Module

This page outlines the configuration options for the dl-search module, which powers both search functionality and the AI Assistant in DocLayer. Please read the instructions carefully, as some options are interdependent and may affect each other, especially when it comes to the assistant configuration.

Applying configuration

To apply your custom configuration just define it within the nuxt.config.ts file:

export default defineNuxtConfig({  modules: ['@vuehouse/dl-search'],  dlSearch: {    // configuration goes here  },  // or with modules array definition  modules: [['@vuehouse/dl-search', {}]],});

Configuration

Below you will find a comprehensive list of all available configuration options for the dl-search module. Treat this as a standalone reference for the module setup, outside the context of DocLayer.

collections

Option specifies which content collections will be parsed.

typedefaultrequired

string[]

['docs']no

By default, it is an array of strings set to ['docs']. If you provide an array of collection names, they will be prioritized over the default value. Leave the empty array to disable the collections parsing.

assistant.enabled

Option is used to control whether the AI Assistant is enabled or disabled.

typedefaultrequired
booleanfalseno

AI Assistant is disabled by default; as explained on the previous page, enabling this option requires these two environment variables to be properly set: DL_SEARCH_ASSISTANT and DL_SEARCH_ASSISTANT_HFC. Be aware that if assistant is enabled, the dedicated assets will be added to the application build.

By default DocLayer sets this conditional logic for you, so your main task is to set the environment variables in your .env file.

Why not use just the environment variables? This option is provided not only to allow the assistant functionality to depend on internal conditions, but also to give you the flexibility to define your own rules for enabling it.

When the assistant is enabled, the model type is automatically set to local. This means that when you start the application, the preparation process for this type of setup will be applied. If you want to use a different configuration, please refer to the model type options.

assistant.contentTopK

Option controls the number of top content pages to use to resolve the answer.

typedefaultrequired
NumberRange<1, 10>3no

To answer the user's question (prompts), the assistant first selects the most relevant sections (within the relevant pages) from the content index. This option determines how many of these top-ranked content sections the assistant will use to generate the final answer. In a perfect world, the assistant would read from all pages, but that would be very performance-intensive. Therefore, the content is first ranked, and only the best pages are selected for further processing.

assistant.contextTopK

Option controls the number of top context chunks to use to resolve the answer.

typedefaultrequired
NumberRange<1, 10>3no

The assistant will select the most relevant sections (within the relevant pages) that best match the user's question (prompts). This option determines how many of these top-ranked context chunks or sections the assistant will use to generate the final answer. Although, when assistant.extractContextFrom is set to 'page', this option has no effect, as all of the page sections are picked up to build a context.

assistant.preciseContext

Option controls whether to use the fully precised context for the Assistant.

typedefaultrequired
booleanfalseno

By default, the assistant will use the full context extracted from the content index. This means it will access more data to answer user's questions, which can sometimes introduce irrelevant information and lower the quality of the response. Setting this option to true makes the assistant focus the context more precisely on the user's question, potentially improving the answer quality.

assistant.extractContextFrom

Option controls whether to extract the context from the section or the page.

typedefaultrequired
'section' | 'page''section'no

By default, the assistant extracts context from 'section'. This means that, for each of the most relevant sections found in your content index, those sections will be passed as the context to the model. If you set this option to 'page' instead, the entire page containing the relevant section will be sent to the model as context.

Keep in mind that since contextTopK controls how many sections are included, you should adjust it accordingly. When using 'page', it is best to keep contentTopK set to 1 to prevent sending overly large payloads to the API. Local model can handle larger context quite well.

assistant.extractCodeFrom

Option controls whether to extract code snippets.

typedefaultrequired
'answer' | 'context'undefinedno

Internally, the assistant uses a Code Reference resolution algorithm to extract code snippets either from the context or the final model answer, depending on this option. Note that extracting from the context may include code references that are less relevant to the user's question, as the context contains broader information.

Finally, extracted code references will be returned along with the meta object of the answer in the cref array.

{  "answer": "The answer to the user's question",  "score": 1,  "meta": {    "cref": ["cref:1", "cref:2", "cref:3"]  }}

Additionally, if assistant.model.type is set to 'local' and the assistant extracts code references, the code snippets will be fetched from the dedicated repository and included in the meta.code array. You can then easily render these code items in the UI using the DlCode component. In this case, it is recommended to set assistant.extractCodeFrom to context, since it is unlikely that code references will be returned directly with the answer due to the limitations of smaller models.

assistant.model

General object to control the model used by the AI Assistant.

typedefaultrequired
Modelsee belowno

The model object support four different interfaces, depending on the type of model you specify. By default, the assistant uses the local one, which employs a lightweight feature-extraction model to match user questions against the indexed content. More about selecting the operational model you can read here.

This is the default configuration for the assistant model.

export default defineNuxtConfig({  dlSearch: {    assistant: {      // the rest of the assistant configuration      model: {        type: 'local',        config: {          modelProcessedAnswer: true,        },      },    },  },});

Note that explicitly defining this is not necessary - it will be applied automatically if you "select" the local model. If your intention is to customize the configuration, then provide the config object.

assistant.model.type

Option controls the type of model to use.

typedefaultrequired

'local'
'dl'
'remote'
'custom'

'local'no

By default, the assistant uses the local model.

assistant.model.config

General object to control the configuration of the model used by the AI Assistant.

typedefaultrequired
Record<string, unknown>

depends on the model type

no

The config property depends on the chosen model type. Selecting different model types will require different config options. Below, we outline the configuration options and usage examples for each type.

More about model configuration reference, you can read here.

Assistant model type: 'local'

Below you can see the local model configuration.

assistant.model.config.modelProcessedAnswer

Option controls whether to process the answer with a local model.

typedefaultrequired
booleantrueno

By default, the assistant uses the AI model to generate the answer. If you set this option to false, the assistant will instead return the most relevant, ranked context directly as the answer, without processing it with the model. This can be helpful if you want to receive the top relevant context for further custom processing, rather than relying on the model's output.

assistant.model.config.answerCount

Option controls the number of answers to return from the assistant.

typedefaultrequired
NumberRange<1, 5>1no

By default, the assistant returns one answer. Setting this option to a higher number will make the assistant return multiple answers. This is useful if you want to receive several potentially relevant answers from the context to your question.

assistant.model.config.extractRichestAnswer

Option controls whether to extract the richest answer.

typedefaultrequired
booleanfalseno

If the answerCount option is set to a value greater than 1, the assistant will return the richest answer from the context. In this case, "richest" means the selected answer is determined by both score and length. If answerCount is set to 1, this option is ignored.

Assistant model type: 'dl'

Below you can find the DocLayer AI model configuration.

DocLayer's Remote Model

DocLayer offers a prebuilt remote API for the AI Assistant, providing advanced features like context focusing, deterministic intelligent caching, and optimized code extraction to deliver precise, high-quality answers (almost) every time.

Our carefully fine-tuned model is available through the 🫠 Early Supporter Program - help us to build the best product possible securing the most advanced features for the best price.

Here’s how you can configure it:

export default defineNuxtConfig({  // the rest of the nuxt.config.ts  modules: ['@vuehouse/dl-search'],  dlSearch: {    assistant: {      model: {        type: 'dl',        config: {          endpoint: 'https://vue.house/api',          token: process.env.DL_API_TOKEN,        },      },    },  },});

To try our API please contact us. It's free.

Remote API operates with a dedicated DocLayer AI Kit.

assistant.model.config.endpoint

Input to specify the endpoint of the remote model to use.

typedefaultrequired

'https://vue.house/api'

undefinedyes

assistant.model.config.token

Input to specify the token of the remote API.

typedefaultrequired
stringundefinedyes

Assistant model type: 'remote'

Besides the remote API provided by DocLayer, you can use your own API to power the AI Assistant and answer your users' questions.

To do this, you need to create a new Adapter - our internal extensibility system. There is a dedicated and reserved key, assistant, under which you should register your adapter within the app.config.ts file. The module will then call this adapter to resolve the user's question or prompt. Here is how you should register your adapter along with the remote model type:

export default defineNuxtConfig({  // the rest of the nuxt.config.ts file  dlSearch: {    assistant: {      model: { type: 'remote' },    },  },});
import assistantAdapter from './adapters/assistant';export default defineDoclayerAppConfig({  // the rest of the app.config.ts file  dl: {    adapters: {      assistant: assistantAdapter('assistant-custom', {        // use external API endpoint, or Nuxt API route        endpoint: 'http://your-api-endpoint.com/api/assistant',      }),    },  },});
import { defineDoclayerAdapter } from '@vuehouse/dl/exports';import type { PromptAsyncDataResponse } from '@vuehouse/dl/types';type AssistantContext = {  config: { endpoint: string };  input: { prompt: string; context: string };};type AssistantResponse = PromptAsyncDataResponse['data'];export default defineDoclayerAdapter<AssistantContext, AssistantResponse>((adapter, { config, input }) => {  return adapter(    'assistant',    async () =>      await fetch(config.endpoint, {        method: 'POST',        body: JSON.stringify(input),      }),  );});

The external API should return the expected data structure, which will then be processed by the asyncData function before being provided to your application. The assistant adapter enforces the correct data structure through its types. For your convenience, here is an example of the expected response interface (you can also use the prebuilt type from the module as shown above).

type PromptConfidence = 'high' | 'medium' | 'low';type AssistantResponse = {  answer: string;  confidence?: PromptConfidence;  score?: number;};

To ensure proper integration, we highly recommend reviewing how the adapters work and how to build them. This will help you avoid common pitfalls and ensure a smooth integration process.

Assistant model type: 'custom'

Option controls whether to use a custom model(s).

Last but not least, you can also provide your own models for the application. When this option is enabled, the module will not include the prebuilt models for embeddings and search-generation. Instead, you can manually add your custom models. These models must be placed in the public/.doclayer/models directory with the following folder structure:

public/.doclayer/models├── embed│   └── e5 / allmini / [custom]│   │   └──  onnx│   │   │    └── model_quantized.onnx│   │   ├──  config.json│   │   ├──  tokenizer_config.json└── └── └──  tokenizer.json├── search│   └──  onnx│   │    └── model_quantized.onnx│   ├──  config.json│   ├──  tokenizer_config.json└── └──  tokenizer.json

Important note would be that the module expects quantized with ONNX format models.

embedding

Object to control the embedding model used by the AI Assistant.

typedefaultrequired

{ model: 'allmini' | 'e5' }

{ model: 'e5' }no

Embedding models convert content into their vector representations, which are used to search the content index in response to user questions (prompts). Changing the embedding model may result in different vector quality; using a smaller model can provide less accurate results, but might be faster and more suitable for less complex content, such as simple blogs. By default, the assistant uses the e5 embedding model. More about embedding models as internal assets you can read here.

Currently, the following embedding models are supported:

  • allmini all-MiniLM-L6-v2: lightweight embedding model,
  • e5 e5-small-v2: bigger (still small) embedding model.

exclusions

Option controls the exclusions for the AST parser.

typedefaultrequired
Exclusionscheck hereno

When parsing content, the internal parser automatically excludes special characters, tags, custom tags, definitions, and other elements that are not relevant or important for content indexing. This helps ensure cleaner parsing and more accurate search results. You can add your own exclusions by following the Exclusions interface; your custom ones will be merged with the defaults. Alternatively, you can provide a callback function to fully override the exclusions.

iterations

Specifies how many times the parser should process the content.

typedefaultrequired
{ current: number, total: number }{ current: 0, total: 1 }no

By default, the parser will iterate over the content once. If you set the total value to a higher number, the parser will process the content multiple times. This can be helpful for ensuring the content is fully and accurately processed during runtime. However, parsing content on each update may impact performance, as it can be time-consuming. It is recommended to parse the content primarily when starting the application fresh. The current value is used internally to track progress and should not be set manually.

debug

Object to control the debug mode.

typedefaultrequired
type DebugOptions =  | {      mint: boolean;      parser: boolean;      assistant: boolean;      compression: boolean;    }  | boolean;
falseno

Each property controls debug mode for a specific part of the search module.

  • parser - Controls the debug mode for the AST parser. When enabled, internal parser will inform you about potential issues with the content parsing.
  • assistant - Controls the debug mode for the AI Assistant. When enabled, you'll be able to to see the assistant’s internal logs - such as resolved context and metadata - in the browser console.
  • compression - Controls the debug mode for the compression process. By default all of the application-saved assets are compressed, setting this option to true will disable compression.
  • mint - Controls the debug mode in the mint way.

By default all debugging options are disabled. Because parser logging can be quite verbose, there is an internal Mint mode (mint), which provides less noisy logs. Here, options are strictly independent: if parser is enabled, mint is ignored.

You can also enable/disable all debugging options at once by setting the debug property to a boolean value.

record

Controls whether the auto-generated assets should be recorded.

typedefaultrequired
booleanfalseno

This option is intended primarily for module maintenance purposes. When working with dl-search, the internal parser processes content using an AST and operates on data virtually, without actually writing to the file system. If you need to inspect or debug the data being handled, you can enable this option to record the generated data into dedicated files for each collection. Data will be stored in the module's ./runtime/data directory.