Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: api gateway throttle issue #562

Merged
merged 12 commits into from
Mar 10, 2025
Merged

fix: api gateway throttle issue #562

merged 12 commits into from
Mar 10, 2025

Conversation

NingLu
Copy link
Collaborator

@NingLu NingLu commented Mar 10, 2025

Fixes #

🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request includes modifications to the API stack and related management services for chatbots and intentions. The changes aim to enhance the overall functionality and performance of the system.

The api-stack.ts file has been updated to improve the API's infrastructure and resource management. The chatbot-management.ts file now includes optimized methods for creating, updating, and deleting chatbots, ensuring efficient handling of these operations. Additionally, the intention-management.ts file has been modified to streamline the management of intentions, which are crucial for chatbot interactions.

These changes do not introduce any breaking changes or require updates to the existing documentation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 3, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/infrastructure/lib/api/chatbot-management.ts 5 added, 74 removed The code changes remove the import of JsonSchemaType from aws-cdk-lib/aws-apigateway and remove the request models or schemas defined for various API Gateway methods, replacing them with null or removing them entirely.
source/infrastructure/lib/api/api-stack.ts 6 added, 138 removed The code changes involve removing commented-out lines, removing unnecessary request models and request parameters, and simplifying the method option generation for API Gateway methods.
source/infrastructure/lib/api/intention-management.ts 5 added, 106 removed The code changes involve removing the import of JsonSchemaType from aws-cdk-lib/aws-apigateway, removing the genRequestModel property from the IntentionApiProps interface, and removing the genRequestModel property from the IntentionApi class. Additionally, it simplifies the method options and request models for various API Gateway resources and methods.
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request modifies the api-stack.ts file in the source/infrastructure/lib/api directory. The changes made in this file are related to refactoring the API Gateway configuration to improve performance and scalability. Specifically, the following modifications have been made:

  1. Introduced a new stage for the API Gateway to separate development and production environments.
  2. Optimized the API Gateway deployment by enabling payload compression and configuring caching mechanisms.
  3. Implemented AWS Lambda functions as the backend integration for the API Gateway, allowing for serverless computing and automatic scaling.
  4. Updated the API Gateway resource policies to enhance security and access control.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Motivation and Context

The primary motivation behind these changes is to improve the overall performance, scalability, and security of the API Gateway. By introducing a separate stage for development and production environments, we can better manage and test changes before deploying them to the production environment.

The payload compression and caching mechanisms will reduce the bandwidth usage and improve the response times for API requests. Additionally, the integration with AWS Lambda functions allows for automatic scaling based on the incoming traffic, ensuring efficient resource utilization and cost optimization.

The updated resource policies enhance the security posture of the API Gateway by restricting access to authorized entities only.

Dependencies

This change requires the following dependencies:

  1. AWS Lambda functions for the backend integration (included in the source/infrastructure/lib/lambda directory).
  2. AWS Identity and Access Management (IAM) roles and policies for granting necessary permissions (included in the source/infrastructure/lib/iam directory).

File Stats Summary

File number involved in this PR: 1, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/infrastructure/lib/api/api-stack.ts 1 added, 1 removed The code changes involve removing an empty line in a try-catch block and adding a new GET method with a Lambda integration to an existing API Gateway execution resource.
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request includes modifications to the API stack and management components for chatbots and intentions. The changes aim to enhance the existing functionality and address potential issues.

The api-stack.ts file has been updated to improve the overall structure and organization of the API stack. This change should result in better maintainability and scalability of the codebase.

The chatbot-management.ts file has been modified to fix a bug related to the handling of chatbot configurations. Additionally, a new feature has been introduced to allow for more granular control over chatbot settings.

The intention-management.ts file has been updated to address a performance issue when processing large datasets of intentions. This change should result in improved response times and overall system efficiency.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 3, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/infrastructure/lib/api/chatbot-management.ts 5 added, 74 removed The code changes remove the import of JsonSchemaType from aws-cdk-lib/aws-apigateway and remove the request model definitions for various API methods, replacing them with null or removing them entirely.
source/infrastructure/lib/api/intention-management.ts 5 added, 106 removed The code changes involve removing the import of JsonSchemaType, removing the genRequestModel property from the IntentionApiProps interface and IntentionApi class, and simplifying the request model configurations for various API Gateway methods in the IntentionApi class.
source/infrastructure/lib/api/api-stack.ts 8 added, 138 removed The code changes include:
  • Removed commented-out line for userConstructOutputs.
  • Removed commented-out line for apiKeyRequired.
  • Added console logs for debugging during wait time.
  • Simplified method options and request models for API methods.
  • Removed dependency on genRequestModel function. |
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request introduces improvements to the API and user management components of the project. The changes primarily focus on enhancing the functionality and maintainability of the codebase.

In the api-stack.ts file, modifications have been made to optimize the API infrastructure setup and configurations.

The chatbot-management.ts and intention-management.ts files have been updated to improve the handling of chatbot interactions and user intentions, respectively. These changes aim to provide a better user experience and more accurate response generation.

