Skip to content

Commit

Permalink
Merge branch 'main' into feat/jsii_53
Browse files Browse the repository at this point in the history
  • Loading branch information
hvital authored Jan 29, 2024
2 parents e458f67 + 36401ac commit ce5e508
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/patterns/gen-ai/aws-langchain-common-layer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const lambdaDepsLayer = new LangchainCommonDepsLayer(this, 'lambdagenaidepslayer
});

const lambdaCommonLayer = new LangchainCommonLayer(this, 'lambdagenaicommonlayer', {
runtime: lambdaRuntime,
architecture: lambdaArchitecture,
compatibleRuntimes: [lambdaRuntime],
compatibleArchitectures: [lambdaArchitecture],
});

//Then pass the layers above to your lambda function constructor
Expand Down
2 changes: 1 addition & 1 deletion src/patterns/gen-ai/aws-langchain-common-layer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class LangchainCommonLayer extends Construct {
super(scope, id);

const layer = new lambda.LayerVersion(this, 'Model Adapter Layer', {
code: lambda.Code.fromAsset(path.join(__dirname, '../../../../layers/model-adapter-layer')),
code: lambda.Code.fromAsset(path.join(__dirname, '../../../../layers/langchain-common-layer')),
description: 'Utilities to instantiate a llm client adapter. Adapters include bedrock, sagemaker, and openai',
...props,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
import * as cdk from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import {
LangchainCommonLayer,
LangchainCommonDepsLayer,
} from '../../../../src/patterns/gen-ai/aws-langchain-common-layer';

describe('LangchainCommonLayer construct', () => {

let LangchainCommonLayerTestTemplate: Template;
let LangchainCommonLayerTestConstruct: LangchainCommonLayer;

afterAll(() => {
console.log('Test completed');
console.log(LangchainCommonLayerTestTemplate.toJSON());
});

beforeAll(() => {

const LangchainCommonLayerTestStack = new cdk.Stack(undefined, undefined, {
env: { account: cdk.Aws.ACCOUNT_ID, region: 'us-east-1' },
});

// Lambda layer
const lambdaArchitecture = lambda.Architecture.ARM_64;
const lambdaRuntime = lambda.Runtime.PYTHON_3_10;

LangchainCommonLayerTestConstruct = new LangchainCommonLayer(LangchainCommonLayerTestStack, 'lambdagenaicommonlayer', {
compatibleRuntimes: [lambdaRuntime],
compatibleArchitectures: [lambdaArchitecture],
});
LangchainCommonLayerTestTemplate = Template.fromStack(LangchainCommonLayerTestStack);

});

test('LayerVersion count', () => {
LangchainCommonLayerTestTemplate.resourceCountIs('AWS::Lambda::LayerVersion', 1);
expect(LangchainCommonLayerTestConstruct.layer).not.toBeNull;
});
});

describe('LangchainCommonDepsLayer construct', () => {

let LangchainCommonLayerDepsTestTemplate: Template;
let LangchainCommonLayerDepsTestConstruct: LangchainCommonDepsLayer;

afterAll(() => {
console.log('Test completed');
console.log(LangchainCommonLayerDepsTestTemplate.toJSON());
});

beforeAll(() => {

const LangchainCommonLayerDepsTestStack = new cdk.Stack(undefined, undefined, {
env: { account: cdk.Aws.ACCOUNT_ID, region: 'us-east-1' },
});

// Lambda layer
const lambdaArchitecture = lambda.Architecture.ARM_64;
const lambdaRuntime = lambda.Runtime.PYTHON_3_10;

LangchainCommonLayerDepsTestConstruct = new LangchainCommonDepsLayer(LangchainCommonLayerDepsTestStack, 'lambdagenaidepslayer', {
runtime: lambdaRuntime,
architecture: lambdaArchitecture,
autoUpgrade: true,
});
LangchainCommonLayerDepsTestTemplate = Template.fromStack(LangchainCommonLayerDepsTestStack);

});

test('LayerVersionDeps count', () => {
LangchainCommonLayerDepsTestTemplate.resourceCountIs('AWS::Lambda::LayerVersion', 1);
expect(LangchainCommonLayerDepsTestConstruct.layer).not.toBeNull;
});
});

0 comments on commit ce5e508

Please sign in to comment.