diff --git a/layer/requirements.txt b/layer/requirements.txt index 5526a8c..85771e6 100644 --- a/layer/requirements.txt +++ b/layer/requirements.txt @@ -1,7 +1,8 @@ -# Sample file built from bedrock-access-gateway repo -fastapi==0.115.6 -pydantic==2.10.4 -uvicorn==0.34.0 -requests==2.32.3 -boto3==1.38.27 -botocore==1.38.27 +fastapi==0.120.0 +pydantic==2.12.3 +pydantic-settings==2.11.0 +uvicorn==0.29.0 +tiktoken==0.6.0 +numpy==1.26.4 +boto3==1.40.59 +botocore==1.40.59 \ No newline at end of file diff --git a/patches/app.py.patch b/patches/app.py.patch index 755b272..d6b9d45 100644 --- a/patches/app.py.patch +++ b/patches/app.py.patch @@ -1,10 +1,18 @@ --- a/api/app.py +++ b/api/app.py -@@ -6,7 +6,6 @@ from fastapi.responses import StreamingResponse +@@ -5,7 +5,6 @@ from fastapi import FastAPI + from fastapi.exceptions import RequestValidationError from fastapi.middleware.cors import CORSMiddleware - from fastapi.openapi.docs import get_swagger_ui_html - from fastapi.staticfiles import StaticFiles + from fastapi.responses import PlainTextResponse -from mangum import Mangum from api.routers import chat, embeddings, model - from api.setting import ( + from api.setting import API_ROUTE_PREFIX, DESCRIPTION, SUMMARY, TITLE, VERSION +@@ -47,7 +46,5 @@ async def validation_exception_handler(request, exc): + return PlainTextResponse(str(exc), status_code=400) + + +-handler = Mangum(app) +- + if __name__ == "__main__": + uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True) diff --git a/patches/pydantic-version.patch b/patches/pydantic-version.patch index 6e2b30d..a5ee55a 100644 --- a/patches/pydantic-version.patch +++ b/patches/pydantic-version.patch @@ -1,9 +1,9 @@ --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ - mangum==0.19.0 - fastapi==0.115.6 --pydantic==2.10.4 -+pydantic>=2.10.4 - pydantic-settings==2.6.1 - uvicorn==0.34.0 + fastapi==0.115.8 +-pydantic==2.7.1 ++pydantic>=2.12.3 + uvicorn==0.29.0 + mangum==0.17.0 + tiktoken==0.6.0 diff --git a/patches/requirements.txt.patch b/patches/requirements.txt.patch index 5c3d7b8..57fdac9 100644 --- a/patches/requirements.txt.patch +++ b/patches/requirements.txt.patch @@ -1,7 +1,15 @@ --- a/requirements.txt +++ b/requirements.txt -@@ -1,4 +1,3 @@ --mangum==0.19.0 - fastapi==0.115.6 - pydantic==2.10.4 - pydantic-settings==2.6.1 +@@ -1,9 +1,8 @@ +-fastapi==0.115.8 +-pydantic==2.7.1 ++fastapi==0.120.0 ++pydantic==2.12.3 ++pydantic-settings==2.11.0 + uvicorn==0.29.0 +-mangum==0.17.0 + tiktoken==0.6.0 +-requests==2.32.3 + numpy==1.26.4 + boto3==1.37.0 + botocore==1.37.0 diff --git a/prepare_source.sh b/prepare_source.sh index e888109..85a9c6d 100755 --- a/prepare_source.sh +++ b/prepare_source.sh @@ -38,30 +38,29 @@ rm -rf app/api rm -f layer/requirements.txt if [ -d "$REPO_DIR" ]; then - echo "Repository already cloned, fetching latest changes" - (cd $REPO_DIR && git fetch) + echo "Repository already cloned, resetting to clean state" + (cd $REPO_DIR && git reset --hard HEAD && git clean -fd) else echo "Cloning aws-samples/bedrock-access-gateway repository" git clone --depth 1 https://github.com/aws-samples/bedrock-access-gateway $REPO_DIR fi -cp -r $REPO_DIR/src/api app/api -cp $REPO_DIR/src/requirements.txt layer/requirements.txt - -echo "" > app/requirements.txt - # Apply patches echo "Applying patches" (cd $REPO_DIR/src && patch -p1 < ../../../patches/auth.py.patch) (cd $REPO_DIR/src && patch -p1 < ../../../patches/app.py.patch) (cd $REPO_DIR/src && patch -p1 < ../../../patches/requirements.txt.patch) -(cd $REPO_DIR/src && patch -p1 < ../../../patches/pydantic-version.patch) if [ "$NO_EMBEDDINGS" = true ]; then echo "Applying no-embeddings patch" (cd $REPO_DIR/src && patch -p1 < ../../../patches/no-embeddings.patch) fi +cp -r $REPO_DIR/src/api app/api +cp $REPO_DIR/src/requirements.txt layer/requirements.txt + +echo "" > app/requirements.txt + # Update boto3/botocore to latest versions for pkg in boto3 botocore; do VERSION=$(pip index versions $pkg 2>/dev/null | grep -m 1 "LATEST: " | awk '{print $2}')