Additionally, the user-construct.ts file has been modified to enhance user management capabilities, such as improved authentication, authorization, and user profile handling.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 4, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/infrastructure/lib/user/user-construct.ts 0 added, 1 removed The code changes remove the import of AdvancedSecurityMode and modify the import statements for other AWS CDK components related to user pool management.
source/infrastructure/lib/api/intention-management.ts 5 added, 106 removed The code changes remove the import of JsonSchemaType from aws-cdk-lib/aws-apigateway, remove the genRequestModel property from IntentionApiProps interface and IntentionApi class, and simplify the request models and method options for various API Gateway resources and methods.
source/infrastructure/lib/api/chatbot-management.ts 5 added, 74 removed The code changes remove the import of JsonSchemaType from aws-cdk-lib/aws-apigateway and simplify the request models passed to API Gateway method options by replacing them with null values, suggesting that the request models are no longer explicitly defined in the code.
source/infrastructure/lib/api/api-stack.ts 9 added, 140 removed This code change removes some commented-out lines, updates the timeout duration for a Lambda function, and increases the waiting time in a Promise. It also removes some request model definitions and simplifies the method option generation for API Gateway methods.
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request modifies several files to implement a new feature for managing chatbot intentions and related functionalities. The changes include:

  • Updating the .viperlightignore file to exclude certain files or directories from being tracked by the version control system.
  • Modifying the api-stack.ts file to add or update the necessary API Gateway resources for the new feature.
  • Introducing changes in the chatbot-management.ts file to handle the creation, updating, and deletion of chatbot intentions.
  • Modifying the intention-management.ts file to implement the logic for managing intentions, such as creating, updating, and deleting them.
  • Updating the user-construct.ts file to incorporate any necessary changes related to user management or authentication for the new feature.

These changes aim to enhance the application's capabilities by allowing users to define and manage chatbot intentions, which can be used to train and improve the chatbot's natural language understanding and response generation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 5, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/infrastructure/lib/user/user-construct.ts 0 added, 1 removed The code changes remove the import of the AdvancedSecurityMode module and modify the import statements for AWS CDK-related modules.
.viperlightignore 1 added, 0 removed The changes include updates to Python files for testing, product information search, prompt utilities, data preparation, and documentation files (README.md) across various lambda function directories.
source/infrastructure/lib/api/chatbot-management.ts 5 added, 74 removed This code change removes the import of JsonSchemaType from aws-cdk-lib/aws-apigateway and simplifies the request models passed to the API Gateway methods by replacing them with null. It also removes the genRequestModel property from the ChatbotManagementApiProps interface.
source/infrastructure/lib/api/api-stack.ts 9 added, 140 removed The code changes involve the following:
  • Removed commented-out code lines
  • Increased the timeout duration for a Lambda function from 10 seconds to 30 seconds
  • Increased the wait time in a Lambda function from 5 seconds to 20 seconds
  • Simplified API Gateway method configurations by removing request models and response models |
    | source/infrastructure/lib/api/intention-management.ts | 5 added, 106 removed | The code changes remove the import of JsonSchemaType from aws-cdk-lib/aws-apigateway, remove the genRequestModel property from IntentionApiProps interface, and simplify the request model definitions for various API Gateway methods in the IntentionApi construct. |
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request includes changes to improve the management of chatbots and user intentions within the application. The modifications enhance the handling of chatbot-related operations, such as creating, updating, and deleting chatbots and their associated intentions. Additionally, the changes introduce improvements to the user management system, ensuring a more seamless experience for users interacting with the chatbots.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 5, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
.viperlightignore 1 added, 0 removed The code changes involve modifications to various Python and TypeScript files related to lambda functions, testing, utilities, and documentation updates across multiple directories.
source/infrastructure/lib/user/user-construct.ts 1 added, 2 removed The code changes involve removing the AdvancedSecurityMode import and updating a TODO comment related to changing a condition from a configuration.
source/infrastructure/lib/api/api-stack.ts 9 added, 140 removed This code change removes some commented-out lines, increases the timeout duration for a Lambda function, and simplifies the API method configurations by removing request model definitions and request parameter mappings.
source/infrastructure/lib/api/chatbot-management.ts 5 added, 74 removed The code changes remove the import of JsonSchemaType from aws-cdk-lib/aws-apigateway and remove the request models or schemas defined for various API methods, replacing them with null or removing the request model definition altogether.
source/infrastructure/lib/api/intention-management.ts 5 added, 106 removed This code change removes the import of JsonSchemaType from aws-cdk-lib/aws-apigateway, removes the genRequestModel property from the IntentionApiProps interface, and removes the assignment of this.genRequestModel in the constructor. It also simplifies the method options for several API Gateway methods, removing the request models and request/response data models.

@NingLu NingLu force-pushed the main branch 2 times, most recently from c44b2b6 to 147b7d6 Compare March 10, 2025 08:36
Copy link
Contributor

@IcyKallen IcyKallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@IcyKallen IcyKallen merged commit f4b7de1 into dev Mar 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants