346 lines
26 KiB
Markdown
346 lines
26 KiB
Markdown
# AI Applications
|
|
|
|
This module handles the creation of [AI Applications](https://cloud.google.com/generative-ai-app-builder/docs/introduction) data sources, engines and related configurations.
|
|
|
|
<!-- TOC -->
|
|
* [AI Applications module](#ai-applications)
|
|
* [APIs](#apis)
|
|
* [Quota Project](#quota-project)
|
|
* [Examples](#examples)
|
|
* [Chat Engine](#chat-engine)
|
|
* [Search Engine](#search-engine)
|
|
* [Deploy your service into a region](#deploy-your-service-into-a-region)
|
|
* [Reference Existing Data Sources](#reference-existing-data-sources)
|
|
* [Using multiple data stores](#using-multiple-data-stores)
|
|
* [Set data store schemas](#set-data-store-schemas)
|
|
* [Back data stores with websites data](#back-data-stores-with-websites-data)
|
|
* [Variables](#variables)
|
|
* [Outputs](#outputs)
|
|
<!-- TOC -->
|
|
|
|
## APIs
|
|
|
|
This module uses these APIs
|
|
|
|
- `discoveryengine.googleapis.com`
|
|
- `dialogflow.googleapis.com` (if you create a chat engine)
|
|
|
|
## Quota Project
|
|
|
|
To run this module you'll need to set a quota project.
|
|
|
|
```shell
|
|
export GOOGLE_BILLING_PROJECT=your-project-id
|
|
export USER_PROJECT_OVERRIDE=true
|
|
```
|
|
|
|
## Examples
|
|
|
|
### Chat Engine
|
|
|
|
This is a minimal example to create a Chat Engine (Dialogflow CX) agent.
|
|
By default, this uses the location `global` for engines, agents and data stores.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-chat-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = ["data-store-1"]
|
|
chat_engine_config = {
|
|
company_name = "Google"
|
|
default_language_code = "en"
|
|
time_zone = "America/Los_Angeles"
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=3
|
|
```
|
|
|
|
You can change this location for all components.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-chat-app"
|
|
project_id = var.project_id
|
|
location = "eu"
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = ["data-store-1"]
|
|
chat_engine_config = {
|
|
company_name = "Google"
|
|
default_language_code = "en"
|
|
time_zone = "America/Los_Angeles"
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=3
|
|
```
|
|
|
|
You may need to create the Dialogflow CX agent in a specific region.
|
|
While the agent can be created within a specific region, the engine and the data stores still need to be created in multi-regional locations. Refer to [this table](https://docs.cloud.google.com/dialogflow/cx/docs/concept/region#avail) for the compatibility matrix.
|
|
In this case, you need to specify different locations for each component.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-chat-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = ["data-store-1"]
|
|
location = "eu"
|
|
chat_engine_config = {
|
|
company_name = "Google"
|
|
default_language_code = "en"
|
|
time_zone = "America/Los_Angeles"
|
|
agent_config = {
|
|
location = "europe-west1"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=3
|
|
```
|
|
|
|
Instead of creating a new agent, you can reference an existing agent.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-chat-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = ["data-store-1"]
|
|
chat_engine_config = {
|
|
company_name = "Google"
|
|
default_language_code = "en"
|
|
time_zone = "America/Los_Angeles"
|
|
agent_config = {
|
|
security_settings_config = {
|
|
id = "projects/my-project/locations/global/agents/my-agent"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=3
|
|
```
|
|
|
|
If you create and agent, you can also create the agent security settings.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-chat-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = ["data-store-1"]
|
|
chat_engine_config = {
|
|
company_name = "Google"
|
|
default_language_code = "en"
|
|
time_zone = "America/Los_Angeles"
|
|
agent_config = {
|
|
security_settings_config = {
|
|
create = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=4
|
|
```
|
|
|
|
With the `security_settings_config` you can control every security aspect of the agent, including the creation of the DLP inspect and deidentify templates.
|
|
|
|
You can also reference an existing security profile by passing its id.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-chat-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = ["data-store-1"]
|
|
chat_engine_config = {
|
|
company_name = "Google"
|
|
default_language_code = "en"
|
|
time_zone = "America/Los_Angeles"
|
|
agent_config = {
|
|
security_settings_config = {
|
|
create = false
|
|
id = "projects/my-project/locations/global/securitySettings/my-sec-settings"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=3
|
|
```
|
|
|
|
### Search Engine
|
|
|
|
This is a minimal example to create a Search Engine agent.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-search-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_SEARCH"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = ["data-store-1"]
|
|
search_engine_config = {}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=2
|
|
```
|
|
|
|
### Data stores
|
|
|
|
You can create and connect from your engines multiple data stores.
|
|
Data stores can be either created in the module or you can reference existing data stores, by passing their id.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-chat-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
data-store-2 = {
|
|
solution_types = ["SOLUTION_TYPE_CHAT"]
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = [
|
|
"data-store-1",
|
|
"data-store-2",
|
|
"projects/my-project/locations/global/collections/default_collection/dataStores/data-store-3"
|
|
]
|
|
chat_engine_config = {
|
|
company_name = "Google"
|
|
default_language_code = "en"
|
|
time_zone = "America/Los_Angeles"
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=4
|
|
```
|
|
|
|
### Set data store schemas
|
|
|
|
You can configure JSON data store schemas directly in your data store configuration.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-search-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
data-store-1 = {
|
|
json_schema = "{\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"datetime_detection\":true,\"type\":\"object\",\"geolocation_detection\":true}"
|
|
solution_types = ["SOLUTION_TYPE_SEARCH"]
|
|
}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=2
|
|
```
|
|
|
|
### Back data stores with websites data
|
|
|
|
For search engines, you can make data stores point to multiple websites and optionally specify their sitemap.
|
|
|
|
```hcl
|
|
module "ai-applications" {
|
|
source = "./fabric/modules/ai-applications"
|
|
name = "my-search-app"
|
|
project_id = var.project_id
|
|
data_stores_configs = {
|
|
website-search-ds = {
|
|
solution_types = ["SOLUTION_TYPE_SEARCH"]
|
|
sites_search_config = {
|
|
sitemap_uri = "https://cloud.google.com/sitemap.xml"
|
|
target_sites = {
|
|
include-google-docs = {
|
|
provided_uri_pattern = "cloud.google.com/docs/*"
|
|
}
|
|
exclude-one-page = {
|
|
exact_match = true
|
|
provided_uri_pattern = "https://cloud.google.com/ai-applications"
|
|
type = "EXCLUDE"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
engines_configs = {
|
|
data_store_ids = [
|
|
"website-search-ds"
|
|
]
|
|
industry_vertical = "GENERIC"
|
|
search_engine_config = {}
|
|
}
|
|
}
|
|
# tftest modules=1 resources=5
|
|
```
|
|
<!-- BEGIN TFDOC -->
|
|
## Variables
|
|
|
|
| name | description | type | required | default |
|
|
|---|---|:---:|:---:|:---:|
|
|
| [name](variables.tf#L483) | The name of the resources. | <code>string</code> | ✓ | |
|
|
| [project_id](variables.tf#L489) | The ID of the project where the data stores and the agents will be created. | <code>string</code> | ✓ | |
|
|
| [chat_agent_security_configs](variables.tf#L17) | The DLP security configurations for (Dialogflow CX) chat agents. | <code title="object({ audio_export_settings = optional(object({ audio_format = string gcs_bucket_config = object({ id = optional(string) prefix = string location = optional(string) name = optional(string) versioning = optional(bool, true) }) audio_export_pattern = string enable_audio_redaction = optional(bool, false) })) dlp_deidentify_template = optional(object({ description = optional(string, "Terraform managed.") display_name = optional(string) info_type_transformations = optional(object({ transformations = list(object({ info_types = optional(list(object({ name = string version = optional(string) sensitivity_score = optional(string) }))) primitive_transformation = any })) })) parent = optional(string) record_transformations = optional(object({ field_transformations = optional(list(object({ fields = list(object({ name = string })) condition = optional(object({ expressions = optional(object({ logical_operator = optional(string) conditions = list(object({ field = object({ name = string }) operator = string value = optional(object({ integer_value = optional(number) float_value = optional(number) string_value = optional(string) boolean_value = optional(bool) timestamp_value = optional(string) })) })) })) })) primitive_transformation = optional(object({ replace_config = optional(object({ new_value = object({ integer_value = optional(number) float_value = optional(number) string_value = optional(string) boolean_value = optional(bool) timestamp_value = optional(string) time_value = optional(object({ hours = optional(number) minutes = optional(number) seconds = optional(number) nanos = optional(number) })) date_value = optional(object({ year = optional(number) month = optional(number) day = optional(number) })) day_of_week_value = optional(string) }) })) character_mask_config = optional(object({ masking_character = optional(string) number_to_mask = optional(number) reverse_order = optional(bool) characters_to_ignore = optional(object({ characters_to_skip = optional(string) common_characters_to_ignore = optional(string) })) })) crypto_replace_ffx_fpe_config = optional(object({ crypto_key = optional(object({ transient = optional(object({ name = string })) unwrapped = optional(object({ key = string })) kms_wrapped = optional(object({ wrapped_key = string, crypto_key_name = string })) })) context = optional(object({ name = optional(string) })) surrogate_info_type = optional(object({ name = optional(string) version = optional(string) sensitivity_score = optional(string) })) common_alphabet = optional(string) custom_alphabet = optional(string) radix = optional(number) })) crypto_deterministic_config = optional(any) replace_dictionary_config = optional(any) date_shift_config = optional(any) fixed_size_bucketing_config = optional(any) bucketing_config = optional(any) time_part_config = optional(any) redact_config = optional(bool) crypto_hash_config = optional(any) })) info_type_transformations = optional(object({ transformations = list(object({ info_types = optional(list(object({ name = string version = optional(string) sensitivity_score = optional(string) }))) primitive_transformation = optional(any) })) })) }))) record_suppressions = optional(list(object({ condition = optional(object({ expressions = optional(object({ logical_operator = optional(string) conditions = list(object({ field = object({ name = string }) operator = string value = optional(object({ integer_value = optional(number) float_value = optional(number) string_value = optional(string) boolean_value = optional(bool) timestamp_value = optional(string) })) })) })) })) }))) })) template_id = optional(string) })) dlp_inspect_template = optional(object({ content_options = optional(list(string), []) custom_info_types = optional(map(object({ dictionary = optional(object({ cloud_storage_path = optional(string) words_list = optional(list(string)) })) exclusion_type = optional(string) likelihood = optional(string, "VERY_LIKELY") regex = optional(object({ pattern = string group_indexes = optional(list(number)) })) sensitivity_score = optional(string) stored_type_name = optional(string) surrogate_type = optional(string) version = optional(string) }))) description = optional(string, "Terraform managed.") exclude_info_types = optional(bool, false) include_quote = optional(bool, false) info_types = optional(map(object({ sensitivity_score = optional(string, "SENSITIVITY_MODERATE") version = optional(string) })), {}) limits = optional(object({ max_findings_per_item = optional(number, 2000) max_findings_per_request = optional(number, 2000) max_findings_per_info_type = optional(map(object({ max_findings = optional(number, 2000) sensitivity_score = optional(string, "SENSITIVITY_MODERATE") version = optional(string) }))) })) min_likelihood = optional(string, "POSSIBLE") name = optional(string) parent = optional(string) rule_sets = optional(map(object({ info_types = map(object({ version = optional(string) sensitivity_score = optional(string, "SENSITIVITY_MODERATE") })) rules = object({ exclusion_rule = optional(object({ matching_type = string dictionary = optional(object({ cloud_storage_path = optional(string) words_list = optional(list(string)) })) regex = optional(object({ pattern = string group_indexes = optional(list(number)) })) })) hotword_rule = optional(object({ hotword_regex = object({ pattern = string group_indexes = optional(list(number)) }) proximity = object({ window_after = optional(number) window_before = optional(number) }) likelihood_adjustment = optional(object({ fixed_likelihood = optional(string) relative_likelihood = optional(number) })) })) }) })), {}) template_id = optional(string) })) enable_insights_export = optional(bool, false) location = optional(string) purge_data_types = optional(list(string)) redaction_scope = optional(string) redaction_strategy = optional(string) retention_window_days = optional(number) })">object({…})</code> | | <code>{}</code> |
|
|
| [data_stores_configs](variables.tf#L305) | The ai-applications datastore configurations. | <code title="map(object({ advanced_site_search_config = optional(object({ disable_initial_index = optional(bool) disable_automatic_refresh = optional(bool) })) content_config = optional(string, "NO_CONTENT") create_advanced_site_search = optional(bool) display_name = optional(string) document_processing_config = optional(object({ chunking_config = optional(object({ layout_based_chunking_config = optional(object({ chunk_size = optional(number) include_ancestor_headings = optional(bool) })) })) default_parsing_config = optional(object({ digital_parsing_config = optional(bool) layout_parsing_config = optional(bool) ocr_parsing_config = optional(object({ use_native_text = optional(bool) })) })) parsing_config_overrides = optional(map(object({ digital_parsing_config = optional(bool) layout_parsing_config = optional(bool) ocr_parsing_config = optional(object({ use_native_text = optional(bool) })) }))) })) industry_vertical = optional(string, "GENERIC") json_schema = optional(string) location = optional(string) skip_default_schema_creation = optional(bool) solution_types = optional(list(string)) sites_search_config = optional(object({ sitemap_uri = optional(string) target_sites = map(object({ provided_uri_pattern = string exact_match = optional(bool, false) type = optional(string, "INCLUDE") })) })) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
| [engines_configs](variables.tf#L410) | The AI applications engines configurations. | <code title="object({ chat_engine_config = optional(object({ agent_config = optional(object({ avatar_uri = optional(string) default_language_code = optional(string) description = optional(string, "Terraform managed.") id = optional(string) location = optional(string) security_settings_config = optional(object({ create = optional(bool, false) id = optional(string) })) supported_language_codes = optional(list(string)) time_zone = optional(string) }), {}) allow_cross_region = optional(bool, true) business = optional(string) company_name = optional(string) })) collection_id = optional(string, "default_collection") data_store_ids = optional(list(string), []) industry_vertical = optional(string) location = optional(string) search_engine_config = optional(object({ search_add_ons = optional(list(string), []) search_tier = optional(string) })) })">object({…})</code> | | <code>{}</code> |
|
|
| [location](variables.tf#L477) | Location where the data stores and agents will be created. | <code>string</code> | | <code>"global"</code> |
|
|
|
|
## Outputs
|
|
|
|
| name | description | sensitive |
|
|
|---|---|:---:|
|
|
| [chat_engine_ids](outputs.tf#L17) | The ids of the chat engines created. | |
|
|
| [chat_engines](outputs.tf#L25) | The chat engines created. | |
|
|
| [data_store_ids](outputs.tf#L30) | The ids of the data stores created. | |
|
|
| [data_stores](outputs.tf#L38) | The data stores resources created. | |
|
|
| [search_engine_ids](outputs.tf#L43) | The ids of the search engines created. | |
|
|
| [search_engines](outputs.tf#L51) | The search engines created. | |
|
|
<!-- END TFDOC -->
|