Patch images rendering in Redshift, AWS, Snowflake & SQL cookbook (#1378)

This commit is contained in:
pap-openai 2024-08-16 18:19:28 +01:00 committed by GitHub
parent 7a1fcf17fb
commit 874959b626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 24 deletions

View File

@ -226,7 +226,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"! aws redshift-serverless get-workgroup --workgroup-name default-workgroup --query 'workgroup.{address: endpoint.address, port: endpoint.port, SecurityGroupIds: securityGroupIds, SubnetIds: subnetIds}'" "aws redshift-serverless get-workgroup --workgroup-name default-workgroup --query 'workgroup.{address: endpoint.address, port: endpoint.port, SecurityGroupIds: securityGroupIds, SubnetIds: subnetIds}'"
] ]
}, },
{ {
@ -275,7 +275,6 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"```yaml\n",
"AWSTemplateFormatVersion: '2010-09-09'\n", "AWSTemplateFormatVersion: '2010-09-09'\n",
"Transform: AWS::Serverless-2016-10-31\n", "Transform: AWS::Serverless-2016-10-31\n",
"Description: >\n", "Description: >\n",
@ -402,15 +401,14 @@
" Value: !GetAtt RedshiftMiddlewareFunctionRole.Arn\n", " Value: !GetAtt RedshiftMiddlewareFunctionRole.Arn\n",
" CognitoUserPoolArn:\n", " CognitoUserPoolArn:\n",
" Description: \"ARN of the Cognito User Pool\"\n", " Description: \"ARN of the Cognito User Pool\"\n",
" Value: !GetAtt MyCognitoUserPool.Arn\n", " Value: !GetAtt MyCognitoUserPool.Arn\n"
"```"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Retrieve the URL information, you can then try a cURL request, which should return data in a file format:" "Retrieve the URL information from the previous command output, you can then run a cURL request, which should return data in a file format:"
] ]
}, },
{ {
@ -419,7 +417,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"! curl -X POST https://10o5fvtsr1.execute-api.us-east-1.amazonaws.com/Prod/sql_statement/ \\\n", "curl -X POST https://<your_url>/Prod/sql_statement/ \\\n",
"-H \"Content-Type: application/json\" \\\n", "-H \"Content-Type: application/json\" \\\n",
"-d '{ \"sql_statement\": \"SELECT * FROM customers LIMIT 10\", \"workgroup_name\": \"default-workgroup\", \"database_name\": \"pap-db\" }'" "-d '{ \"sql_statement\": \"SELECT * FROM customers LIMIT 10\", \"workgroup_name\": \"default-workgroup\", \"database_name\": \"pap-db\" }'"
] ]
@ -569,7 +567,7 @@
"\n", "\n",
"You now have deployed a GPT that uses a middleware in AWS, in an authenticated manner, that's able to connect to Redsfhit. Users with access (that are in Cognito) can now query your databases to perform data analysis task:\n", "You now have deployed a GPT that uses a middleware in AWS, in an authenticated manner, that's able to connect to Redsfhit. Users with access (that are in Cognito) can now query your databases to perform data analysis task:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/redshift_gpt.png\">\n" "![../../../images/chatgpt/redshift_gpt.png](../../../images/chatgpt/redshift_gpt.png)\n"
] ]
} }
], ],

View File

