diff --git a/.dockerignore b/.dockerignore index 5e81f2f..263a5ae 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,16 +1,10 @@ -# Keeps the collector image build context (repo root) small. -# Only config.yaml and ingest_utils/confluence_processor are copied in. -.git -cdk.out -node_modules -frontend -planning-docs -**/__pycache__ -**/*.pyc -.venv -venv +# Exclude everything, then re-include only what the collector image needs +* +!config.yaml +!ingest_utils ingest_utils/confluence_processor/confluence_downloads ingest_utils/confluence_processor/google_drive_downloads ingest_utils/confluence_processor/service-credentials.json -ingest_utils/confluence_processor/names.env -ingest_utils/confluence_processor/names.env.copy +ingest_utils/confluence_processor/names.env* +**/__pycache__ +**/*.pyc \ No newline at end of file diff --git a/src/backend/chatbot_backend.py b/src/backend/chatbot_backend.py index 8d2ffcf..f0eb6ee 100644 --- a/src/backend/chatbot_backend.py +++ b/src/backend/chatbot_backend.py @@ -18,7 +18,7 @@ dynamodb = boto3.resource("dynamodb") ssm = boto3.client("ssm") -# Reject oversized queries before any billable Bedrock/OpenSearch call (S5). +# Reject oversized queries before any billable Bedrock/OpenSearch call MAX_QUERY_CHARS = 4000 # Cache for prompts @@ -187,8 +187,8 @@ def invoke_model( return response["output"]["message"]["content"][0]["text"] - except Exception as e: - logger.error(f"Error invoking the model: {str(e)}") + except Exception: + logger.exception("Error invoking the model") return None @@ -615,8 +615,8 @@ def lambda_handler(event: Dict[str, Any], context: Any) -> Dict[str, Any]: ), } - except Exception as e: - logger.error(f"Error in lambda_handler: {e}") + except Exception: + logger.exception("Error in lambda_handler") return { "statusCode": 500, "body": json.dumps("Error processing message"), diff --git a/src/backend/opensearch_query.py b/src/backend/opensearch_query.py index 41930ed..fa426da 100644 --- a/src/backend/opensearch_query.py +++ b/src/backend/opensearch_query.py @@ -27,6 +27,10 @@ def initialize_opensearch(): use_ssl=True, verify_certs=True, connection_class=RequestsHttpConnection, + # AOSS intermittently returns 500s on valid queries; retry through them + max_retries=3, + retry_on_status=(500, 502, 503, 504), + retry_on_timeout=True, ) return client