Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
105 changes: 105 additions & 0 deletions ai/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

# ==============================
# COMMON FUNCTIONS
# ==============================

RED="\033[31m"
BLUE="\033[94m"
GREEN="\033[32m"
ENDCOLOR="\033[0m"

function print_error {
echo -e "${RED}\n==========================================${ENDCOLOR}"
echo -e "${RED} FAILED${ENDCOLOR}"
echo -e "${RED}==========================================\n${ENDCOLOR}"
echo -e "${RED}$1${ENDCOLOR}"
echo -e ""
}
function print_msg {
echo -e "${BLUE}$1${ENDCOLOR}"
}
function print_success {
echo -e "${GREEN}$1${ENDCOLOR}"
}

# Helper function to check whether prerequisites are installed
function check_prerequisites {
# Ensure that jq tool is installed
if ! command -v jq &>/dev/null; then
print_error "'jq' tool is not installed"
exit 1
fi
}

# ==============================
# COMMON IBMCLOUD HELPERS
# ==============================

# helper function to check whether IBM Cloud CLI plugins should get updated, or not
function ensure_plugin_is_up_to_date() {
echo "Checking $1 ..."
# check whether plugin is installed
if ! ibmcloud plugin show $1 -q >/dev/null; then
# install it
ibmcloud plugin install $1 -f --quiet
else
# check whether there is an update available
ibmcloud plugin update $1 -f --quiet
fi
}

function target_region {
print_msg "\nTargetting IBM Cloud region '$1' ..."
current_region=$(ibmcloud target --output JSON |jq -r '.region|.name')
if [[ "$current_region" != "$1" ]]; then
ibmcloud target -r $1 --quiet
fi
}

function target_resource_group {
print_msg "\nTargetting resource group '$1' ..."
current_resource_group_guid=$(ibmcloud target --output JSON |jq -r '.resource_group|.guid')
new_resource_group_guid=$(ibmcloud resource group $1 -output json|jq -r '.[0].id')
if [[ "$current_resource_group_guid" != "$new_resource_group_guid" ]]; then
ibmcloud target -g $1 --quiet
fi
echo "Done"
}

function does_instance_exist {
(( $(ibmcloud resource search "service_name:\"$1\" AND name:\"$2\"" --output JSON|jq -r '.items|length') > 0 ))
}

function does_serviceid_exist {
(( $(ibmcloud resource search "type:serviceid AND name:\"$1\"" --output JSON|jq -r '.items|length') > 0 ))
}

function has_bucket_name_with_prefix {
buckets=$(ibmcloud cos buckets -output json)
COS_BUCKET_NAME=""
if [[ "$(echo "${buckets}" | jq -r '.Buckets')" != "null" ]]; then
for bucket in $(echo "${buckets}" | jq -r '.Buckets|.[] | @base64'); do
_jq() {
echo ${bucket} | base64 --decode | jq -r ${1}
}
bucket_name=$(_jq '.Name')
if [[ "$bucket_name" =~ ^$1-* ]]; then
COS_BUCKET_NAME=$bucket_name
fi
done
fi
echo $COS_BUCKET_NAME
}


function abortScript() {
if [[ "${CLEANUP_ON_ERROR}" == true ]]; then
clean
else
print_msg "\nSkipping deletion of the created IBM Cloud resources. Please be aware that the created resources will occur costs in your account."
echo "$ ibmcloud resource service-instances --type all -g $resource_group_name --location $REGION"
ibmcloud resource service-instances --type all -g $resource_group_name --location $REGION
fi
exit 1
}
14 changes: 14 additions & 0 deletions ai/langchain-skills-agent/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# LLM Configuration (OpenAI-compatible API)
# Configure your inference backend here

# IBM watsonx.ai
INFERENCE_BASE_URL=https://eu-de.ml.cloud.ibm.com
INFERENCE_API_KEY="YOUR_API_KEY"
INFERENCE_MODEL_NAME="meta-llama/llama-3-2-11b-vision-instruct"
INFERENCE_PROJECT_ID="YOUR_PROJECT_ID"


# IBM Cloud Configuration (for deployment)
REGION=eu-de
PROJECT_NAME=langchain-skills-agent-project
NAME_PREFIX=ce-langchain-agent
16 changes: 16 additions & 0 deletions ai/langchain-skills-agent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Environment files
.env

# Python
__pycache__/
*.py[oc]
.venv/
*.egg-info

# IDE
.vscode/
.idea/

# OS
.DS_Store
Thumbs.db
Loading
Loading