diff --git a/lib/chatbot-api/functions/api-handler/common/constant.py b/lib/chatbot-api/functions/api-handler/common/constant.py index f3eb555d8..8ab799622 100644 --- a/lib/chatbot-api/functions/api-handler/common/constant.py +++ b/lib/chatbot-api/functions/api-handler/common/constant.py @@ -5,4 +5,10 @@ SAFE_STR_REGEX = r"^[A-Za-z0-9-_. ]*$" SAFE_HTTP_STR_REGEX = r"^[A-Za-z0-9-_.:/]*$" ID_FIELD_VALIDATION = Field(min_length=1, max_length=100, pattern=SAFE_STR_REGEX) +ID_FIELD_VALIDATION_OPTIONAL = Field( + min_length=1, max_length=100, pattern=SAFE_STR_REGEX, default=None +) SAFE_SHORT_STR_VALIDATION = Field(min_length=1, max_length=100, pattern=SAFE_STR_REGEX) +SAFE_SHORT_STR_VALIDATION_OPTIONAL = Field( + min_length=1, max_length=100, pattern=SAFE_STR_REGEX, default=None +) diff --git a/lib/chatbot-api/functions/api-handler/index.py b/lib/chatbot-api/functions/api-handler/index.py index a1f76d299..850b4c741 100644 --- a/lib/chatbot-api/functions/api-handler/index.py +++ b/lib/chatbot-api/functions/api-handler/index.py @@ -52,8 +52,9 @@ def handler(event: dict, context: LambdaContext) -> dict: ) return app.resolve(event, context) except ValidationError as e: - logger.warning(e.errors()) - raise e + errors = e.errors(include_url=False, include_context=False, include_input=False) + logger.warning("Validation error", errors=errors) + raise ValueError(f"Invalid request. Details: {errors}") except CommonError as e: logger.warning(str(e)) raise e diff --git a/lib/chatbot-api/functions/api-handler/routes/cross_encoders.py b/lib/chatbot-api/functions/api-handler/routes/cross_encoders.py index d7a3df2b8..ae897e3ab 100644 --- a/lib/chatbot-api/functions/api-handler/routes/cross_encoders.py +++ b/lib/chatbot-api/functions/api-handler/routes/cross_encoders.py @@ -14,7 +14,7 @@ class CrossEncodersRequest(BaseModel): provider: str = Field(min_length=1, max_length=500, pattern=SAFE_STR_REGEX) - model: str = Field(min_length=1, max_length=500, pattern=SAFE_STR_REGEX) + model: str = Field(min_length=1, max_length=500, pattern=r"^[A-Za-z0-9-_. /]*$") reference: str = Field(min_length=1, max_length=MAX_STR_INPUT_LENGTH) passages: List[Annotated[str, Field(min_length=1, max_length=MAX_STR_INPUT_LENGTH)]] diff --git a/lib/chatbot-api/functions/api-handler/routes/documents.py b/lib/chatbot-api/functions/api-handler/routes/documents.py index 36fb3d4ce..d69e2b2d2 100644 --- a/lib/chatbot-api/functions/api-handler/routes/documents.py +++ b/lib/chatbot-api/functions/api-handler/routes/documents.py @@ -1,6 +1,7 @@ import os from common.constant import ( ID_FIELD_VALIDATION, + ID_FIELD_VALIDATION_OPTIONAL, SAFE_HTTP_STR_REGEX, SAFE_STR_REGEX, MAX_STR_INPUT_LENGTH, @@ -19,9 +20,13 @@ router = Router() logger = Logger() +CONTENT_TYPE_VALDIATION = Field( + min_length=1, max_length=100, pattern=r"^[A-Za-z0-9-_./]*$" +) + class FileUploadRequest(BaseModel): - workspaceId: Optional[str] = ID_FIELD_VALIDATION + workspaceId: Optional[str] = ID_FIELD_VALIDATION_OPTIONAL fileName: str = Field(min_length=1, max_length=500, pattern=SAFE_STR_REGEX) @@ -43,7 +48,7 @@ class WebsiteDocumentRequest(BaseModel): address: str = Field(min_length=1, max_length=500, pattern=SAFE_HTTP_STR_REGEX) followLinks: bool limit: int = Field(gt=-1) - contentTypes: Optional[List[Annotated[str, SAFE_SHORT_STR_VALIDATION]]] + contentTypes: Optional[List[Annotated[str, CONTENT_TYPE_VALDIATION]]] = None class RssFeedDocumentRequest(BaseModel): @@ -59,16 +64,14 @@ class RssFeedDocumentRequest(BaseModel): default=None, min_length=1, max_length=100, pattern=SAFE_STR_REGEX ) followLinks: bool - contentTypes: Optional[List[Annotated[str, SAFE_SHORT_STR_VALIDATION]]] + contentTypes: Optional[List[Annotated[str, CONTENT_TYPE_VALDIATION]]] = None class RssFeedCrawlerUpdateRequest(BaseModel): documentType: str = SAFE_SHORT_STR_VALIDATION followLinks: bool limit: int = Field(lt=500) - contentTypes: Optional[Annotated[str, SAFE_SHORT_STR_VALIDATION]] = Field( - min_length=1, max_length=100, pattern=SAFE_STR_REGEX - ) + contentTypes: Optional[List[Annotated[str, CONTENT_TYPE_VALDIATION]]] = None class ListDocumentsRequest(BaseModel): diff --git a/lib/chatbot-api/functions/api-handler/routes/embeddings.py b/lib/chatbot-api/functions/api-handler/routes/embeddings.py index 00431ad79..f4091a5a9 100644 --- a/lib/chatbot-api/functions/api-handler/routes/embeddings.py +++ b/lib/chatbot-api/functions/api-handler/routes/embeddings.py @@ -15,7 +15,7 @@ class EmbeddingsRequest(BaseModel): provider: str = Field(min_length=1, max_length=500, pattern=SAFE_STR_REGEX) - model: str = Field(min_length=1, max_length=500, pattern=SAFE_STR_REGEX) + model: str = Field(min_length=1, max_length=500, pattern=r"^[A-Za-z0-9-_. /]*$") passages: List[Annotated[str, Field(min_length=1, max_length=MAX_STR_INPUT_LENGTH)]] task: Optional[Task] = Task.STORE diff --git a/lib/chatbot-api/functions/api-handler/routes/workspaces.py b/lib/chatbot-api/functions/api-handler/routes/workspaces.py index bdc3188b6..e106fe16e 100644 --- a/lib/chatbot-api/functions/api-handler/routes/workspaces.py +++ b/lib/chatbot-api/functions/api-handler/routes/workspaces.py @@ -1,6 +1,7 @@ from typing import Annotated, List, Optional from common.constant import ( SAFE_SHORT_STR_VALIDATION, + SAFE_SHORT_STR_VALIDATION_OPTIONAL, ) from common.validation import WorkspaceIdValidation import genai_core.types @@ -27,9 +28,13 @@ class CreateWorkspaceAuroraRequest(BaseModel): kind: str = SAFE_SHORT_STR_VALIDATION name: str = Field(min_length=1, max_length=100, pattern=name_regex) embeddingsModelProvider: str = SAFE_SHORT_STR_VALIDATION - embeddingsModelName: str = SAFE_SHORT_STR_VALIDATION - crossEncoderModelProvider: Optional[str] = SAFE_SHORT_STR_VALIDATION - crossEncoderModelName: Optional[str] = SAFE_SHORT_STR_VALIDATION + embeddingsModelName: str = Field( + min_length=0, max_length=500, pattern=r"^[A-Za-z0-9-_. /]*$", default=None + ) + crossEncoderModelProvider: Optional[str] = SAFE_SHORT_STR_VALIDATION_OPTIONAL + crossEncoderModelName: Optional[str] = Field( + min_length=0, max_length=500, pattern=r"^[A-Za-z0-9-_. /]*$", default=None + ) languages: List[Annotated[str, SAFE_SHORT_STR_VALIDATION]] metric: str = SAFE_SHORT_STR_VALIDATION index: bool diff --git a/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/index.py b/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/index.py index c9740ce64..013259675 100644 --- a/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/index.py +++ b/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/index.py @@ -6,7 +6,8 @@ from aws_lambda_powertools import Logger, Tracer from aws_lambda_powertools.utilities.typing import LambdaContext from aws_lambda_powertools.logging import correlation_paths -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, ValidationError + tracer = Tracer() logger = Logger(log_uncaught_exceptions=True) @@ -17,29 +18,36 @@ MAX_STR_INPUT_LENGTH = 1000000 SAFE_STR_REGEX = r"^[A-Za-z0-9-_. ]*$" SAFE_SHORT_STR_VALIDATION = Field(min_length=0, max_length=500, pattern=SAFE_STR_REGEX) +SAFE_SHORT_STR_VALIDATION_OPTIONAL = Field( + min_length=0, max_length=500, pattern=SAFE_STR_REGEX, default=None +) class ModelKwargsFieldValidation(BaseModel): - streaming: Optional[bool] - maxTokens: Optional[int] = Field(gt=0, lt=1000000) - temperature: Optional[float] = Field(ge=0, le=1) - topP: Optional[float] = Field(ge=0, le=1) + streaming: Optional[bool] = None + maxTokens: Optional[int] = Field(gt=0, lt=1000000, default=None) + temperature: Optional[float] = Field(ge=0, le=1, default=None) + topP: Optional[float] = Field(ge=0, le=1, default=None) class FileFieldValidation(BaseModel): - provider: Optional[str] = SAFE_SHORT_STR_VALIDATION - key: Optional[str] = SAFE_SHORT_STR_VALIDATION + provider: Optional[str] = SAFE_SHORT_STR_VALIDATION_OPTIONAL + key: Optional[str] = SAFE_SHORT_STR_VALIDATION_OPTIONAL class DataFieldValidation(BaseModel): - modelName: Optional[str] = SAFE_SHORT_STR_VALIDATION - provider: Optional[str] = SAFE_SHORT_STR_VALIDATION - sessionId: Optional[str] = SAFE_SHORT_STR_VALIDATION - workspaceId: Optional[str] = SAFE_SHORT_STR_VALIDATION - mode: Optional[str] = SAFE_SHORT_STR_VALIDATION - text: Optional[str] = Field(min_length=1, max_length=MAX_STR_INPUT_LENGTH) + modelName: Optional[str] = Field( + min_length=0, max_length=500, pattern=r"^[A-Za-z0-9-_. /:]*$", default=None + ) + provider: Optional[str] = SAFE_SHORT_STR_VALIDATION_OPTIONAL + sessionId: Optional[str] = SAFE_SHORT_STR_VALIDATION_OPTIONAL + workspaceId: Optional[str] = SAFE_SHORT_STR_VALIDATION_OPTIONAL + mode: Optional[str] = SAFE_SHORT_STR_VALIDATION_OPTIONAL + text: Optional[str] = Field( + min_length=1, max_length=MAX_STR_INPUT_LENGTH, default=None + ) files: Optional[List[FileFieldValidation]] - modelKwargs: Optional[ModelKwargsFieldValidation] + modelKwargs: Optional[ModelKwargsFieldValidation] = None class InputValidation(BaseModel): @@ -67,11 +75,15 @@ def handler(event, context: LambdaContext): "userId": event["identity"]["sub"], "data": request.get("data", {}), } - InputValidation(**message) try: + InputValidation(**message) response = sns.publish(TopicArn=TOPIC_ARN, Message=json.dumps(message)) return response + except ValidationError as e: + errors = e.errors(include_url=False, include_context=False, include_input=False) + logger.warning("Validation error", errors=errors) + raise ValueError(f"Invalid request. Details: {errors}") except Exception as e: # Do not return an unknown exception to the end user. logger.exception(e) diff --git a/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt b/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt index f66948ea5..e68599fc9 100644 --- a/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt +++ b/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt @@ -1,2 +1,2 @@ -pydantic==2.4.0 +pydantic==2.9.2 aws_xray_sdk==2.14.0 \ No newline at end of file diff --git a/lib/rag-engines/aurora-pgvector/create-aurora-workspace.ts b/lib/rag-engines/aurora-pgvector/create-aurora-workspace.ts index fed3efb8e..49988a90a 100644 --- a/lib/rag-engines/aurora-pgvector/create-aurora-workspace.ts +++ b/lib/rag-engines/aurora-pgvector/create-aurora-workspace.ts @@ -137,6 +137,10 @@ export class CreateAuroraWorkspace extends Construct { ? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE : cdk.RemovalPolicy.DESTROY, retention: props.config.logRetention, + // Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy + // size limit. + // https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html + logGroupName: `/aws/vendedlogs/states/CreateAuroraWorkspace-${this.node.addr}`, } ); diff --git a/lib/rag-engines/data-import/file-import-workflow.ts b/lib/rag-engines/data-import/file-import-workflow.ts index 2f2804ce3..b7ec7a626 100644 --- a/lib/rag-engines/data-import/file-import-workflow.ts +++ b/lib/rag-engines/data-import/file-import-workflow.ts @@ -111,6 +111,10 @@ export class FileImportWorkflow extends Construct { ? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE : cdk.RemovalPolicy.DESTROY, retention: props.config.logRetention, + // Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy + // size limit. + // https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html + logGroupName: `/aws/vendedlogs/states/FileImportStateMachine-${this.node.addr}`, }); const workflow = setProcessing.next(fileImportJob).next(setProcessed); diff --git a/lib/rag-engines/data-import/website-crawling-workflow.ts b/lib/rag-engines/data-import/website-crawling-workflow.ts index b9c1b97d3..866f80f6e 100644 --- a/lib/rag-engines/data-import/website-crawling-workflow.ts +++ b/lib/rag-engines/data-import/website-crawling-workflow.ts @@ -132,6 +132,10 @@ export class WebsiteCrawlingWorkflow extends Construct { ? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE : cdk.RemovalPolicy.DESTROY, retention: props.config.logRetention, + // Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy + // size limit. + // https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html + logGroupName: `/aws/vendedlogs/states/WebsiteCrawling-${this.node.addr}`, }); const workflow = setProcessing.next(webCrawlerJob).next(setProcessed); diff --git a/lib/rag-engines/kendra-retrieval/create-kendra-workspace.ts b/lib/rag-engines/kendra-retrieval/create-kendra-workspace.ts index 1a5245d02..e85fc6097 100644 --- a/lib/rag-engines/kendra-retrieval/create-kendra-workspace.ts +++ b/lib/rag-engines/kendra-retrieval/create-kendra-workspace.ts @@ -89,6 +89,10 @@ export class CreateKendraWorkspace extends Construct { ? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE : cdk.RemovalPolicy.DESTROY, retention: props.config.logRetention, + // Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy + // size limit. + // https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html + logGroupName: `/aws/vendedlogs/states/CreateKendraWorkspace-${this.node.addr}`, } ); diff --git a/lib/rag-engines/opensearch-vector/create-opensearch-workspace.ts b/lib/rag-engines/opensearch-vector/create-opensearch-workspace.ts index e1cdf53b2..129ee2201 100644 --- a/lib/rag-engines/opensearch-vector/create-opensearch-workspace.ts +++ b/lib/rag-engines/opensearch-vector/create-opensearch-workspace.ts @@ -151,6 +151,10 @@ export class CreateOpenSearchWorkspace extends Construct { ? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE : cdk.RemovalPolicy.DESTROY, retention: props.config.logRetention, + // Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy + // size limit. + // https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html + logGroupName: `/aws/vendedlogs/states/CreateOpenSearchWorkspace-${this.node.addr}`, } ); diff --git a/lib/rag-engines/workspaces/delete-document.ts b/lib/rag-engines/workspaces/delete-document.ts index c1d29cd5e..13fe67977 100644 --- a/lib/rag-engines/workspaces/delete-document.ts +++ b/lib/rag-engines/workspaces/delete-document.ts @@ -170,6 +170,10 @@ export class DeleteDocument extends Construct { ? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE : cdk.RemovalPolicy.DESTROY, retention: props.config.logRetention, + // Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy + // size limit. + // https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html + logGroupName: `/aws/vendedlogs/states/DeleteWorkspace-${this.node.addr}`, }); const stateMachine = new sfn.StateMachine(this, "DeleteDocument", { diff --git a/lib/rag-engines/workspaces/delete-workspace.ts b/lib/rag-engines/workspaces/delete-workspace.ts index cfa52ceaf..040331a1e 100644 --- a/lib/rag-engines/workspaces/delete-workspace.ts +++ b/lib/rag-engines/workspaces/delete-workspace.ts @@ -173,6 +173,10 @@ export class DeleteWorkspace extends Construct { ? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE : cdk.RemovalPolicy.DESTROY, retention: props.config.logRetention, + // Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy + // size limit. + // https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html + logGroupName: `/aws/vendedlogs/states/DeleteWorkspace-${this.node.addr}`, }); const stateMachine = new sfn.StateMachine(this, "DeleteWorkspace", { diff --git a/lib/shared/file-import-batch-job/requirements.txt b/lib/shared/file-import-batch-job/requirements.txt index 58d6d7d39..f0fe0d92b 100644 --- a/lib/shared/file-import-batch-job/requirements.txt +++ b/lib/shared/file-import-batch-job/requirements.txt @@ -4,12 +4,11 @@ numpy==1.26.0 cfnresponse==1.1.2 aws_requests_auth==0.4.3 requests-aws4auth==1.2.3 -langchain==0.2.14 -langchain-community==0.2.12 +langchain==0.3.5 +langchain-community==0.3.3 opensearch-py==2.3.1 psycopg2-binary==2.9.7 pgvector==0.2.2 -pydantic==2.4.0 urllib3<2 openai==1.47.0 beautifulsoup4==4.12.2 diff --git a/lib/shared/index.ts b/lib/shared/index.ts index 1f342a62f..d13408b1c 100644 --- a/lib/shared/index.ts +++ b/lib/shared/index.ts @@ -45,7 +45,7 @@ export class Shared extends Construct { this.kmsKeyAlias = props.config.prefix + "genaichatbot-shared-key"; this.queueKmsKeyAlias = props.config.prefix + "genaichatbot-queue-shared-key"; - const powerToolsLayerVersion = "46"; + const powerToolsLayerVersion = "2"; this.defaultEnvironmentVariables = { POWERTOOLS_DEV: "false", @@ -258,10 +258,12 @@ export class Shared extends Construct { stringValue: JSON.stringify(props.config), }); + //https://docs.powertools.aws.dev/lambda/python/3.2.0/ + const pythonVersion = pythonRuntime.name.replace(".", ""); const powerToolsArn = lambdaArchitecture === lambda.Architecture.X86_64 - ? `arn:${cdk.Aws.PARTITION}:lambda:${cdk.Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2:${powerToolsLayerVersion}` - : `arn:${cdk.Aws.PARTITION}:lambda:${cdk.Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:${powerToolsLayerVersion}`; + ? `arn:${cdk.Aws.PARTITION}:lambda:${cdk.Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV3-${pythonVersion}-x86_64:${powerToolsLayerVersion}` + : `arn:${cdk.Aws.PARTITION}:lambda:${cdk.Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV3-${pythonVersion}-arm64:${powerToolsLayerVersion}`; const powerToolsLayer = lambda.LayerVersion.fromLayerVersionArn( this, diff --git a/lib/shared/layers/common/requirements.txt b/lib/shared/layers/common/requirements.txt index d9ab3f4a9..d35ba96de 100644 --- a/lib/shared/layers/common/requirements.txt +++ b/lib/shared/layers/common/requirements.txt @@ -3,15 +3,15 @@ numpy==1.26.0 cfnresponse==1.1.2 aws_requests_auth==0.4.3 requests-aws4auth==1.2.3 -langchain==0.2.14 -langchain-community==0.2.12 -langchain-aws==0.1.17 -langchain-openai==0.1.25 -openai==1.47.0 +langchain==0.3.5 +langchain-core==0.3.13 +langchain-community==0.3.3 +langchain-aws==0.2.4 +langchain-openai==0.2.4 +langchain-text-splitters==0.3.1 opensearch-py==2.4.2 psycopg2-binary==2.9.7 pgvector==0.2.2 -pydantic==2.4.0 urllib3<2 beautifulsoup4==4.12.2 requests==2.32.0 diff --git a/lib/shared/layers/python-sdk/python/genai_core/chunks.py b/lib/shared/layers/python-sdk/python/genai_core/chunks.py index 702fde5b0..f5bdaa5fa 100644 --- a/lib/shared/layers/python-sdk/python/genai_core/chunks.py +++ b/lib/shared/layers/python-sdk/python/genai_core/chunks.py @@ -7,7 +7,7 @@ import genai_core.opensearch.chunks from genai_core.types import CommonError, Task from typing import List, Optional -from langchain.text_splitter import RecursiveCharacterTextSplitter +from langchain_text_splitters import RecursiveCharacterTextSplitter PROCESSING_BUCKET_NAME = os.environ.get("PROCESSING_BUCKET_NAME", "") s3 = boto3.resource("s3") diff --git a/lib/shared/utils.ts b/lib/shared/utils.ts index e3bf1be71..fc8dcda89 100644 --- a/lib/shared/utils.ts +++ b/lib/shared/utils.ts @@ -23,13 +23,14 @@ export abstract class Utils { } } - static getDefaultEmbeddingsModel(config: SystemConfig): string { + static getDefaultEmbeddingsModel(config: SystemConfig): string | undefined { const defaultModel = config.rag.embeddingsModels.find( (model) => model.default === true ); if (!defaultModel) { - throw new Error("No default embeddings model found"); + // No default embdeding is set in the config when Aurora or Opensearch are not used. + return undefined; } return `${defaultModel.provider}::${defaultModel.dimensions}::${defaultModel.name}`; diff --git a/lib/shared/web-crawler-batch-job/requirements.txt b/lib/shared/web-crawler-batch-job/requirements.txt index 5b0d69233..67111e9f7 100644 --- a/lib/shared/web-crawler-batch-job/requirements.txt +++ b/lib/shared/web-crawler-batch-job/requirements.txt @@ -4,11 +4,10 @@ numpy==1.26.0 cfnresponse==1.1.2 aws_requests_auth==0.4.3 requests-aws4auth==1.2.3 -langchain==0.2.14 +langchain==0.3.5 opensearch-py==2.3.1 psycopg2-binary==2.9.7 pgvector==0.2.2 -pydantic==2.4.0 urllib3<2 openai==0.28.0 beautifulsoup4==4.12.2 diff --git a/lib/user-interface/react-app/src/pages/rag/embeddings/embeddings.tsx b/lib/user-interface/react-app/src/pages/rag/embeddings/embeddings.tsx index 8dede63ce..e27f14f48 100644 --- a/lib/user-interface/react-app/src/pages/rag/embeddings/embeddings.tsx +++ b/lib/user-interface/react-app/src/pages/rag/embeddings/embeddings.tsx @@ -72,10 +72,6 @@ export default function Embeddings() { validate: (form) => { const errors: Record = {}; - if (!form.embeddingsModel) { - errors.embeddingsModel = "Embeddings model is required"; - } - for (let i = 0; i < form.input.length; i++) { const input = form.input[i]; if (input.trim().length === 0) { diff --git a/lib/user-interface/react-app/vite.config.ts b/lib/user-interface/react-app/vite.config.ts index 892b548e9..6e7655171 100644 --- a/lib/user-interface/react-app/vite.config.ts +++ b/lib/user-interface/react-app/vite.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ define: { "process.env": {}, // Prevents replacing global in the import strings. - global: "global", + global: isDev ? {} : "global", }, plugins: [ isDev && { diff --git a/tests/__snapshots__/cdk-app.test.ts.snap b/tests/__snapshots__/cdk-app.test.ts.snap index b4a989418..ac0266a4f 100644 --- a/tests/__snapshots__/cdk-app.test.ts.snap +++ b/tests/__snapshots__/cdk-app.test.ts.snap @@ -2689,7 +2689,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -3309,7 +3309,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -5101,7 +5101,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -5907,7 +5907,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -7713,7 +7713,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -7995,6 +7995,7 @@ schema { "RagEnginesAuroraPgVectorCreateAuroraWorkspaceCreateAuroraWorkspaceSMLogGroup3134E68A": { "DeletionPolicy": "RetainExceptOnCreate", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/CreateAuroraWorkspace-c85defe1059e7fe274e5d32dfa5fbf22bf25029784", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -8207,7 +8208,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -9261,6 +9262,7 @@ schema { "RagEnginesDataImportFileImportWorkflowFileImportSMLogGroupACEA6D66": { "DeletionPolicy": "RetainExceptOnCreate", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/FileImportStateMachine-c8cf719aab95cd313558c24b954a4d64738cc90e28", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -9859,7 +9861,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -10169,7 +10171,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -10589,7 +10591,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -11076,7 +11078,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -12512,6 +12514,7 @@ schema { "RagEnginesDataImportWebsiteCrawlingWorkflowWebsiteCrawlingSMLogGroup0C0F0231": { "DeletionPolicy": "RetainExceptOnCreate", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/WebsiteCrawling-c84284c45e3cc190f86fcddfefa098795bf6057ea6", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -12579,6 +12582,7 @@ schema { "RagEnginesKendraRetrievalCreateKendraWorkspaceCreateKendraWorkspaceSMLogGroupC9D4A635": { "DeletionPolicy": "RetainExceptOnCreate", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/CreateKendraWorkspace-c82d1f0bddb3f281b5b0d41fbdc8dd5ce18a954f60", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -13320,7 +13324,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -13593,6 +13597,7 @@ schema { "RagEnginesOpenSearchVectorCreateOpenSearchWorkspaceCreateOpenSearchWorkspaceSMLogGroupB97A0992": { "DeletionPolicy": "RetainExceptOnCreate", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/CreateOpenSearchWorkspace-c80c40855b0079b324a7fd75085c6a2e70b9e6eeae", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -16032,7 +16037,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -16478,6 +16483,7 @@ schema { "RagEnginesWorkspacesDeleteDocumentDeleteDocumentSMLogGroupD3F7AE1A": { "DeletionPolicy": "RetainExceptOnCreate", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/DeleteWorkspace-c8f300d08639a84d1a06e986b62cd5544b8a7b47f9", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -16765,7 +16771,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -17211,6 +17217,7 @@ schema { "RagEnginesWorkspacesDeleteWorkspaceDeleteWorkspaceSMLogGroup6EA3524F": { "DeletionPolicy": "RetainExceptOnCreate", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/DeleteWorkspace-c8d0f97b477041b4948603d16e0499afeaa5361c9c", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", diff --git a/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap b/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap index d7b672bf4..808305652 100644 --- a/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap +++ b/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap @@ -2860,7 +2860,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -3400,7 +3400,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -5618,7 +5618,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -5853,6 +5853,7 @@ schema { "RagEnginesAuroraPgVectorCreateAuroraWorkspaceCreateAuroraWorkspaceSMLogGroup3134E68A": { "DeletionPolicy": "Delete", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/CreateAuroraWorkspace-c8452d5c1e50beef6ce7711a12b5b2b94c06ab63c9", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -6043,7 +6044,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -7033,6 +7034,7 @@ schema { "RagEnginesDataImportFileImportWorkflowFileImportSMLogGroupACEA6D66": { "DeletionPolicy": "Delete", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/FileImportStateMachine-c8dccfec6c46c17fc1838ad79ebf8db898b8909b9c", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -7722,7 +7724,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -7983,7 +7985,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -8358,7 +8360,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -8870,7 +8872,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -10280,6 +10282,7 @@ schema { "RagEnginesDataImportWebsiteCrawlingWorkflowWebsiteCrawlingSMLogGroup0C0F0231": { "DeletionPolicy": "Delete", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/WebsiteCrawling-c84c2dc1c7dcbb91f090053c5011b698fba19f95c3", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -10347,6 +10350,7 @@ schema { "RagEnginesKendraRetrievalCreateKendraWorkspaceCreateKendraWorkspaceSMLogGroupC9D4A635": { "DeletionPolicy": "Delete", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/CreateKendraWorkspace-c8fb806c7befce2813b20d937db829309c4304e20d", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -11139,7 +11143,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -11357,6 +11361,7 @@ schema { "RagEnginesOpenSearchVectorCreateOpenSearchWorkspaceCreateOpenSearchWorkspaceSMLogGroupB97A0992": { "DeletionPolicy": "Delete", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/CreateOpenSearchWorkspace-c8a01fbc6e0a5b466bef32a0f428525db17267e978", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -13635,7 +13640,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -14034,6 +14039,7 @@ schema { "RagEnginesWorkspacesDeleteDocumentDeleteDocumentSMLogGroupD3F7AE1A": { "DeletionPolicy": "Delete", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/DeleteWorkspace-c86de8028b47fd4c13e24a1f6afdd4cc78fb5a7272", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", @@ -14300,7 +14306,7 @@ schema { { "Ref": "AWS::Region", }, - ":017000801446:layer:AWSLambdaPowertoolsPythonV2:46", + ":017000801446:layer:AWSLambdaPowertoolsPythonV3-python311-x86_64:2", ], ], }, @@ -14699,6 +14705,7 @@ schema { "RagEnginesWorkspacesDeleteWorkspaceDeleteWorkspaceSMLogGroup6EA3524F": { "DeletionPolicy": "Delete", "Properties": { + "LogGroupName": "/aws/vendedlogs/states/DeleteWorkspace-c8407881c0ca4430481731ee6b0a7f7f73e6028115", "RetentionInDays": 731, }, "Type": "AWS::Logs::LogGroup", diff --git a/tests/chatbot-api/functions/api-handler/routes/documents_test.py b/tests/chatbot-api/functions/api-handler/routes/documents_test.py index 5d7b286b4..ebe2c1c81 100644 --- a/tests/chatbot-api/functions/api-handler/routes/documents_test.py +++ b/tests/chatbot-api/functions/api-handler/routes/documents_test.py @@ -41,7 +41,7 @@ def test_file_upload(mocker): def test_file_upload_invalid_input(mocker): - with pytest.raises(ValidationError, match="2 validation errors"): + with pytest.raises(ValidationError, match="1 validation error"): file_upload({}) with pytest.raises(ValidationError, match="2 validation errors"): file_upload({"fileName": "fileName