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

feat: support updating existing documents #430

Merged
merged 9 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 11 additions & 26 deletions source/infrastructure/lib/api/api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,36 +176,19 @@ export class ApiConstruct extends Construct {
],
});

const listExecutionLambda = new LambdaFunction(this, "ListExecution", {
const executionManagementLambda = new LambdaFunction(this, "ExecutionManagementLambda", {
code: Code.fromAsset(join(__dirname, "../../../lambda/etl")),
handler: "list_execution.lambda_handler",
handler: "execution_management.lambda_handler",
environment: {
EXECUTION_TABLE: executionTableName,
},
statements: [this.iamHelper.dynamodbStatement],
});

const getExecutionLambda = new LambdaFunction(this, "GetExecution", {
code: Code.fromAsset(join(__dirname, "../../../lambda/etl")),
handler: "get_execution.lambda_handler",
environment: {
ETL_OBJECT_TABLE: etlObjTableName,
ETL_OBJECT_INDEX: etlObjIndexName,
},
statements: [this.iamHelper.dynamodbStatement],
});

const delExecutionLambda = new LambdaFunction(this, "DeleteExecution", {
code: Code.fromAsset(join(__dirname, "../../../lambda/etl")),
handler: "delete_execution.lambda_handler",
environment: {
SFN_ARN: props.knowledgeBaseStackOutputs.sfnOutput.stateMachineArn,
EXECUTION_TABLE: executionTableName,
},
statements: [this.iamHelper.dynamodbStatement],
});

props.knowledgeBaseStackOutputs.sfnOutput.grantStartExecution(delExecutionLambda.function);
props.knowledgeBaseStackOutputs.sfnOutput.grantStartExecution(executionManagementLambda.function);

const uploadDocLambda = new LambdaFunction(this, "UploadDocument", {
code: Code.fromAsset(join(__dirname, "../../../lambda/etl")),
Expand Down Expand Up @@ -278,7 +261,7 @@ export class ApiConstruct extends Construct {
}
apiKBExecution.addMethod(
"GET",
new apigw.LambdaIntegration(listExecutionLambda.function),
new apigw.LambdaIntegration(executionManagementLambda.function),
{...this.genMethodOption(api, auth, {
Items: {type: JsonSchemaType.ARRAY, items: {
type: JsonSchemaType.OBJECT,
Expand Down Expand Up @@ -333,22 +316,22 @@ export class ApiConstruct extends Construct {
);
apiKBExecution.addMethod(
"DELETE",
new apigw.LambdaIntegration(delExecutionLambda.function),
new apigw.LambdaIntegration(executionManagementLambda.function),
{
...this.genMethodOption(api, auth, {
data: { type: JsonSchemaType.ARRAY, items: { type: JsonSchemaType.STRING } },
message: { type: JsonSchemaType.STRING }
ExecutionIds: { type: JsonSchemaType.ARRAY, items: { type: JsonSchemaType.STRING } },
Message: { type: JsonSchemaType.STRING }
}),
requestModels: this.genRequestModel(api, {
"executionId": { "type": JsonSchemaType.ARRAY, "items": { "type": JsonSchemaType.STRING } },
})
}
);

const apiGetExecutionById = apiKBExecution.addResource("{executionId}");
apiGetExecutionById.addMethod(
"GET",
new apigw.LambdaIntegration(getExecutionLambda.function),
new apigw.LambdaIntegration(executionManagementLambda.function),
{
...this.genMethodOption(api, auth, {
Items: {
Expand All @@ -375,6 +358,8 @@ export class ApiConstruct extends Construct {
// })
}
);
apiGetExecutionById.addMethod("PUT", new apigw.LambdaIntegration(executionManagementLambda.function), this.genMethodOption(api, auth, null));


const apiUploadDoc = apiResourceStepFunction.addResource("kb-presigned-url");
apiUploadDoc.addMethod(
Expand Down
2 changes: 1 addition & 1 deletion source/lambda/etl/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ExecutionStatus(Enum):
COMPLETED = "COMPLETED"
DELETING = "DELETING"
DELETED = "DELETED"

UPDATING = "UPDATING"

class EmbeddingModelType(Enum):
BEDROCK_TITAN_V1 = "amazon.titan-embed-text-v1"
Expand Down
103 changes: 0 additions & 103 deletions source/lambda/etl/create_chatbot.py

This file was deleted.

139 changes: 0 additions & 139 deletions source/lambda/etl/delete_execution.py

This file was deleted.

Loading
Loading