diff --git a/docs/tutorials/aws/AIConnectorHelper.ipynb b/docs/tutorials/aws/AIConnectorHelper.ipynb index 5ff0bad4aa..5b9697cdb8 100644 --- a/docs/tutorials/aws/AIConnectorHelper.ipynb +++ b/docs/tutorials/aws/AIConnectorHelper.ipynb @@ -586,20 +586,21 @@ "connector_role_name = 'my_test_bedrock_connector_role'\n", "create_connector_role_name = 'my_test_create_bedrock_connector_role'\n", "\n", + "bedrock_region = 'us-west-2' # bedrock region could be different with OpenSearch domain region\n", "create_connector_input = {\n", " \"name\": \"Amazon Bedrock Connector: titan embedding v1\",\n", " \"description\": \"The connector to bedrock Titan embedding model\",\n", " \"version\": 1,\n", " \"protocol\": \"aws_sigv4\",\n", " \"parameters\": {\n", - " \"region\": region,\n", + " \"region\": bedrock_region,\n", " \"service_name\": \"bedrock\"\n", " },\n", " \"actions\": [\n", " {\n", " \"action_type\": \"predict\",\n", " \"method\": \"POST\",\n", - " \"url\": f\"https://bedrock-runtime.{region}.amazonaws.com/model/amazon.titan-embed-text-v1/invoke\",\n", + " \"url\": f\"https://bedrock-runtime.{bedrock_region}.amazonaws.com/model/amazon.titan-embed-text-v1/invoke\",\n", " \"headers\": {\n", " \"content-type\": \"application/json\",\n", " \"x-amz-content-sha256\": \"required\"\n", @@ -722,13 +723,14 @@ "create_connector_role_name = 'my_test_create_sagemaker_connector_role'\n", "sagemaker_inference_endpoint_url = '...' # set your SageMaker inference endpoint URL\n", "\n", + "sagemaker_endpoint_region = 'us-west-2' # SageMaker endpoint region could be different with OpenSearch domain region\n", "create_connector_input = {\n", " \"name\": \"Sagemaker embedding model connector\",\n", " \"description\": \"Connector for my Sagemaker embedding model\",\n", " \"version\": \"1.0\",\n", " \"protocol\": \"aws_sigv4\",\n", " \"parameters\": {\n", - " \"region\": region,\n", + " \"region\": sagemaker_endpoint_region,\n", " \"service_name\": \"sagemaker\"\n", " },\n", " \"actions\": [\n", @@ -839,7 +841,9 @@ ], "source": [ "secret_name = 'my_test_cohere_secret'\n", - "secret_value = {\"my_cohere_key\": \"...\"} # set your Cohere API key\n", + "secret_key = 'my_cohere_key'\n", + "secret_value = '...' # set your Cohere API key\n", + "secret_value = { secret_key: secret_value }\n", "# You can use existing role if the role permission and trust relationship are correct. \n", "# To quick start, you can specify new role names. AIConnectorHelper will create role automatically.\n", "connector_role_name = 'my_test_cohere_connector_role'\n", @@ -861,7 +865,7 @@ " \"method\": \"POST\",\n", " \"url\": \"https://api.cohere.ai/v1/embed\",\n", " \"headers\": {\n", - " \"Authorization\": \"Bearer ${credential.secretArn.my_cohere_key}\",\n", + " \"Authorization\": f\"Bearer ${{credential.secretArn.{secret_key}}}\",\n", " \"Request-Source\": \"unspecified:opensearch\"\n", " },\n", " \"request_body\": \"{ \\\"texts\\\": ${parameters.texts}, \\\"truncate\\\": \\\"${parameters.truncate}\\\", \\\"model\\\": \\\"${parameters.model}\\\", \\\"input_type\\\": \\\"${parameters.input_type}\\\" }\",\n", @@ -965,7 +969,9 @@ ], "source": [ "secret_name = 'my_test_openai_secret'\n", - "secret_value = {\"my_openai_key\": \"...\"} # set your OpenAI API key\n", + "secret_key = 'my_openai_key'\n", + "secret_value = '...' # set your OpenAI API key\n", + "secret_value = { secret_key : secret_value }\n", "# You can use existing role if the role permission and trust relationship are correct. \n", "# To quick start, you can specify new role names. AIConnectorHelper will create role automatically.\n", "connector_role_name = 'my_test_openai_connector_role'\n", @@ -985,7 +991,7 @@ " \"method\": \"POST\",\n", " \"url\": \"https://api.openai.com/v1/embeddings\",\n", " \"headers\": {\n", - " \"Authorization\": \"Bearer ${credential.secretArn.my_openai_key}\"\n", + " \"Authorization\": f\"Bearer ${{credential.secretArn.{secret_key}}}\",\n", " },\n", " \"request_body\": \"{ \\\"input\\\": ${parameters.input}, \\\"model\\\": \\\"${parameters.model}\\\" }\",\n", " \"pre_process_function\": \"connector.pre_process.openai.embedding\",\n",