Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
37dd81b
chore: enable local dev with a docker compose based stack
joeds13 Nov 21, 2025
0961f90
update app to send document as bytes instead of doing text conversion
PaulTaylor Nov 27, 2025
5e63b2c
updated system prompt
PaulTaylor Nov 28, 2025
aae4b06
fix bedrock service tests
PaulTaylor Nov 28, 2025
30825d3
fix markdown rendering issue on the client with the updated prompt
PaulTaylor Dec 1, 2025
2fd9889
update evaluation mechanisms for multimodal prompting
PaulTaylor Dec 3, 2025
31409c9
Remove pandoc and pypdf as no longer required
PaulTaylor Dec 4, 2025
d763608
switch default model to nova-lite
PaulTaylor Dec 5, 2025
e59d873
ignore terraform plugin-cache and built evaluation_alerts.zip
PaulTaylor Dec 5, 2025
c87b8ef
fix mixed http/https issue in the frontend when retriving history
PaulTaylor Dec 11, 2025
e942808
resolve CodeQL issues
PaulTaylor Dec 16, 2025
5a6bedc
fix whitespace issues
PaulTaylor Dec 16, 2025
7b3dd0e
frontend dependency updates to address vulnerabilities
PaulTaylor Dec 16, 2025
f195466
fix unit tests for evaluation service
PaulTaylor Dec 16, 2025
35866ef
exclude local docker runner from sonar coverage analysis
PaulTaylor Dec 16, 2025
42a43e0
improve test coverage in bedrock_service.py
PaulTaylor Dec 16, 2025
4729bdc
exclude local development wrapper from sonor analysis
PaulTaylor Dec 16, 2025
e26288b
disable automated evaluations as they always give the same result
PaulTaylor Dec 16, 2025
baff263
remove some stray print statements remaining from debugging
PaulTaylor Dec 17, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,5 @@ src/backend/app/.env
src/backend/bedrock_alerts/lambda_build
src/backend/bedrock_alerts/lambda_function.zip
src/backend/bedrock_alerts/lambda_function.zip
src/backend/bedrock_alerts/evaluations_alerts.zip
plugin-cache
93 changes: 93 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
x-aws-environment: &aws-environment
AWS_DEFAULT_REGION: eu-west-2
AWS_REGION: eu-west-2
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN}

