Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Create API Vertex AI Agent Builder google.api_core.exceptions.InternalServerError: 500 Internal erro

Hi, I'm trying to automate the process of creating App Builder agents, I'm following this documentation here , I managed to create the datastore uploads the files, however when I try to create the app via script as shown in the documentation I am not having success I receive the following error:

 

 

    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INTERNAL
        details = "Internal error encountered. Please try again. If the issue persists, please contact our support team."
        debug_error_string = "UNKNOWN:Error received from peer ipv4:142.251.129.74:443 {created_time:"2024-07-03T20:13:48.5523557+00:00", grpc_status:13, grpc_message:"Internal error encountered. Please try agair.py", line 66, in create_engine_sample 

   raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.InternalServerError: 500 Internal error encountered. Please try again. If the issue persists, please contact our support team.

 

 

I can't understand what I'm doing wrong or if something is missing, the error isn't clear about the problem I'm facing, below is an example of the code I'm using:

 

 

 

from typing import List

from google.api_core.client_options import ClientOptions
from google.cloud import discoveryengine_v1 as discoveryengine
from google.oauth2 import service_account

# Caminho para a chave JSON da conta de serviço
GOOGLE_APPLICATION_CREDENTIALS = './chave.json'

project_id = "projetoxpto"
location = "global" # Values: "global"
engine_id = "agente_rodrigo_martins"
data_store_ids = ["base_1719884343347"]  # Certifique-se de que este data store existe


def create_engine_sample(
    project_id: str, location: str, engine_id: str, data_store_ids: List[str]
) -> str:
    #  For more information, refer to:
    # https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store
    client_options = (
        ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com")
        if location != "global"
        else None
    )

    # Create a client
    client = discoveryengine.EngineServiceClient(client_options=client_options)

    # The full resource name of the collection
    # e.g. projects/{project}/locations/{location}/collections/default_collection
    parent = client.collection_path(
        project=project_id,
        location=location,
        collection="default_collection",
    )

    print(f'Chegou no discoveryengine...\n')
    engine = discoveryengine.Engine(
        display_name="app criado via script",
        # Options: GENERIC, MEDIA, HEALTHCARE_FHIR
        industry_vertical=discoveryengine.IndustryVertical.GENERIC,
        # Options: SOLUTION_TYPE_RECOMMENDATION, SOLUTION_TYPE_SEARCH, SOLUTION_TYPE_CHAT, SOLUTION_TYPE_GENERATIVE_CHAT
        solution_type=discoveryengine.SolutionType.SOLUTION_TYPE_CHAT,
        # For search apps only
        search_engine_config=discoveryengine.Engine.SearchEngineConfig(
            # Options: SEARCH_TIER_STANDARD, SEARCH_TIER_ENTERPRISE
            search_tier=discoveryengine.SearchTier.SEARCH_TIER_STANDARD,
            # Options: SEARCH_ADD_ON_LLM, SEARCH_ADD_ON_UNSPECIFIED
            search_add_ons=[discoveryengine.SearchAddOn.SEARCH_ADD_ON_UNSPECIFIED],
        ),
        # For generic recommendation apps only
        # similar_documents_config=discoveryengine.Engine.SimilarDocumentsEngineConfig,
        data_store_ids=data_store_ids,
    )
    # Make the request
    print(f'Chegou no CreateEngineRequest...\n')
    request = discoveryengine.CreateEngineRequest(
        parent=parent,
        engine=engine,
        engine_id=engine_id,
    )

    # Make the request
    print(f'Chegou no create_engine...\n')
    operation = client.create_engine(request=request,timeout=3600)

    print(f"Waiting for operation to complete: {operation.operation.name}")
    response = operation.result()

    # Once the operation is complete,
    # get information from operation metadata
    metadata = discoveryengine.CreateEngineMetadata(operation.metadata)

    # Handle the response
    print(response)
    print(metadata)

    return operation.operation.name


create_engine_sample(project_id,location,engine_id, data_store_ids)

 

 

 

1 2 800
2 REPLIES 2

Hi @rodrigomartins8,

Welcome to Google Cloud Community!

Discovery Engine API does not directly support creating engines (app) with a SOLUTION_TYPE_CHAT as its type of solution. With this, please try changing this line of code from 

solution_type=discoveryengine.SolutionType.SOLUTION_TYPE_CHAT

  to

solution_type=discoveryengine.SolutionType.SOLUTION_TYPE_SEARCH

You can also find this line of code in our documentation.

I hope this helps.

Hi Cassandrame, this worked for me, however it creates the agent but when I click it opens the dialogflow on a blank screen and is it possible to create it and leave it linked in the dialogflow?

 

 engine = discoveryengine.Engine(
        display_name="Agente Script Python",
        # Options: GENERIC, MEDIA, HEALTHCARE_FHIR
        industry_vertical=discoveryengine.IndustryVertical.GENERIC,
        # Options: SOLUTION_TYPE_RECOMMENDATION, SOLUTION_TYPE_SEARCH, SOLUTION_TYPE_CHAT, SOLUTION_TYPE_GENERATIVE_CHAT
        solution_type=discoveryengine.SolutionType.SOLUTION_TYPE_GENERATIVE_CHAT,
        # For search apps only
        search_engine_config=discoveryengine.Engine.SearchEngineConfig(
            # Options: SEARCH_TIER_STANDARD, SEARCH_TIER_ENTERPRISE
            search_tier=discoveryengine.SearchTier.SEARCH_TIER_STANDARD,
            # Options: SEARCH_ADD_ON_LLM, SEARCH_ADD_ON_UNSPECIFIED
            search_add_ons=[discoveryengine.SearchAddOn.SEARCH_ADD_ON_LLM],
        ),
        # For generic recommendation apps only
        # similar_documents_config=discoveryengine.Engine.SimilarDocumentsEngineConfig,
        data_store_ids=data_store_ids,
    )

 

 Another question, in the console I follow the following steps to create an app and automatically create the dialogflow agent, select the type as chat, enter the company name, time zone, default language (pt-br), agent name, local type Can I pass the time zone and language via code?