@ -304,7 +304,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"\n", "\n",
"<img src=\"../../../images/chatgpt/snowflake_direct_oauth.png\">" "![../../../images/chatgpt/snowflake_direct_oauth.png](../../../images/chatgpt/snowflake_direct_oauth.png)"
] ]
}, },
{ {

View File

@ -68,7 +68,7 @@
"\n", "\n",
"This guide will focus on option 1. For those interested in option 2, consider implementing a service like [PostgREST](https://github.com/PostgREST/postgrest) or [Hasura](https://hasura.io/) to streamline the process.\n", "This guide will focus on option 1. For those interested in option 2, consider implementing a service like [PostgREST](https://github.com/PostgREST/postgrest) or [Hasura](https://hasura.io/) to streamline the process.\n",
"\n", "\n",
"<img src=\"../../../images/gptactions_sql_database_middleware.png\" alt=\"An application architecture diagram depicting the interaction between the user, GPT, middleware, and database\" width=\"75%\" />\n", "![An application architecture diagram depicting the interaction between the user, GPT, middleware, and database](../../../images/gptactions_sql_database_middleware.png)",
"\n", "\n",
"_Application architecture diagram_\n", "_Application architecture diagram_\n",
"\n", "\n",

View File

@ -203,7 +203,7 @@
"\n", "\n",
"Once you have this deployed, you can go check out the application on AWS Lambda:\n", "Once you have this deployed, you can go check out the application on AWS Lambda:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_1.png\">\n", "![../../../images/chatgpt/aws_lambda_1.png](../../../images/chatgpt/aws_lambda_1.png)\n",
"\n", "\n",
"You can confirm that the function is not reachable unless authenticated by running a curl command without any authentication:\n", "You can confirm that the function is not reachable unless authenticated by running a curl command without any authentication:\n",
"\n", "\n",
@ -239,35 +239,35 @@
"\n", "\n",
"Let's now make sure we create a webpage/domain on which we can log-in. Go to AWS Cognito, select the newly created user pool & go to App Integration tab:\n", "Let's now make sure we create a webpage/domain on which we can log-in. Go to AWS Cognito, select the newly created user pool & go to App Integration tab:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_3.png\">\n", "![../../../images/chatgpt/aws_lambda_3.png](../../../images/chatgpt/aws_lambda_3.png)\n",
"\n", "\n",
"Create a Cognito Domain by clicking on \"Domains\" then \"Create Cognito Domain\"\n", "Create a Cognito Domain by clicking on \"Domains\" then \"Create Cognito Domain\"\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_8.png\">\n", "![../../../images/chatgpt/aws_lambda_8.png](../../../images/chatgpt/aws_lambda_8.png)\n",
"\n", "\n",
"Scroll down to `App client list` on the App Integration page of your User Pool:\n", "Scroll down to `App client list` on the App Integration page of your User Pool:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_9.png\">\n", "![../../../images/chatgpt/aws_lambda_9.png](../../../images/chatgpt/aws_lambda_9.png)\n",
"\n", "\n",
"Select your app client and edit the Hosted UI:\n", "Select your app client and edit the Hosted UI:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_10.png\">\n", "![../../../images/chatgpt/aws_lambda_10.png](../../../images/chatgpt/aws_lambda_10.png)\n",
"\n", "\n",
"And add a callback URL, Authorization Scheme and OAuth scope:\n", "And add a callback URL, Authorization Scheme and OAuth scope:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_11.png\">\n", "![../../../images/chatgpt/aws_lambda_11.png](../../../images/chatgpt/aws_lambda_11.png)\n",
"\n", "\n",
"_Note that you'll come back to this step when ChatGPT will generate a callback URL for the authentication of your action. The postman URL, should be used only for development purpose._\n", "_Note that you'll come back to this step when ChatGPT will generate a callback URL for the authentication of your action. The postman URL, should be used only for development purpose._\n",
"\n", "\n",
"You can try this connection in Postman, under Authorization for your `<api_url>`, copy/paste the value from AWS for the client_id, client_secret and the URL you set up for the auth domain, make sure to add `openid` in the scope to get a valid access_token:\n", "You can try this connection in Postman, under Authorization for your `<api_url>`, copy/paste the value from AWS for the client_id, client_secret and the URL you set up for the auth domain, make sure to add `openid` in the scope to get a valid access_token:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_12.png\">\n", "![../../../images/chatgpt/aws_lambda_12.png](../../../images/chatgpt/aws_lambda_12.png)\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_13.png\">\n", "![../../../images/chatgpt/aws_lambda_13.png](../../../images/chatgpt/aws_lambda_13.png)\n",
"\n", "\n",
"If you're now doing the request on Postman, using the access_token you just retrieve, you'll get a success JSON returned:\n", "If you're now doing the request on Postman, using the access_token you just retrieve, you'll get a success JSON returned:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_14.png\">" "![../../../images/chatgpt/aws_lambda_14.png](../../../images/chatgpt/aws_lambda_14.png)"
] ]
}, },
{ {
@ -320,13 +320,13 @@
"Click on Authentication > OAuth.\n", "Click on Authentication > OAuth.\n",
"We'll now need to fetch AWS Cognito's variables. Let's go on your User Pool > User Pool App Client. From there you can retrieve your client ID and client Secret.\n", "We'll now need to fetch AWS Cognito's variables. Let's go on your User Pool > User Pool App Client. From there you can retrieve your client ID and client Secret.\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_15.png\">\n", "![../../../images/chatgpt/aws_lambda_15.png](../../../images/chatgpt/aws_lambda_15.png)\n",
"\n", "\n",
"Copy paste those values in ChatGPT. Now let's add the Token URLs.\n", "Copy paste those values in ChatGPT. Now let's add the Token URLs.\n",
"\n", "\n",
"From your User Pool you'll find the URL you've previously created for the hosted domain.\n", "From your User Pool you'll find the URL you've previously created for the hosted domain.\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_16.png\">\n", "![../../../images/chatgpt/aws_lambda_16.png](../../../images/chatgpt/aws_lambda_16.png)\n",
"\n", "\n",
"We'll take this URL and append [AWS routes for OAuth](https://docs.aws.amazon.com/cognito/latest/developerguide/federation-endpoints.html).\n", "We'll take this URL and append [AWS routes for OAuth](https://docs.aws.amazon.com/cognito/latest/developerguide/federation-endpoints.html).\n",
"\n", "\n",
@ -351,11 +351,11 @@
"source": [ "source": [
"Now go back on your GPT (moving out of the action subview), and you'll see a callback URL provided by ChatGPT for the Authentication:\n", "Now go back on your GPT (moving out of the action subview), and you'll see a callback URL provided by ChatGPT for the Authentication:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_17.png\">\n", "![../../../images/chatgpt/aws_lambda_17.png](../../../images/chatgpt/aws_lambda_17.png)\n",
"\n", "\n",
"Get this URL and edit the hosted UI of your User Pool App client & save the changes:\n", "Get this URL and edit the hosted UI of your User Pool App client & save the changes:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_18.png\">" "![../../../images/chatgpt/aws_lambda_18.png](../../../images/chatgpt/aws_lambda_18.png)"
] ]
}, },
{ {
@ -371,13 +371,13 @@
"source": [ "source": [
"You can now test this action again:\n", "You can now test this action again:\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_19.png\">\n", "![../../../images/chatgpt/aws_lambda_19.png](../../../images/chatgpt/aws_lambda_19.png)\n",
"\n", "\n",
"You will be redirected to AWS Cognito page, which you can log-in in using the credentials previously set-up.\n", "You will be redirected to AWS Cognito page, which you can log-in in using the credentials previously set-up.\n",
"\n", "\n",
"If you now ask the GPT to run the same action, it will answer correctly as you're now authenticated and able to run this function!\n", "If you now ask the GPT to run the same action, it will answer correctly as you're now authenticated and able to run this function!\n",
"\n", "\n",
"<img src=\"../../../images/chatgpt/aws_lambda_20.png\">" "![../../../images/chatgpt/aws_lambda_20.png](../../../images/chatgpt/aws_lambda_20.png)"
] ]
}, },
{ {