Skip to content

Commit 1d61a39

Browse files
author
Dinesh Sajwan
committed
feat(construct): fixed defects abd added schema schanges warning
1 parent 10247ba commit 1d61a39

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

lambda/aws-qa-appsync-opensearch/question_answering/src/qa_agent/chain.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def run_question_answering(arguments):
4848
image_url = arguments['presignedurl']
4949

5050
#set deafult modality to text
51-
qa_model= arguments['qa_model']['modality']
51+
qa_model= arguments['qa_model']
5252
modality=qa_model.get('modality','Text')
5353

5454
# Visual QA

lambda/aws-qa-appsync-opensearch/question_answering/src/qa_agent/image_qa.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
logger = Logger(service="QUESTION_ANSWERING")
3030
tracer = Tracer(service="QUESTION_ANSWERING")
3131
metrics = Metrics(namespace="question_answering", service="QUESTION_ANSWERING")
32+
3233
bucket_name = os.environ['INPUT_BUCKET']
3334

3435
def run_qa_agent_on_image_no_memory(input_params):

lambda/aws-rag-appsync-stepfn-opensearch/s3_file_transformer/src/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ typing-extensions
55
boto3>=1.34.29
66
requests
77
langchain==0.1.4
8-
pypdf2==4.0.2
8+
pypdf2==3.0.1
99
Pillow==10.2.0
1010
langchain-community==0.0.16

src/patterns/gen-ai/aws-qa-appsync-opensearch/index.ts

+26-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* and limitations under the License.
1212
*/
1313
import * as path from 'path';
14-
import { Duration, Aws } from 'aws-cdk-lib';
14+
import { Duration, Aws, Annotations } from 'aws-cdk-lib';
1515
import * as appsync from 'aws-cdk-lib/aws-appsync';
1616
import * as cognito from 'aws-cdk-lib/aws-cognito';
1717
import * as ec2 from 'aws-cdk-lib/aws-ec2';
@@ -158,6 +158,21 @@ export interface QaAppsyncOpensearchProps {
158158
* @summary The QaAppsyncOpensearch class.
159159
*/
160160
export class QaAppsyncOpensearch extends Construct {
161+
/**
162+
* Construct warning
163+
*/
164+
public static readonly CONSTRUCT_SCHEMA_UPDATE_WARNING=`
165+
Attention QaAppsyncOpensearch users, an update has been made to
166+
the GraphQL schema.To ensure continued functionality, please review
167+
and update your GraphQL mutations and subscriptions to align with
168+
the new schema.This schema update enables enhanced capabilities
169+
and optimizations,so adopting the changes is recommended.
170+
Please refer to the construct documentation for details
171+
on the schema changes and examples of updated GraphQL statements.
172+
Reach out to the support team if you need assistance
173+
updating your integration codebase.
174+
`;
175+
161176
/**
162177
* Returns the instance of ec2.IVpc used by the construct
163178
*/
@@ -189,6 +204,7 @@ export class QaAppsyncOpensearch extends Construct {
189204
*/
190205
public readonly qaLambdaFunction: lambda.DockerImageFunction;
191206

207+
192208
/**
193209
* @summary Constructs a new instance of the RagAppsyncStepfnOpensearch class.
194210
* @param {cdk.App} scope - represents the scope for all the resources.
@@ -200,6 +216,7 @@ export class QaAppsyncOpensearch extends Construct {
200216
constructor(scope: Construct, id: string, props: QaAppsyncOpensearchProps) {
201217
super(scope, id);
202218

219+
Annotations.of(scope).addWarning(QaAppsyncOpensearch.CONSTRUCT_SCHEMA_UPDATE_WARNING);
203220
// stage
204221
let stage = '-dev';
205222
if (props?.stage) {
@@ -425,7 +442,7 @@ export class QaAppsyncOpensearch extends Construct {
425442
},
426443
);
427444

428-
// Minimum permissions for a Lambda function to execute while accessing a resource within a VPC
445+
// Minimum permissions for a Lambda functienvon to execute while accessing a resource within a VPC
429446
question_answering_function_role.addToPolicy(
430447
new iam.PolicyStatement({
431448
effect: iam.Effect.ALLOW,
@@ -449,6 +466,13 @@ export class QaAppsyncOpensearch extends Construct {
449466
resources: ['*'],
450467
}),
451468
);
469+
question_answering_function_role.addToPolicy(
470+
new iam.PolicyStatement({
471+
effect: iam.Effect.ALLOW,
472+
actions: ['sagemaker:InvokeEndpoint'],
473+
resources: ['*'],
474+
}),
475+
);
452476

453477
// The lambda will access the opensearch credentials
454478
if (props.openSearchSecret) {

src/patterns/gen-ai/aws-rag-appsync-stepfn-opensearch/index.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* and limitations under the License.
1212
*/
1313
import * as path from 'path';
14-
import { Duration, Aws, Stack } from 'aws-cdk-lib';
14+
import { Duration, Aws, Stack, Annotations } from 'aws-cdk-lib';
1515
import * as appsync from 'aws-cdk-lib/aws-appsync';
1616
import * as cognito from 'aws-cdk-lib/aws-cognito';
1717
import * as ec2 from 'aws-cdk-lib/aws-ec2';
@@ -177,6 +177,22 @@ export interface RagAppsyncStepfnOpensearchProps {
177177
* @summary The RagAppsyncStepfnOpensearch class.
178178
*/
179179
export class RagAppsyncStepfnOpensearch extends Construct {
180+
181+
/**
182+
* Construct warning
183+
*/
184+
public static readonly CONSTRUCT_SCHEMA_UPDATE_WARNING=`
185+
Attention RagAppsyncStepfnOpensearch users, an update has been made to
186+
the GraphQL schema.To ensure continued functionality, please review
187+
and update your GraphQL mutations and subscriptions to align with
188+
the new schema.This schema update enables enhanced capabilities
189+
and optimizations,so adopting the changes is recommended.
190+
Please refer to the construct documentation for details
191+
on the schema changes and examples of updated GraphQL statements.
192+
Reach out to the support team if you need assistance
193+
updating your integration codebase.
194+
`;
195+
180196
/**
181197
* Returns the instance of ec2.IVpc used by the construct
182198
*/
@@ -242,6 +258,7 @@ export class RagAppsyncStepfnOpensearch extends Construct {
242258
constructor(scope: Construct, id: string, props: RagAppsyncStepfnOpensearchProps) {
243259
super(scope, id);
244260

261+
Annotations.of(scope).addWarning(RagAppsyncStepfnOpensearch.CONSTRUCT_SCHEMA_UPDATE_WARNING);
245262
// stage
246263
let stage = '-dev';
247264
if (props?.stage) {

0 commit comments

Comments
 (0)