Skip to content

Commit

Permalink
added planning and reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarrata committed Dec 6, 2024
1 parent 71162b9 commit d1d367f
Show file tree
Hide file tree
Showing 22 changed files with 434 additions and 15 deletions.
51 changes: 51 additions & 0 deletions bootstrap/database/db-init-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: batch/v1
kind: Job
metadata:
name: db-init-job
annotations:
argocd.argoproj.io/sync-wave: "2"
spec:
template:
spec:
initContainers:
- name: wait-for-db
image: busybox:1.28
command: ['sh', '-c', 'until nc -z -v -w30 $POSTGRESQL_DATABASE 5432; do echo "Waiting for database connection..."; sleep 2; done;']
env:
- name: POSTGRESQL_DATABASE
value: claimdb.ic-shared-db.svc.cluster.local
containers:
- name: postgresql
image: registry.redhat.io/rhel9/postgresql-13:latest
env:
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
name: claimdb
key: database-name
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
name: claimdb
key: database-user
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: claimdb
key: database-password
- name: POSTGRESQL_DATABASE_HOST
value: claimdb.ic-shared-db.svc.cluster.local
command: ["/bin/bash", "-c"]
args:
- |
echo "Running SQL script"
psql -h $POSTGRESQL_DATABASE_HOST -p 5432 -U $POSTGRESQL_USER -d $POSTGRESQL_DATABASE -f /sql-script/script.sql
volumeMounts:
- name: sql-script-volume
mountPath: /sql-script
restartPolicy: Never
volumes:
- name: sql-script-volume
configMap:
name: sql-script-configmap
backoffLimit: 4
76 changes: 76 additions & 0 deletions bootstrap/database/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: ic-shared-db
name: ic-shared-db
annotations:
argocd.argoproj.io/sync-wave: "1"
spec:
selector:
matchLabels:
app: ic-shared-db
replicas: 1
template:
metadata:
labels:
app: ic-shared-db
spec:
containers:
- name: postgresql
image: registry.redhat.io/rhel9/postgresql-13:latest
resources:
limits:
memory: 512Mi
readinessProbe:
exec:
command:
- /usr/libexec/check-container
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
livenessProbe:
exec:
command:
- /usr/libexec/check-container
- '--live'
initialDelaySeconds: 120
timeoutSeconds: 10
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
env:
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
name: claimdb
key: database-user
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: claimdb
key: database-password
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
name: claimdb
key: database-name
securityContext:
capabilities: {}
privileged: false
ports:
- containerPort: 5432
protocol: TCP
imagePullPolicy: IfNotPresent
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: claimdb-data
mountPath: /var/lib/pgsql/data
volumes:
- name: claimdb-data
persistentVolumeClaim:
claimName: claimdb
strategy:
type: Recreate
22 changes: 22 additions & 0 deletions bootstrap/database/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ic-shared-db

commonLabels:
component: ic-shared-db

