Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/ai-constructs

Package Overview
Dependencies
Maintainers
9
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/ai-constructs

This package vends L3 CDK Constructs that deploy resources which power AI routes in Amplify apps.

  • 0.0.0-test-20240926024033
  • npm
  • Socket score

Version published
Weekly downloads
6.5K
decreased by-0.12%
Maintainers
9
Weekly downloads
 
Created
Source

Description

This package vends L3 CDK Constructs that deploy resources which power AI routes in Amplify apps.

Conversation Handler Function

Conversation Handler Function L3 CDK Construct provisions resources required to integrate conversation routes (i.e. defined with a.ai.conversation() from @aws-amplify/data-schema) with AI models provided by AWS Bedrock service.

Resources deployed by this construct include:

  1. AWS Lambda function that:
    1. Accepts conversation turn events coming from upstream AWS AppSync instance that is hosting conversation routes in a form of GraphQL schemas.
    2. Interacts with AWS Bedrock to elicit a response to current conversation turn.
    3. Sends back the response to the same AWS AppSync instance in a form of GraphQL mutation.
  2. AWS CloudWatch Log Group associated with AWS Lambda function with addition of appropriate data protection policy.
  3. AWS IAM Policy that grants access to selected AWS Bedrock models.

This construct is used implicitly by @aws-amplify/data-construct when conversational routes don't specify handler reference. In this case default implementation provided by Amplify is deployed.

Alternatively, a custom lambda implementation can be provided by explicitly including this construct in backend definition and referencing it in schema.

Examples

Default implementation

import { App, Stack } from 'aws-cdk-lib';
import { ConversationHandlerFunction } from '@aws-amplify/ai-constructs/conversation';

const app = new App();
const stack = new Stack(app, 'ConversationHandlerStack');

new ConversationHandlerFunction(stack, {
  models: [
    {
      modelId: 'anthropic.claude-3-haiku-20240307-v1:0',
      region: 'us-east-1',
    },
  ],
});

Custom implementation

import { App, Stack } from 'aws-cdk-lib';
import { ConversationHandlerFunction } from '@aws-amplify/ai-constructs/conversation';
import path from 'path';

const app = new App();
const stack = new Stack(app, 'ConversationHandlerStack');

new ConversationHandlerFunction(stack, {
  entry: path.resolve('./custom_handler.ts'),
  models: [
    {
      modelId: 'anthropic.claude-3-haiku-20240307-v1:0',
      region: 'us-east-1',
    },
  ],
});

FAQs

Package last updated on 26 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc