Skip to content

Commit cc218c2

Browse files
committed
feat: Comprehensive health AI application improvements
Major Updates: - πŸ”§ Configure Chicago region for Speech AI and Object Storage compatibility - πŸ€– Add OpenAI integration as default AI provider with fallback to Oracle GenAI - πŸ” Externalize all configuration to environment variables for security - πŸ—„οΈ Fix SQL schema issues with constraint naming and JSON validation - πŸ“± Enhance medical transcription with comprehensive error handling - πŸš€ Update Kubernetes deployment templates with credential mounting Technical Changes: - Switch Object Storage from eu-frankfurt-1 to us-chicago-1 (aitests bucket) - Update Speech AI to use us-chicago-1 region for service alignment - Add OpenAI.java service with GPT-3.5-turbo integration - Enhanced OracleSpeechAI.java with detailed error reporting and job lifecycle monitoring - Updated MedicalTranscriptionsController.java to handle both audio formats and quality issues - Fixed SQL constraint naming conflicts in aiuser-tables-indexes-functions.sql - Added aivision_results_fixed.sql with proper JSON validation - Updated .gitignore to prevent deployment files with sensitive data from being committed - Added comprehensive .env.example template with safe placeholder values Security Improvements: - All sensitive configuration moved to environment variables - Removed hardcoded credentials from source code - Added gitignore rules for generated deployment files - Enhanced logging without exposing sensitive data Configuration Management: - Centralized configuration in AIApplication.java using System.getenv() - Updated Kubernetes deployment template with all required placeholders - Added setup-oci-credentials.sh for proper OCI authentication mounting - Enhanced deploy.sh to use environment variables from .env file This update resolves Speech AI transcription issues by ensuring regional compatibility and provides a robust, secure foundation for the health AI application with multiple AI service providers and comprehensive error handling.
1 parent ec3e167 commit cc218c2

23 files changed

+1237
-428
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ grabdish/inventory-micronaut/build/
55
.deployed/
66
.deployed/*.yaml
77

8+
# Generated deployment files with sensitive data
9+
**/healthai-backend-springboot-deployment.yaml
10+
811
# Compiled class file
912
*.class
1013

β€Žhealth/.env.exampleβ€Ž

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# OCI Configuration
3+
export OCICONFIG_FILE=~/.oci/config
4+
export OCICONFIG_PROFILE=DEFAULT
5+
export COMPARTMENT_ID=ocid1.compartment.oc1..your_compartment_id_here
6+
export OBJECTSTORAGE_NAMESPACE=your_objectstore_namespace
7+
export OBJECTSTORAGE_BUCKETNAME=aitests
8+
export OBJECTSTORAGE_REGION=us-chicago-1
9+
10+
# AI Vision Model OCIDs
11+
export VISIONAI_XRAY_BREASTCANCER_MODEL_OCID=ocid1.aivisionmodel.oc1..your_breastcancer_model_id
12+
export VISIONAI_XRAY_LUNGCANCER_MODEL_OCID=ocid1.aivisionmodel.oc1..your_lungcancer_model_id
13+
export VISIONAI_XRAY_PNEUMONIA_MODEL_OCID=ocid1.aivisionmodel.oc1..your_pneumonia_model_id
14+
export VISIONAI_XRAY_PNEUMONIA_MODEL_DEEP_LEARNING_OCID=ocid1.aivisionmodel.oc1..your_pneumonia_deep_learning_model_id
15+
16+
# Service Endpoints (Chicago region for Speech AI compatibility)
17+
export ORDS_ENDPOINT_URL=https://your-ords-endpoint-url
18+
export OCI_VISION_SERVICE_ENDPOINT=https://vision.aiservice.us-chicago-1.oci.oraclecloud.com
19+
export OCI_SPEECH_SERVICE_ENDPOINT=https://speech.aiservice.us-chicago-1.oci.oraclecloud.com
20+
export OCI_GENAI_SERVICE_ENDPOINT=https://genai.aiservice.eu-frankfurt-1.oci.oraclecloud.com
21+
22+
# OpenAI Configuration (primary AI provider)
23+
export OPENAI_API_KEY=sk-proj-your_openai_api_key_here
24+
25+
# Display all set environment variables
26+
echo "=== Environment Variables Set ==="
27+
echo "OCICONFIG_FILE: $OCICONFIG_FILE"
28+
echo "OCICONFIG_PROFILE: $OCICONFIG_PROFILE"
29+
echo "COMPARTMENT_ID: $COMPARTMENT_ID"
30+
echo "OBJECTSTORAGE_NAMESPACE: $OBJECTSTORAGE_NAMESPACE"
31+
echo "OBJECTSTORAGE_BUCKETNAME: $OBJECTSTORAGE_BUCKETNAME"
32+
echo "VISIONAI_XRAY_BREASTCANCER_MODEL_OCID: $VISIONAI_XRAY_BREASTCANCER_MODEL_OCID"
33+
echo "VISIONAI_XRAY_LUNGCANCER_MODEL_OCID: $VISIONAI_XRAY_LUNGCANCER_MODEL_OCID"
34+
echo "VISIONAI_XRAY_PNEUMONIA_MODEL_OCID: $VISIONAI_XRAY_PNEUMONIA_MODEL_OCID"
35+
echo "ORDS_ENDPOINT_URL: $ORDS_ENDPOINT_URL"
36+
echo "OCI_VISION_SERVICE_ENDPOINT: $OCI_VISION_SERVICE_ENDPOINT"
37+
echo "OCI_SPEECH_SERVICE_ENDPOINT: $OCI_SPEECH_SERVICE_ENDPOINT"
38+
echo "OCI_GENAI_SERVICE_ENDPOINT: $OCI_GENAI_SERVICE_ENDPOINT"
39+
echo "OPENAI_KEY: $OPENAI_KEY"
40+
echo "=== All environment variables have been set successfully! ==="
900 KB
Binary file not shown.

β€Žhealth/springboot-backend/deploy.shβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
## Copyright (c) 2025 Oracle and/or its affiliates.
33
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44

5+
# Source environment variables from .env file
6+
if [ -f "../.env" ]; then
7+
echo "Loading environment variables from .env file..."
8+
source "../.env"
9+
else
10+
echo "Warning: .env file not found. Using environment variables from shell."
11+
fi
12+
513
export TAG=0.1.$(date +%s)
614
echo TAG = $TAG
715

@@ -46,6 +54,19 @@ podman push --format docker "$IMAGE"
4654

4755
cp healthai-backend-springboot-deployment_template.yaml healthai-backend-springboot-deployment.yaml
4856
sed -i '' "s|IMAGE_PLACEHOLDER|$IMAGE|g" healthai-backend-springboot-deployment.yaml
57+
sed -i '' "s|COMPARTMENT_ID_PLACEHOLDER|$COMPARTMENT_ID|g" healthai-backend-springboot-deployment.yaml
58+
sed -i '' "s|OBJECTSTORAGE_NAMESPACE_PLACEHOLDER|$OBJECTSTORAGE_NAMESPACE|g" healthai-backend-springboot-deployment.yaml
59+
sed -i '' "s|OBJECTSTORAGE_BUCKETNAME_PLACEHOLDER|$OBJECTSTORAGE_BUCKETNAME|g" healthai-backend-springboot-deployment.yaml
60+
sed -i '' "s|OBJECTSTORAGE_REGION_PLACEHOLDER|$OBJECTSTORAGE_REGION|g" healthai-backend-springboot-deployment.yaml
61+
sed -i '' "s|ORDS_ENDPOINT_URL_PLACEHOLDER|$ORDS_ENDPOINT_URL|g" healthai-backend-springboot-deployment.yaml
62+
sed -i '' "s|OCI_VISION_SERVICE_ENDPOINT_PLACEHOLDER|$OCI_VISION_SERVICE_ENDPOINT|g" healthai-backend-springboot-deployment.yaml
63+
sed -i '' "s|OCI_SPEECH_SERVICE_ENDPOINT_PLACEHOLDER|$OCI_SPEECH_SERVICE_ENDPOINT|g" healthai-backend-springboot-deployment.yaml
64+
sed -i '' "s|OCI_GENAI_SERVICE_ENDPOINT_PLACEHOLDER|$OCI_GENAI_SERVICE_ENDPOINT|g" healthai-backend-springboot-deployment.yaml
65+
sed -i '' "s|OPENAI_API_KEY_PLACEHOLDER|$OPENAI_API_KEY|g" healthai-backend-springboot-deployment.yaml
66+
sed -i '' "s|VISIONAI_XRAY_BREASTCANCER_MODEL_OCID_PLACEHOLDER|$VISIONAI_XRAY_BREASTCANCER_MODEL_OCID|g" healthai-backend-springboot-deployment.yaml
67+
sed -i '' "s|VISIONAI_XRAY_LUNGCANCER_MODEL_OCID_PLACEHOLDER|$VISIONAI_XRAY_LUNGCANCER_MODEL_OCID|g" healthai-backend-springboot-deployment.yaml
68+
sed -i '' "s|VISIONAI_XRAY_PNEUMONIA_MODEL_OCID_PLACEHOLDER|$VISIONAI_XRAY_PNEUMONIA_MODEL_OCID|g" healthai-backend-springboot-deployment.yaml
69+
sed -i '' "s|VISIONAI_XRAY_PNEUMONIA_MODEL_DEEP_LEARNING_OCID_PLACEHOLDER|$VISIONAI_XRAY_PNEUMONIA_MODEL_DEEP_LEARNING_OCID|g" healthai-backend-springboot-deployment.yaml
4970
kubectl apply -f healthai-backend-springboot-deployment.yaml -n health
5071

5172

β€Žhealth/springboot-backend/env.propertiesβ€Ž

Lines changed: 0 additions & 13 deletions
This file was deleted.

β€Žhealth/springboot-backend/healthai-backend-springboot-deployment.yamlβ€Ž

Lines changed: 0 additions & 48 deletions
This file was deleted.