resources:
# wave 0
- namespace.yaml
# wave 1
- pvc.yaml
- secret.yaml
- secret-minio.yaml
- deployment.yaml
- service.yaml
- sql-script-configmap.yaml
# wave 2
- db-init-job.yaml
- populate-images.yaml
11 changes: 11 additions & 0 deletions bootstrap/database/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: ic-shared-db
labels:
app: ic-shared-db
argocd.argoproj.io/managed-by: openshift-gitops
annotations:
openshift.io/display-name: "Shared PostgreSQL Database"
argocd.argoproj.io/sync-wave: "0"
59 changes: 59 additions & 0 deletions bootstrap/database/populate-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: populate-images
annotations:
argocd.argoproj.io/sync-wave: "2"
spec:
backoffLimit: 4
template:
spec:
initContainers:
- name: wait-for-minio
image: busybox:1.28
command: ['sh', '-c', 'until nc -z -v -w30 $MINIO_ENDPOINT 9000; do echo "Waiting for Minio connection..."; sleep 2; done;']
env:
- name: MINIO_ENDPOINT
value: minio.ic-shared-minio.svc.cluster.local
containers:
- name: add-images-to-bucket
image: image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/s2i-generic-data-science-notebook:1.2
imagePullPolicy: IfNotPresent
command: ["/bin/bash"]
args:
- -ec
- |-
git clone https://github.com/rh-aiservices-bu/parasol-insurance.git
cat << 'EOF' | python3
import boto3, os, botocore
s3 = boto3.client("s3",
endpoint_url=os.getenv("AWS_S3_ENDPOINT"),
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"))
# Create image bucket
bucket_name = "claim-images"
try:
s3.head_bucket(Bucket=bucket_name)
except botocore.exceptions.ClientError as e:
if e.response['Error']['Code'] == '404':
s3.create_bucket(Bucket=bucket_name)
# Upload original images to minio
for filename in os.listdir("parasol-insurance/bootstrap/ic-shared-database/images/original_images"):
with open(f"parasol-insurance/bootstrap/ic-shared-database/images/original_images/{filename}", "rb") as f:
s3.upload_fileobj(f, bucket_name, f"original_images/{filename}")
# Upload processed images to minio
for filename in os.listdir("parasol-insurance/bootstrap/ic-shared-database/images/processed_images"):
with open(f"parasol-insurance/bootstrap/ic-shared-database/images/processed_images/{filename}", "rb") as f:
s3.upload_fileobj(f, bucket_name, f"processed_images/{filename}")
EOF
envFrom:
- secretRef:
name: secret-minio
restartPolicy: Never
16 changes: 16 additions & 0 deletions bootstrap/database/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: claimdb
namespace: ic-shared-db
labels:
app: ic-shared-db
annotations:
argocd.argoproj.io/sync-wave: "1"
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
14 changes: 14 additions & 0 deletions bootstrap/database/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: Secret
apiVersion: v1
metadata:
name: claimdb
namespace: ic-shared-db
labels:
app: ic-shared-db
annotations:
argocd.argoproj.io/sync-wave: "1"
stringData:
database-name: claimdb
database-password: claimdb
database-user: claimdb
type: Opaque
20 changes: 20 additions & 0 deletions bootstrap/database/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: v1
kind: Service
metadata:
name: claimdb
namespace: ic-shared-db
labels:
app: ic-shared-db
annotations:
argocd.argoproj.io/sync-wave: "1"
spec:
ports:
- name: postgresql
protocol: TCP
port: 5432
targetPort: 5432
selector:
app: ic-shared-db
sessionAffinity: None
type: ClusterIP
Binary file modified content/modules/ROOT/assets/images/04/04-02-react-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/modules/ROOT/assets/images/05/05-01-tool-calling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/modules/ROOT/assets/images/06/06-03-human-loop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions content/modules/ROOT/pages/05-02-agentic-architectures.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ workflows with access to external resources.
- **Memory**: Retains context across steps, using short-term and long-term memory.
- **Planning**: Enables the LLM to decide on multi-step actions, iteratively refining its approach based on observations.
image::05/05-01-tool-calling.png[Tool Calling]

## Key Features for Custom Agent Architectures

- **Human-in-the-Loop**: Involves human oversight for critical decisions, such as approving actions or editing the agent’s state. This is crucial for sensitive tasks where full automation may not be desirable.
Expand Down
3 changes: 2 additions & 1 deletion content/modules/ROOT/pages/05-03-routing-collaboration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ensuring precision and reliability in specific applications.
Routers are ideal for scenarios where an LLM must make a single decision or route a task based on
context, without the complexity of managing an entire control flow.

image::05/05-08-agent-routing.png[Agentic Routing]

## **Key Features of Routers**

1. **Decision-Making Scope**:
Expand All @@ -30,7 +32,6 @@ context, without the complexity of managing an entire control flow.
3. **Routing**: It selects the appropriate step or tool to proceed.
4. **Execution**: The selected tool or path is executed to complete the task.
image::05/05-08-agent-routing.png[Agentic Routing]
## **Examples of Router Applications**

Expand Down
4 changes: 3 additions & 1 deletion content/modules/ROOT/pages/05-04-tool-calling.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Tool calling agents enable:
This architecture allows for more dynamic and flexible behaviors, enabling agents to solve intricate tasks by
leveraging external resources efficiently.

image::05/05-01-tool-calling.png[Tool Calling]

== **Tool Calling**

Tools are essential for enabling agents to interact with external systems, such as APIs or databases.
Expand All @@ -33,7 +35,7 @@ the gap between natural language inputs and the structured requirements of these

Let's see the Tool Calling and Routing Agents in Action!

From the `agentic-workshop/lab-materials/05` folder, please open the notebook called `5.1-agent-routing.ipynb` and follow the instructions.
From the `agentic-workshop/lab-materials/04` folder, please open the notebook called `4.1-agent-routing.ipynb` and follow the instructions.

=== Example Use Cases:

Expand Down
2 changes: 1 addition & 1 deletion content/modules/ROOT/pages/05-05-sql-agents.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ image::05/05-07-sql-agents.png[SQL Agents]

Let's see the SQL Retriever Agents in Action!

From the `agentic-workshop/lab-materials/05` folder, please open the notebook called `4.5-sql-agents.ipynb` and follow the instructions.
From the `agentic-workshop/lab-materials/04` folder, please open the notebook called `4.5-sql-agents.ipynb` and follow the instructions.

== **Example Use Cases**

Expand Down
2 changes: 1 addition & 1 deletion content/modules/ROOT/pages/05-06-react-implementation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ image::04/04-07-react-final.png[ReAct Final]

Let's see the Tool Calling and Routing Agents in Action!

From the `agentic-workshop/lab-materials/04` folder, please open the notebook called `4.2-react-agents.ipynb` and follow the instructions.
From the `agentic-workshop/lab-materials/04` folder, please open the notebook called `4.3-react-agents.ipynb` and follow the instructions.

== Advantages of ReAct Agents

Expand Down
Loading

0 comments on commit d1d367f

Please sign in to comment.