Update app.py
Browse files
app.py
CHANGED
|
@@ -135,17 +135,17 @@ def _(client_instantiation_form, mo):
|
|
| 135 |
from ibm_watsonx_ai import APIClient, Credentials
|
| 136 |
|
| 137 |
def setup_task_credentials(deployment_client):
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
|
| 150 |
if client_instantiation_form.value:
|
| 151 |
### Instantiate the watsonx.ai client
|
|
|
|
| 135 |
from ibm_watsonx_ai import APIClient, Credentials
|
| 136 |
|
| 137 |
def setup_task_credentials(deployment_client):
|
| 138 |
+
# Get existing task credentials
|
| 139 |
+
existing_credentials = deployment_client.task_credentials.get_details()
|
| 140 |
+
|
| 141 |
+
# Delete existing credentials if any
|
| 142 |
+
if "resources" in existing_credentials and existing_credentials["resources"]:
|
| 143 |
+
for cred in existing_credentials["resources"]:
|
| 144 |
+
cred_id = deployment_client.task_credentials.get_id(cred)
|
| 145 |
+
deployment_client.task_credentials.delete(cred_id)
|
| 146 |
+
|
| 147 |
+
# Store new credentials
|
| 148 |
+
return deployment_client.task_credentials.store()
|
| 149 |
|
| 150 |
if client_instantiation_form.value:
|
| 151 |
### Instantiate the watsonx.ai client
|