β€Žhealth/springboot-backend/healthai-backend-springboot-deployment_template.yamlβ€Ž

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,36 @@ spec:
2828
value: Welcome12345*
2929
- name: OCI_REGION
3030
value: us-phoenix-1
31+
- name: OCICONFIG_FILE
32+
value: "/root/.oci/config"
33+
- name: OCICONFIG_PROFILE
34+
value: "DEFAULT"
35+
- name: COMPARTMENT_ID
36+
value: "COMPARTMENT_ID_PLACEHOLDER"
37+
- name: OBJECTSTORAGE_NAMESPACE
38+
value: "OBJECTSTORAGE_NAMESPACE_PLACEHOLDER"
39+
- name: OBJECTSTORAGE_BUCKETNAME
40+
value: "OBJECTSTORAGE_BUCKETNAME_PLACEHOLDER"
41+
- name: OBJECTSTORAGE_REGION
42+
value: "OBJECTSTORAGE_REGION_PLACEHOLDER"
43+
- name: ORDS_ENDPOINT_URL
44+
value: "ORDS_ENDPOINT_URL_PLACEHOLDER"
45+
- name: OCI_VISION_SERVICE_ENDPOINT
46+
value: "OCI_VISION_SERVICE_ENDPOINT_PLACEHOLDER"
47+
- name: OCI_SPEECH_SERVICE_ENDPOINT
48+
value: "OCI_SPEECH_SERVICE_ENDPOINT_PLACEHOLDER"
49+
- name: OCI_GENAI_SERVICE_ENDPOINT
50+
value: "OCI_GENAI_SERVICE_ENDPOINT_PLACEHOLDER"
51+
- name: OPENAI_API_KEY
52+
value: "OPENAI_API_KEY_PLACEHOLDER"
53+
- name: VISIONAI_XRAY_BREASTCANCER_MODEL_OCID
54+
value: "VISIONAI_XRAY_BREASTCANCER_MODEL_OCID_PLACEHOLDER"
55+
- name: VISIONAI_XRAY_LUNGCANCER_MODEL_OCID
56+
value: "VISIONAI_XRAY_LUNGCANCER_MODEL_OCID_PLACEHOLDER"
57+
- name: VISIONAI_XRAY_PNEUMONIA_MODEL_OCID
58+
value: "VISIONAI_XRAY_PNEUMONIA_MODEL_OCID_PLACEHOLDER"
59+
- name: VISIONAI_XRAY_PNEUMONIA_MODEL_DEEP_LEARNING_OCID
60+
value: "VISIONAI_XRAY_PNEUMONIA_MODEL_DEEP_LEARNING_OCID_PLACEHOLDER"
3161
# value: Welcome12345
3262
# - name: spring.datasource.password
3363
# valueFrom:
@@ -38,11 +68,25 @@ spec:
3868
volumeMounts:
3969
- name: creds
4070
mountPath: /healthai/creds
71+
- name: oci-config
72+
mountPath: /root/.oci
73+
readOnly: true
74+
- name: oci-private-key
75+
mountPath: /root/.ssh
76+
readOnly: true
4177
ports:
4278
- containerPort: 8080
4379
restartPolicy: Always
4480
volumes:
4581
- name: creds
4682
secret:
4783
secretName: healthai-backend-db-tns-admin-secret
84+
- name: oci-config
85+
configMap:
86+
name: oci-config
87+
defaultMode: 0600
88+
- name: oci-private-key
89+
secret:
90+
secretName: oci-private-key
91+
defaultMode: 0600
4892

β€Žhealth/springboot-backend/logpod.shβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ echo ""
5151
echo "πŸ’‘ To follow logs in real-time, use:"
5252
for POD in $PODS; do
5353
echo " kubectl logs -f $POD -n health"
54+
kubectl logs -f $POD -n health
5455
done

β€Žhealth/springboot-backend/pom.xmlβ€Ž

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<spring-cloud.version>2022.0.4</spring-cloud.version>
2020
<oracle.jdbc.version>21.9.0.0</oracle.jdbc.version>
2121
<spring.vault.version>3.1.1</spring.vault.version>
22-
<oci.sdk.version>3.35.0</oci.sdk.version>
22+
<oci.sdk.version>3.45.0</oci.sdk.version>
2323
<jib-maven-plugin.version>3.3.1</jib-maven-plugin.version>
2424
<liquibase.version>4.17.2</liquibase.version>
2525
<docker.registry>${env.DOCKER_REGISTRY}</docker.registry>
@@ -43,9 +43,10 @@
4343
</dependency>
4444
<dependency>
4545
<groupId>com.oracle.oci.sdk</groupId>
46-
<artifactId>oci-java-sdk-common-httpclient-jersey</artifactId>
46+
<artifactId>oci-java-sdk-common-httpclient-jersey3</artifactId>
4747
<version>${oci.sdk.version}</version>
4848
</dependency>
49+
4950
<dependency>
5051
<groupId>org.slf4j</groupId>
5152
<artifactId>slf4j-simple</artifactId>
@@ -108,11 +109,12 @@
108109
<artifactId>spring-jdbc</artifactId>
109110
</dependency>
110111

111-
<!-- <dependency>-->
112-
<!-- <groupId>com.theokanning.openai-gpt3-java</groupId>-->
113-
<!-- <artifactId>service</artifactId>-->
114-
<!-- <version>0.12.0</version>-->
115-
<!-- </dependency>-->
112+
<!-- OpenAI Java SDK -->
113+
<dependency>
114+
<groupId>com.theokanning.openai-gpt3-java</groupId>
115+
<artifactId>service</artifactId>
116+
<version>0.18.2</version>
117+
</dependency>
116118

