DEV Community

Rashmitha v
Rashmitha v

Posted on

Build a ChatGPT on AWS

Introduction
ChatGPT is based on OpenAI's GPT (Generative Pre-trained Transformer) architecture. It leverages deep learning to understand and generate human-like text based on the input it receives. Building a ChatGPT involves setting up a similar environment where your model can learn from data and interact with users in a conversational manner.

Service used:

API Gateway
lambda function
Bedrock
IAM Role

  1. Create a bedrock:

It provides a foundation models:

  • base models
  • custom models
  • imported models the request access should be provided before using.

click on base model

  • no access to any model

Step 1:
To providing access click on 'enable all models'

Step 2:
uncheck the Anthropic models.

2.create an IAM role

  • click roles
  • choose lambda function as service.
  • add permissions (bedrockFullAccess)(cloudwatchlogFullAccess)

  • provide role name.

3.create a lambda function:

  • create a function name.
  • set the run time
  • choose existing role. function is created and click configuration to increase the timeout.

this is our request body the AI model
Image description

create a lambda code and paste it on the lambda_function.

4.create a API Gateway:
-create a API gateway to create a endpoints

  • click on restAPI
  • provide a name.

click regional and create a resource.

  • create a method.
  • choose method type "POST"
  • check the lambda proxy
  • choose the lambda function.
  • click create the method.

Deploy the APT

  • deploy the API to a new stage the API endpoint is create!

this API endpoint will call the lambda function to generate the response.

  • copy the lambda endpoint and paste it in the POSTMAN tool.
  • select the method as post.

Top comments (0)