services:
frontend:
build:
context: src/frontend/notifai-uploader
ports:
- "3000:80"
depends_on:
- backend
- bedrock-prompt-messager
environment:
<<: *aws-environment
REACT_APP_BACKEND_API_BASE_URL: "http://localhost:8080"
REACT_APP_COGNITO_ID: "4kgkrqjc0770v6slu27pjuagb1"
REACT_APP_COGNITO_USER_POOL_ID: "eu-west-2_JuQWLuCTr"
REACT_APP_API_GATEWAY: "http://localhost:8081/call-llm"
healthcheck:
test: ["CMD", "curl", "http://localhost:80/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s

backend:
build:
context: src/backend/app
ports:
- "8080:8080"
entrypoint:
[
"fastapi",
"dev",
"/app/main.py",
"--port",
"8080",
"--host",
"0.0.0.0",
"--reload",
]
volumes:
- "${PWD}/src/backend/app:/app"
environment:
<<: *aws-environment
COGNITO_REGION: "eu-west-2"
COGNITO_USER_POOL_ID: "eu-west-2_JuQWLuCTr"
COGNITO_APP_CLIENT_ID: "4kgkrqjc0770v6slu27pjuagb1"
S3_LLM_LOGS_BUCKET: "nhs-notifai-shared"
S3_LLM_LOGS_DIRECTORY: "logs/"
S3_LLM_LOGS_BUCKET_ACCOUNT_ID: "496395772806"
healthcheck:
test:
[
"CMD",
"python3",
"-c",
"import urllib.request; urllib.request.urlopen('http://localhost:8080/health')",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s

bedrock-prompt-messager:
build:
context: src/backend/bedrock-prompt-messager
dockerfile: Dockerfile
ports:
- "8081:8080"
volumes:
- "${PWD}/src/backend/bedrock-prompt-messager:/var/task"
environment:
<<: *aws-environment
env_model_id: "amazon.nova-lite-v1:0"
env_temperature: "0.1"
env_max_tokens: "10000"
env_top_p: "0.5"
env_logging_s3_bucket: "nhs-notifai-shared"
env_logging_s3_key_prefix: "logs/"
env_guardrail_arn: "arn:aws:bedrock:eu-west-2:496395772806:guardrail/7z5kf9qg62is"
env_guardrail_version: "1"
env_logging_s3_account_id: "496395772806"
healthcheck:
test: ["CMD", "curl", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
2 changes: 1 addition & 1 deletion infrastructure/terraform/components/notifyai/bedrock.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ data "aws_iam_policy_document" "bedrock_access_s3" {
aws_s3_bucket.evaluation_programatic_results.arn,
"${aws_s3_bucket.evaluation_programatic_results.arn}/*",
"arn:aws:bedrock:*::foundation-model/*",
"arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.amazon.nova-pro-v1:0",
"arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.amazon.nova-lite-v1:0",
"arn:aws:bedrock:${var.region}:${var.aws_account_id}:evaluation-job/*",
"arn:aws:bedrock:${var.region}::prompt/*",
"arn:aws:bedrock:*:${var.aws_account_id}:inference-profile/*",
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/terraform/components/notifyai/eventbridge.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module "eventbridge" {
arn = aws_lambda_function.bedrock_evaluations.arn
input = jsonencode({ "job" : "cron-by-rate" })
role_arn = aws_iam_role.eventbridge_scheduler_role.arn

end_date = "2025-12-16T00:00:00Z"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/terraform/components/notifyai/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ data "aws_iam_policy_document" "bedrock_access" {
"${aws_s3_bucket.lambda_prompt_logging_s3_bucket.arn}/${local.s3_lambda_logging_key}*",
"arn:aws:bedrock:${var.region}:${var.aws_account_id}:guardrail/*",
"arn:aws:bedrock:${var.region}:${var.aws_account_id}:inference-profile/eu.amazon.nova-pro-v1:*",
"arn:aws:bedrock:${var.region}::foundation-model/amazon.nova-pro-v1:0",
"arn:aws:bedrock:${var.region}::foundation-model/amazon.nova-lite-v1:0",
"arn:aws:logs:${var.region}:${var.aws_account_id}:log-group:/aws/lambda/${local.lambda_name}:*"
]
}
Expand Down

This file was deleted.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions infrastructure/terraform/etc/env_eu-west-2_dev1.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ prompt-max-tokens-to-sample = 5000
prompt-temperature = 0.1
prompt-top-p = 0.5

prompt-model = "amazon.nova-pro-v1:0"
evaluation-evaluator-model-identifier = "amazon.nova-pro-v1:0"
evaluation-inference-model-identifier = "amazon.nova-pro-v1:0"
prompt-model = "amazon.nova-lite-v1:0"
evaluation-evaluator-model-identifier = "amazon.nova-lite-v1:0"
evaluation-inference-model-identifier = "amazon.nova-lite-v1:0"
evaluation-schedule-days = 30

log_retention_in_days = 3
6 changes: 3 additions & 3 deletions infrastructure/terraform/etc/env_eu-west-2_dev2.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ prompt-max-tokens-to-sample = 5000
prompt-temperature = 0.1
prompt-top-p = 0.5

prompt-model = "amazon.nova-pro-v1:0"
evaluation-evaluator-model-identifier = "amazon.nova-pro-v1:0"
evaluation-inference-model-identifier = "amazon.nova-pro-v1:0"
prompt-model = "amazon.nova-lite-v1:0"
evaluation-evaluator-model-identifier = "amazon.nova-lite-v1:0"
evaluation-inference-model-identifier = "amazon.nova-lite-v1:0"
evaluation-schedule-days = 30

log_retention_in_days = 3
6 changes: 3 additions & 3 deletions infrastructure/terraform/etc/env_eu-west-2_test.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prompt-max-tokens-to-sample = 5000
prompt-temperature = 0.1
prompt-top-p = 0.5

prompt-model = "amazon.nova-pro-v1:0"
evaluation-evaluator-model-identifier = "amazon.nova-pro-v1:0"
evaluation-inference-model-identifier = "amazon.nova-pro-v1:0"
prompt-model = "amazon.nova-lite-v1:0"
evaluation-evaluator-model-identifier = "amazon.nova-lite-v1:0"
evaluation-inference-model-identifier = "amazon.nova-lite-v1:0"
evaluation-schedule-days = 3
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ aws_account_id = "767397886959"
region = "eu-west-2"

# Generics
log_retention_in_days = 10
log_retention_in_days = 14
kms_deletion_window = 15

budget_amount = 300
Expand Down
4 changes: 2 additions & 2 deletions scripts/config/sonar-scanner.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sonar.qualitygate.wait=true
sonar.sourceEncoding=UTF-8
sonar.sources=src/backend/app, src/backend/bedrock-prompt-messager, src/frontend/notifai-uploader
sonar.tests=src/backend/app/tests, src/backend/bedrock-prompt-messager/tests/
sonar.exclusions=src/**/tests/**
sonar.exclusions=src/**/tests/**,src/backend/bedrock-prompt-messager/api_wrapper.py,src/backend/bedrock-prompt-messager/Dockerfile
sonar.python.coverage.reportPaths=coverage.xml
#sonar.[javascript|typescript].lcov.reportPaths=.coverage/lcov.info
sonar.coverage.exclusions=scripts/**/*,**/core/config.py,**/core/constants.py,**/frontend/**/*
sonar.coverage.exclusions=scripts/**/*,**/core/config.py,**/core/constants.py,**/frontend/**/*,src/backend/bedrock-prompt-messager/api_wrapper.py
4 changes: 1 addition & 3 deletions src/backend/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ FROM python:slim

WORKDIR /app

RUN apt-get update && apt-get install -y pandoc && rm -rf /var/lib/apt/lists/*

COPY requirements.txt /requirements.txt

RUN pip install --no-cache-dir --upgrade -r /requirements.txt
Expand All @@ -12,4 +10,4 @@ COPY . .

EXPOSE 8080

CMD ["fastapi", "start", "app/main.py", "--port", "8080"]
CMD ["fastapi", "run", "/app/main.py", "--port", "8080"]
3 changes: 3 additions & 0 deletions src/backend/app/core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ async def dispatch(self, request: Request, call_next):
if request.method == "OPTIONS":
return await call_next(request)

if request.url.path in ["/health"]:
return await call_next(request)

try:
payload = _verify_request_token(request, self.authenticator)
request.state.user = payload
Expand Down
20 changes: 12 additions & 8 deletions src/backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CognitoAuthenticator,
NotFoundExceptionHandler,
)
from app.routers import convert, s3
from app.routers import s3
from dotenv import load_dotenv

load_dotenv()
Expand All @@ -16,18 +16,22 @@
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

authenticator = CognitoAuthenticator()

app.add_middleware(AuthMiddleware, authenticator=authenticator)
app.add_exception_handler(404, NotFoundExceptionHandler(authenticator))

app.add_middleware(
CORSMiddleware,
allow_origin_regex=r"https://[a-z0-9]+\.[a-z0-9\-]+\.awsapprunner\.com$", # Regex for App Runner URLs only
# Regex for App Runner and local dev URLs only
allow_origin_regex=r"https://[a-z0-9]+\.[a-z0-9\-]+\.awsapprunner\.com|.*localhost.*|127\.0\.0\.1$",
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

app.include_router(convert.router)
authenticator = CognitoAuthenticator()
app.add_middleware(AuthMiddleware, authenticator=authenticator)
app.add_exception_handler(404, NotFoundExceptionHandler(authenticator))

app.include_router(s3.router)


@app.get("/health")
async def health():
return {"detail": "ok"}, 200
4 changes: 1 addition & 3 deletions src/backend/app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
fastapi[standard]==0.115.2
uvicorn==0.32.0
python-multipart==0.0.18
boto3
pandoc
pypdf
boto3[crt]
pytest
pyjwt[crypto]
python-jose
Expand Down
12 changes: 0 additions & 12 deletions src/backend/app/routers/convert.py

This file was deleted.

74 changes: 0 additions & 74 deletions src/backend/app/services/convert_service.py

This file was deleted.

45 changes: 0 additions & 45 deletions src/backend/app/tests/routers/test_convert_router.py

This file was deleted.

Loading
Loading