Creating built-in Milvus knowledge bases
If you don’t have an existing Milvus or Elasticsearch instance to connect to, you can create a knowledge base by simply uploading your documents. These documents will be ingested into the built-in Milvus instance, which will serve as the backend for your knowledge base. The supported documents must follow these requirements:- Each file must have a unique name.
- A single batch can include up to 20 files, with a total size limit of 30 MB.
- The maximum file size for
.docx,.pdf,.pptx, and.xlsxfiles is 25 MB. - The maximum file size for
.csv,.html, and.txtfiles is 5 MB.
Note:
The
embeddings_model_name field is optional. If you don’t provide it, the system uses ibm/slate-125m-english-rtrvr-v2 by default.Creating external knowledge bases
External knowledge bases allow you to connect your existing Milvus or Elasticsearch databases as a knowledge source for your agent. To configure a knowledge base with your external database, use theconversational_search_tool.index_config to define the connection details for your Milvus or Elasticsearch instance.
Use the field_mapping in your index_config to to specify which fields from the search results are used for the title, body and optionally url of the search result
Milvus
When connecting to a Milvus instance: Ensure the providedembedding_model_id is the one used when ingesting the documents in your index.
Additionally, ensure you use the GRPC host and port from your Milvus instance Connections will fail if you use the HTTP host or port.
Optionally, provide the server_cert to use a custom server certificate when connecting to a Milvus instance.
ElasticSearch
For Elasticsearch, you can provide a customquery_body that will be sent as the POST body in the search request. This allows for advanced query customization.
- If provided, the
query_bodymust include the $QUERY token, which will be replaced by the user’s query at runtime. - If no custom
query_bodyis provided, a keyword search will be used.
result_filter can be set to an array of ElasticSearch filters. If using both query_body and result_filter, the query_body must include the $FILTER token, which will be replaced by the result_filter array at runtime.
For more information about ElasticSearch query body and filters customizations, see How to configure the advanced Elasticsearch settings
Custom search
With custom search, you can connect your own search server, enabling out-of-the-box alternatives to the default search solutions. To set up a custom search, configure the URL and optionally the filter and metadata for your search. For example:AstraDB
To connect to AstraDB knowledge base, in your knowledge base file, configure theapi_endpoint, data_type, and embedding_mode for your AstraDB. You can also configure optional fields like port, server_cert, keyspace, collection, table, index_column, embedding_model_id, search_mode, limit, filter, and field_mapping.
Configuring generation options
With the ADK, you can further fine-tune how your agent uses knowledge through theconversational_search_tool configuration in your knowledge base.
You can apply these settings to both built-in Milvus knowledge bases and external knowledge bases. Below are the configurable options available within the conversational_search_tool section:
| Parameter | Description |
|---|---|
prompt_instruction | Set this under generation. If specified, this instruction will be included in the prompt sent to the language model to guide response generation. |
max_docs_passed_to_llm | Set this under generation. If specified, define the maximum number of documents passed to the LLM. This field accepts values from 1 to 20. |
generated_response_length | Set this under generation to one of Concise, Moderate or Verbose. This setting adjusts the prompt to request responses of the specified length. If not set, the default is Moderate. |
idk_message | Set this under generation. Defines the fallback message sent to the user when the knowledge base cannot provide an answer. |
retrieval_confidence_threshold | Set this under confidence_thresholds to one of Off, Lowest, Low, High or Highest. This threshold determines the minimum confidence required that the retrieved documents answer the user’s query. If the confidence is below the threshold, the agent will return a default “I don’t know” response instead of generating a response. The default is “Low”. |
response_confidence_threshold | Set this under confidence_thresholds to one of Off, Lowest, Low, High or Highest. This threshold evaluates the confidence that both the generated response and the retrieved documents answer the user’s query. If the confidence is below the threshold, the agent will return a default “I don’t know” response. The default is Low. |
query_rewrite | If enabled, the user’s query is rewritten using the context of the conversation to support multi-turn interactions. This setting is enabled by default. |
citations_shown | Set this under citations. Use the citations_shown parameter to control how many citations appear during the interaction. Set a specific number to define the maximum citations displayed. Use 0 to hide all citations, or -1 to show every available citation. If not set, the default is -1, which means all available citations will be displayed |
supports_full_document | Enables the Agent to request full documents instead of performing a search when it determines that full documents provide better support for answering the query. This option improves performance for tasks where search is less effective, such as summarization, proofreading, and extracting key points. The default value is False. Note: This setting has no effect when you set generation.enabled to True. |
Note:
In dynamic knowledge bases, only the
max_docs_passed_to_llm and citations_shown parameters apply. All other settings are ignored.Configuring dynamic knowledge bases (Public preview)
By default, classic knowledge base is used as a linear pipeline that retrieves information from whatever content store it is connected to. It takes the user’s input and the conversation context to create a query against that store and then generates an answer which is sent back to the agent. Enabling dynamic mode allows knowledge base to retrieve information as before, but the agent decides how to use it. The agent may generate an answer or use the retrieved information as context to complete tasks. In addition, the agent can be configured to create a query against the content store. To configure a dynamic knowledge base, update your configuration file with the following parameters in theconversational_search_tool schema:
| Parameter | Description |
|---|---|
query_source | Defines the query source. Accepted values:
|
generation | In the generation schema, set the enabled parameter to false to activate dynamic mode. |

