File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
solutions/banking/watson-scripts Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
IAM_TOKEN=" $1 "
6
6
WATSON_ASSISTANT_URL=$2
7
+ project_name=" gen-ai-rag-sample-app-assistant"
7
8
8
9
token=" $( echo " $IAM_TOKEN " | awk ' {print $2}' ) "
9
10
10
- curl -X POST --location " $WATSON_ASSISTANT_URL /v2/assistants?version=2023-06-15" \
11
+ ASSISTANT_ID= $( curl --retry 3 -fLsS -X GET --location " $WATSON_ASSISTANT_URL /v2/assistants?version=2023-06-15" \
11
12
--header " Authorization: Bearer $token " \
12
13
--header " Content-Type: application/json" \
13
- --data " {\" name\" :\" gen-ai-rag-sample-app-assistant\" ,\" language\" :\" en\" ,\" description\" :\" Generative AI sample app assistant\" }"
14
+ | jq -r ' .assistants[] | select(.name == "' $project_name ' ") | .assistant_id ' )
15
+
16
+ if [[ -z " $ASSISTANT_ID " ]]; then
17
+ # if not ASSISTANT_ID is found then create a new assistant project
18
+ curl --retry 3 -fLsS -X POST --location " $WATSON_ASSISTANT_URL /v2/assistants?version=2023-06-15" \
19
+ --header " Authorization: Bearer $token " \
20
+ --header " Content-Type: application/json" \
21
+ --data " {\" name\" :\" $project_name \" ,\" language\" :\" en\" ,\" description\" :\" Generative AI sample app assistant\" }"
22
+ else
23
+ # If ASSISTANT_ID exists in a project then do not create another project.
24
+ echo " $project_name project already exists."
25
+ exit 0
26
+ fi
You can’t perform that action at this time.
0 commit comments