117119
<dependency>
118120
<groupId>com.oracle.oci.sdk</groupId>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
# setup-oci-credentials.sh - Create Kubernetes secrets and configmaps for OCI authentication
4+
5+
echo "πŸ”§ Setting up OCI credentials for Kubernetes deployment..."
6+
7+
# Check if files exist
8+
if [ ! -f ~/.oci/config ]; then
9+
echo "❌ Error: ~/.oci/config file not found"
10+
echo "Please ensure your OCI config file exists at ~/.oci/config"
11+
exit 1
12+
fi
13+
14+
if [ ! -f ~/.ssh/oracleidentitycloudservice_paul.parkinson-05-07-03-14.pem ]; then
15+
echo "❌ Error: Private key file not found at ~/.ssh/oracleidentitycloudservice_paul.parkinson-05-07-03-14.pem"
16+
echo "Please ensure your OCI private key file exists"
17+
exit 1
18+
fi
19+
20+
echo "βœ… Found required OCI credential files"
21+
22+
# Create namespace if it doesn't exist
23+
# kubectl create namespace health --dry-run=client -o yaml | kubectl apply -f -
24+
25+
# Delete existing secrets/configmaps if they exist (to update them)
26+
echo "🧹 Cleaning up existing OCI credentials..."
27+
kubectl delete configmap oci-config -n health --ignore-not-found=true
28+
kubectl delete secret oci-private-key -n health --ignore-not-found=true
29+
30+
# Create ConfigMap for OCI config file
31+
echo "πŸ“ Creating OCI config ConfigMap..."
32+
kubectl create configmap oci-config \
33+
--from-file=config="$HOME/.oci/config" \
34+
-n health
35+
36+
if [ $? -eq 0 ]; then
37+
echo "βœ… Successfully created oci-config ConfigMap"
38+
else
39+
echo "❌ Failed to create oci-config ConfigMap"
40+
exit 1
41+
fi
42+
43+
# Create Secret for private key file
44+
echo "πŸ” Creating OCI private key Secret..."
45+
kubectl create secret generic oci-private-key \
46+
--from-file=oracleidentitycloudservice_paul.parkinson-05-07-03-14.pem="$HOME/.ssh/oracleidentitycloudservice_paul.parkinson-05-07-03-14.pem" \
47+
-n health
48+
49+
if [ $? -eq 0 ]; then
50+
echo "βœ… Successfully created oci-private-key Secret"
51+
else
52+
echo "❌ Failed to create oci-private-key Secret"
53+
exit 1
54+
fi
55+
56+
echo ""
57+
echo "πŸŽ‰ OCI credentials setup complete!"
58+
echo ""
59+
echo "πŸ“‹ Created resources:"
60+
echo " β€’ ConfigMap: oci-config (contains ~/.oci/config)"
61+
echo " β€’ Secret: oci-private-key (contains private key file)"
62+
echo ""
63+
echo "πŸ’‘ Your deployment template is now configured to mount these at:"
64+
echo " β€’ /root/.oci/config (OCI configuration)"
65+
echo " β€’ /root/.ssh/oracleidentitycloudservice_paul.parkinson-05-07-03-14.pem (private key)"
66+
echo ""
67+
echo "πŸš€ You can now deploy your application with:"
68+
echo " ./deploy.sh"
69+
echo ""
70+
71+
# Verify the setup
72+
echo "πŸ” Verifying setup..."
73+
echo "ConfigMaps in health namespace:"
74+
kubectl get configmaps -n health | grep oci-config || echo "❌ oci-config not found"
75+
76+
echo "Secrets in health namespace:"
77+
kubectl get secrets -n health | grep oci-private-key || echo "❌ oci-private-key not found"
78+
79+
echo ""
80+
echo "βœ… Setup verification complete!"

0 commit comments

Comments
Β (0)