h2ogpte 1.6.39__py3-none-any.whl → 1.6.40rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. h2ogpte/__init__.py +1 -1
  2. h2ogpte/errors.py +4 -0
  3. h2ogpte/h2ogpte.py +443 -23
  4. h2ogpte/h2ogpte_async.py +449 -27
  5. h2ogpte/h2ogpte_sync_base.py +5 -0
  6. h2ogpte/rest_async/__init__.py +13 -1
  7. h2ogpte/rest_async/api/__init__.py +1 -0
  8. h2ogpte/rest_async/api/agents_api.py +1181 -22
  9. h2ogpte/rest_async/api/configurations_api.py +1005 -136
  10. h2ogpte/rest_async/api/permissions_api.py +296 -0
  11. h2ogpte/rest_async/api/prompt_templates_api.py +1242 -305
  12. h2ogpte/rest_async/api/secrets_api.py +1698 -0
  13. h2ogpte/rest_async/api_client.py +1 -1
  14. h2ogpte/rest_async/configuration.py +1 -1
  15. h2ogpte/rest_async/models/__init__.py +11 -0
  16. h2ogpte/rest_async/models/add_custom_agent_tool201_response_inner.py +87 -0
  17. h2ogpte/rest_async/models/create_agent_tool_request.py +103 -0
  18. h2ogpte/rest_async/models/create_secret201_response.py +87 -0
  19. h2ogpte/rest_async/models/create_secret_request.py +101 -0
  20. h2ogpte/rest_async/models/list_custom_agent_tools200_response_inner.py +95 -0
  21. h2ogpte/rest_async/models/prompt_template.py +10 -2
  22. h2ogpte/rest_async/models/role_info.py +5 -3
  23. h2ogpte/rest_async/models/set_role_priority_request.py +87 -0
  24. h2ogpte/rest_async/models/update_custom_agent_tool200_response.py +87 -0
  25. h2ogpte/rest_async/models/update_custom_agent_tool_request.py +87 -0
  26. h2ogpte/rest_async/models/update_default_prompt_template_visibility_request.py +87 -0
  27. h2ogpte/rest_async/models/update_prompt_template_privacy_request.py +87 -0
  28. h2ogpte/rest_async/models/update_secret_request.py +87 -0
  29. h2ogpte/rest_sync/__init__.py +13 -1
  30. h2ogpte/rest_sync/api/__init__.py +1 -0
  31. h2ogpte/rest_sync/api/agents_api.py +1181 -22
  32. h2ogpte/rest_sync/api/configurations_api.py +1005 -136
  33. h2ogpte/rest_sync/api/permissions_api.py +296 -0
  34. h2ogpte/rest_sync/api/prompt_templates_api.py +1242 -305
  35. h2ogpte/rest_sync/api/secrets_api.py +1698 -0
  36. h2ogpte/rest_sync/api_client.py +1 -1
  37. h2ogpte/rest_sync/configuration.py +1 -1
  38. h2ogpte/rest_sync/models/__init__.py +11 -0
  39. h2ogpte/rest_sync/models/add_custom_agent_tool201_response_inner.py +87 -0
  40. h2ogpte/rest_sync/models/create_agent_tool_request.py +103 -0
  41. h2ogpte/rest_sync/models/create_secret201_response.py +87 -0
  42. h2ogpte/rest_sync/models/create_secret_request.py +101 -0
  43. h2ogpte/rest_sync/models/list_custom_agent_tools200_response_inner.py +95 -0
  44. h2ogpte/rest_sync/models/prompt_template.py +10 -2
  45. h2ogpte/rest_sync/models/role_info.py +5 -3
  46. h2ogpte/rest_sync/models/set_role_priority_request.py +87 -0
  47. h2ogpte/rest_sync/models/update_custom_agent_tool200_response.py +87 -0
  48. h2ogpte/rest_sync/models/update_custom_agent_tool_request.py +87 -0
  49. h2ogpte/rest_sync/models/update_default_prompt_template_visibility_request.py +87 -0
  50. h2ogpte/rest_sync/models/update_prompt_template_privacy_request.py +87 -0
  51. h2ogpte/rest_sync/models/update_secret_request.py +87 -0
  52. h2ogpte/session.py +1 -3
  53. h2ogpte/types.py +10 -4
  54. {h2ogpte-1.6.39.dist-info → h2ogpte-1.6.40rc2.dist-info}/METADATA +1 -1
  55. {h2ogpte-1.6.39.dist-info → h2ogpte-1.6.40rc2.dist-info}/RECORD +57 -33
  56. {h2ogpte-1.6.39.dist-info → h2ogpte-1.6.40rc2.dist-info}/WHEEL +0 -0
  57. {h2ogpte-1.6.39.dist-info → h2ogpte-1.6.40rc2.dist-info}/top_level.txt +0 -0
h2ogpte/__init__.py CHANGED
@@ -3,7 +3,7 @@ from h2ogpte.h2ogpte import H2OGPTE
3
3
  from h2ogpte.h2ogpte_async import H2OGPTEAsync
4
4
  from h2ogpte.session_async import SessionAsync
5
5
 
6
- __version__ = "1.6.39"
6
+ __version__ = "1.6.40rc2"
7
7
 
8
8
  __all__ = [
9
9
  "H2OGPTE",
h2ogpte/errors.py CHANGED
@@ -37,6 +37,10 @@ class InternalServerError(H2OGPTEError):
37
37
  pass
38
38
 
39
39
 
40
+ class NotImplementedError(H2OGPTEError):
41
+ pass
42
+
43
+
40
44
  class FailedError(H2OGPTEError):
41
45
  pass
42
46
 
h2ogpte/h2ogpte.py CHANGED
@@ -2286,6 +2286,111 @@ class H2OGPTE(H2OGPTESyncBase):
2286
2286
  )
2287
2287
  return self._wait_for_completion(response.id, timeout=timeout)
2288
2288
 
2289
+ def list_secret_ids(self, connector_type: Optional[str] = None) -> List[str]:
2290
+ """
2291
+ List available secret IDs from the SecureStore for cloud storage connectors.
2292
+
2293
+ Args:
2294
+ connector_type: Type of connector ('s3', 'gcs', 'azure_key', 'azure_sas')
2295
+ If None, returns secrets for all connector types.
2296
+
2297
+ Returns:
2298
+ List of secret IDs available for the specified connector type
2299
+ """
2300
+ self._init_rest()
2301
+ header = self._get_auth_header()
2302
+ response = _rest_to_client_exceptions(
2303
+ lambda: self._secrets_api.list_secret_ids(
2304
+ connector_type=connector_type, _headers=header
2305
+ )
2306
+ )
2307
+ return response.ids
2308
+
2309
+ def get_secret(self, secret_id: str) -> Union[Dict[str, Any], None]:
2310
+ """Get a secret from the SecureStore by its ID.
2311
+
2312
+ Args:
2313
+ secret_id: The ID of the secret to retrieve.
2314
+
2315
+ Returns:
2316
+ The secret object corresponding to the provided ID.
2317
+ """
2318
+ self._init_rest()
2319
+ header = self._get_auth_header()
2320
+ response = _rest_to_client_exceptions(
2321
+ lambda: self._secrets_api.get_secret(secret_id=secret_id, _headers=header)
2322
+ )
2323
+ return response.to_dict()
2324
+
2325
+ def get_secret_value(self, secret_id: str) -> Union[str, None]:
2326
+ """Get the value of a secret from the SecureStore by its ID.
2327
+
2328
+ Args:
2329
+ secret_id: The ID of the secret to retrieve.
2330
+
2331
+ Returns:
2332
+ The value of the secret corresponding to the provided ID.
2333
+ """
2334
+ self._init_rest()
2335
+ header = self._get_auth_header()
2336
+ response = _rest_to_client_exceptions(
2337
+ lambda: self._secrets_api.get_secret_value(
2338
+ secret_id=secret_id, _headers=header
2339
+ )
2340
+ )
2341
+ return response.value if response else None
2342
+
2343
+ def create_secret(self, secret: Dict[str, Any]) -> None:
2344
+ """Create a new secret in the SecureStore.
2345
+
2346
+ Args:
2347
+ secret: A dictionary containing the secret data to be stored.
2348
+
2349
+ Returns:
2350
+ The ID of the newly created secret.
2351
+ """
2352
+ self._init_rest()
2353
+ header = self._get_auth_header()
2354
+ response = _rest_to_client_exceptions(
2355
+ lambda: self._secrets_api.create_secret(secret=secret, _headers=header)
2356
+ )
2357
+ return response.id
2358
+
2359
+ def update_secret(self, secret_id: str, secret: Dict[str, Any]) -> None:
2360
+ """Update an existing secret in the SecureStore.
2361
+
2362
+ Args:
2363
+ secret_id: The ID of the secret to update.
2364
+ secret: A dictionary containing the updated secret data.
2365
+
2366
+ Returns:
2367
+ None
2368
+ """
2369
+ self._init_rest()
2370
+ header = self._get_auth_header()
2371
+ _rest_to_client_exceptions(
2372
+ lambda: self._secrets_api.update_secret(
2373
+ secret_id=secret_id, secret=secret, _headers=header
2374
+ )
2375
+ )
2376
+
2377
+ def delete_secret(self, secret_id: str) -> None:
2378
+ """Delete a secret from the SecureStore by its ID.
2379
+
2380
+ Args:
2381
+ secret_id: The ID of the secret to delete.
2382
+
2383
+ Returns:
2384
+ None
2385
+ """
2386
+ self._init_rest()
2387
+ header = self._get_auth_header()
2388
+ _rest_to_client_exceptions(
2389
+ lambda: self._secrets_api.delete_secret(
2390
+ secret_id=secret_id, _headers=header
2391
+ )
2392
+ )
2393
+
2289
2394
  def ingest_uploads(
2290
2395
  self,
2291
2396
  collection_id: str,
@@ -4278,6 +4383,78 @@ class H2OGPTE(H2OGPTESyncBase):
4278
4383
  )
4279
4384
  return [PromptTemplate(**d.to_dict()) for d in response]
4280
4385
 
4386
+ def list_all_recent_prompt_templates(
4387
+ self, offset: int, limit: int
4388
+ ) -> List[PromptTemplate]:
4389
+ """Fetch user's prompt templates sorted by last update time.
4390
+
4391
+ Note: Users with permission to manage prompt templates can use this to list hidden default prompt templates.
4392
+
4393
+ Args:
4394
+ offset:
4395
+ How many prompt templates to skip before returning.
4396
+ limit:
4397
+ How many prompt templates to return.
4398
+
4399
+ Returns:
4400
+ list of PromptTemplate: set of prompts
4401
+ """
4402
+ header = self._get_auth_header()
4403
+ with self._RESTClient(self) as rest_client:
4404
+ response = _rest_to_client_exceptions(
4405
+ lambda: rest_client.prompt_template_api.list_all_prompt_templates(
4406
+ offset=offset,
4407
+ limit=limit,
4408
+ _headers=header,
4409
+ )
4410
+ )
4411
+ return [PromptTemplate(**d.to_dict()) for d in response]
4412
+
4413
+ def list_all_recent_prompt_templates_sort(
4414
+ self,
4415
+ offset: int,
4416
+ limit: int,
4417
+ sort_column: str,
4418
+ ascending: bool,
4419
+ template_type: str = "all",
4420
+ filter: str = "",
4421
+ ) -> List[PromptTemplate]:
4422
+ """Fetch user's prompt templates sorted by last update time.
4423
+
4424
+ Note: Users with permission to manage prompt templates can use this to list hidden default prompt templates.
4425
+
4426
+ Args:
4427
+ offset:
4428
+ How many prompt templates to skip before returning.
4429
+ limit:
4430
+ How many prompt templates to return.
4431
+ sort_column:
4432
+ Sort column.
4433
+ ascending:
4434
+ When True, return sorted by sort_column in ascending order.
4435
+ template_type:
4436
+ When set, will be used as a type filter, possible values are: all, user, system.
4437
+ filter:
4438
+ When set, will be used as a filter on some prompt template columns.
4439
+
4440
+ Returns:
4441
+ list of PromptTemplate: set of prompts
4442
+ """
4443
+ header = self._get_auth_header()
4444
+ with self._RESTClient(self) as rest_client:
4445
+ response = _rest_to_client_exceptions(
4446
+ lambda: rest_client.prompt_template_api.list_all_prompt_templates(
4447
+ offset=offset,
4448
+ limit=limit,
4449
+ sort_column=sort_column,
4450
+ ascending=ascending,
4451
+ template_type=template_type,
4452
+ filter=filter,
4453
+ _headers=header,
4454
+ )
4455
+ )
4456
+ return [PromptTemplate(**d.to_dict()) for d in response]
4457
+
4281
4458
  def get_prompt_template(self, id: Optional[str] = None) -> PromptTemplate:
4282
4459
  """Get a prompt template
4283
4460
 
@@ -4745,6 +4922,49 @@ class H2OGPTE(H2OGPTESyncBase):
4745
4922
  )
4746
4923
  return result
4747
4924
 
4925
+ def make_prompt_template_public(self, prompt_template_id: str):
4926
+ """Make a prompt template public
4927
+
4928
+ Once a prompt template is public, it can be seen and used by all users.
4929
+
4930
+ Args:
4931
+ prompt_template_id:
4932
+ ID of the prompt template to make public.
4933
+ """
4934
+ header = self._get_auth_header()
4935
+ with self._RESTClient(self) as rest_client:
4936
+ _rest_to_client_exceptions(
4937
+ lambda: rest_client.prompt_template_api.update_prompt_template_privacy(
4938
+ prompt_template_id=prompt_template_id,
4939
+ update_prompt_template_privacy_request=rest.UpdatePromptTemplatePrivacyRequest(
4940
+ is_public=True
4941
+ ),
4942
+ _headers=header,
4943
+ )
4944
+ )
4945
+
4946
+ def make_prompt_template_private(self, prompt_template_id: str):
4947
+ """Make a prompt template private
4948
+
4949
+ Once a prompt template is private, other users will no longer
4950
+ be able to see or use it unless it has been shared individually or by group.
4951
+
4952
+ Args:
4953
+ prompt_template_id:
4954
+ ID of the prompt template to make private.
4955
+ """
4956
+ header = self._get_auth_header()
4957
+ with self._RESTClient(self) as rest_client:
4958
+ _rest_to_client_exceptions(
4959
+ lambda: rest_client.prompt_template_api.update_prompt_template_privacy(
4960
+ prompt_template_id=prompt_template_id,
4961
+ update_prompt_template_privacy_request=rest.UpdatePromptTemplatePrivacyRequest(
4962
+ is_public=False
4963
+ ),
4964
+ _headers=header,
4965
+ )
4966
+ )
4967
+
4748
4968
  def list_prompt_permissions(self, prompt_id: str) -> List[SharePermission]:
4749
4969
  """Returns a list of access permissions for a given prompt template.
4750
4970
 
@@ -4791,6 +5011,32 @@ class H2OGPTE(H2OGPTESyncBase):
4791
5011
  )
4792
5012
  return [GroupSharePermission(**d.to_dict()) for d in response]
4793
5013
 
5014
+ def set_default_prompt_template_visibility(self, prompt_id: str, is_visible: bool):
5015
+ """
5016
+ Updates a flag specifying whether a default prompt template is visible or hidden to users.
5017
+
5018
+ Once you hide a default prompt template, users will no longer be able to use this prompt template.
5019
+ This will also affect collections and chats that have this as a default prompt template.
5020
+ Once you show a default prompt template, all users will be able to see and use this prompt template.
5021
+
5022
+ Args:
5023
+ prompt_id:
5024
+ ID of the default prompt template you would like to change the visibility of.
5025
+ is_visible:
5026
+ Whether the default prompt template should be visible.
5027
+ """
5028
+ header = self._get_auth_header()
5029
+ with self._RESTClient(self) as rest_client:
5030
+ _rest_to_client_exceptions(
5031
+ lambda: rest_client.prompt_template_api.update_default_prompt_template_visibility(
5032
+ prompt_template_id=prompt_id,
5033
+ update_default_prompt_template_visibility_request=rest.UpdateDefaultPromptTemplateVisibilityRequest(
5034
+ is_visible=is_visible
5035
+ ),
5036
+ _headers=header,
5037
+ )
5038
+ )
5039
+
4794
5040
  def set_collection_prompt_template(
4795
5041
  self,
4796
5042
  collection_id: str,
@@ -5511,7 +5757,7 @@ class H2OGPTE(H2OGPTESyncBase):
5511
5757
  can_overwrite: bool,
5512
5758
  is_public: bool,
5513
5759
  value_type: str = None,
5514
- ) -> List[ConfigItem]:
5760
+ ) -> List[GlobalConfigItem]:
5515
5761
  """Set a global configuration.
5516
5762
 
5517
5763
  Note: Both default collection size limit and inactivity interval can be disabled. To do so, pass '-1' as the string_value.
@@ -5529,7 +5775,7 @@ class H2OGPTE(H2OGPTESyncBase):
5529
5775
  The type of the value to be set for the global config.
5530
5776
 
5531
5777
  Returns:
5532
- List[ConfigItem]: List of global configurations.
5778
+ List[GlobalConfigItem]: List of global configurations.
5533
5779
  """
5534
5780
  header = self._get_auth_header()
5535
5781
  with self._RESTClient(self) as rest_client:
@@ -5545,9 +5791,9 @@ class H2OGPTE(H2OGPTESyncBase):
5545
5791
  _headers=header,
5546
5792
  )
5547
5793
  )
5548
- return [ConfigItem(**c.to_dict()) for c in response]
5794
+ return [GlobalConfigItem(**c.to_dict()) for c in response]
5549
5795
 
5550
- def get_global_configurations_by_admin(self) -> List[ConfigItem]:
5796
+ def get_global_configurations_by_admin(self) -> List[GlobalConfigItem]:
5551
5797
  header = self._get_auth_header()
5552
5798
  with self._RESTClient(self) as rest_client:
5553
5799
  response = _rest_to_client_exceptions(
@@ -5556,9 +5802,9 @@ class H2OGPTE(H2OGPTESyncBase):
5556
5802
  _headers=header,
5557
5803
  )
5558
5804
  )
5559
- return [ConfigItem(**c.to_dict()) for c in response]
5805
+ return [GlobalConfigItem(**c.to_dict()) for c in response]
5560
5806
 
5561
- def get_global_configurations(self) -> List[ConfigItem]:
5807
+ def get_global_configurations(self) -> List[GlobalConfigItem]:
5562
5808
  header = self._get_auth_header()
5563
5809
  with self._RESTClient(self) as rest_client:
5564
5810
  response = _rest_to_client_exceptions(
@@ -5567,11 +5813,11 @@ class H2OGPTE(H2OGPTESyncBase):
5567
5813
  _headers=header,
5568
5814
  )
5569
5815
  )
5570
- return [ConfigItem(**c.to_dict()) for c in response]
5816
+ return [GlobalConfigItem(**c.to_dict()) for c in response]
5571
5817
 
5572
5818
  def bulk_delete_global_configurations(
5573
5819
  self, key_names: List[str]
5574
- ) -> List[ConfigItem]:
5820
+ ) -> List[GlobalConfigItem]:
5575
5821
  header = self._get_auth_header()
5576
5822
  with self._RESTClient(self) as rest_client:
5577
5823
  response = _rest_to_client_exceptions(
@@ -5580,11 +5826,11 @@ class H2OGPTE(H2OGPTESyncBase):
5580
5826
  _headers=header,
5581
5827
  )
5582
5828
  )
5583
- return [ConfigItem(**c.to_dict()) for c in response]
5829
+ return [GlobalConfigItem(**c.to_dict()) for c in response]
5584
5830
 
5585
5831
  def set_user_configuration_for_user(
5586
5832
  self, key_name: str, string_value: str, user_id: str, value_type: str = None
5587
- ) -> List[UserConfigItem]:
5833
+ ) -> List[ConfigItem]:
5588
5834
  """Set a user configuration for a specific user (overrides the global configuration and to be used by admins only).
5589
5835
 
5590
5836
  Note: Both default collection size limit and inactivity interval can be disabled. To do so, pass '-1' as the string_value.
@@ -5600,7 +5846,7 @@ class H2OGPTE(H2OGPTESyncBase):
5600
5846
  The type of the value to be set for the config.
5601
5847
 
5602
5848
  Returns:
5603
- List[UserConfigItem]: List of user configurations.
5849
+ List[ConfigItem]: List of user configurations.
5604
5850
  """
5605
5851
  header = self._get_auth_header()
5606
5852
  with self._RESTClient(self) as rest_client:
@@ -5615,9 +5861,9 @@ class H2OGPTE(H2OGPTESyncBase):
5615
5861
  _headers=header,
5616
5862
  )
5617
5863
  )
5618
- return [UserConfigItem(**c.to_dict()) for c in response]
5864
+ return [ConfigItem(**c.to_dict()) for c in response]
5619
5865
 
5620
- def get_user_configurations_for_user(self, user_id: str) -> List[UserConfigItem]:
5866
+ def get_user_configurations_for_user(self, user_id: str) -> List[ConfigItem]:
5621
5867
  """Gets the user configurations for a specific user (to be used by admins only).
5622
5868
 
5623
5869
  Args:
@@ -5625,7 +5871,7 @@ class H2OGPTE(H2OGPTESyncBase):
5625
5871
  The unique identifier of the user.
5626
5872
 
5627
5873
  Returns:
5628
- List[UserConfigItem]: List of user configurations.
5874
+ List[ConfigItem]: List of user configurations.
5629
5875
  """
5630
5876
  header = self._get_auth_header()
5631
5877
  with self._RESTClient(self) as rest_client:
@@ -5635,13 +5881,13 @@ class H2OGPTE(H2OGPTESyncBase):
5635
5881
  _headers=header,
5636
5882
  )
5637
5883
  )
5638
- return [UserConfigItem(**c.to_dict()) for c in response]
5884
+ return [ConfigItem(**c.to_dict()) for c in response]
5639
5885
 
5640
- def get_user_configurations(self) -> List[UserConfigItem]:
5886
+ def get_user_configurations(self) -> List[ConfigItem]:
5641
5887
  """Gets the user configurations for the current user.
5642
5888
 
5643
5889
  Returns:
5644
- List[UserConfigItem]: List of user configurations.
5890
+ List[ConfigItem]: List of user configurations.
5645
5891
  """
5646
5892
  header = self._get_auth_header()
5647
5893
  with self._RESTClient(self) as rest_client:
@@ -5650,11 +5896,11 @@ class H2OGPTE(H2OGPTESyncBase):
5650
5896
  _headers=header
5651
5897
  )
5652
5898
  )
5653
- return [UserConfigItem(**c.to_dict()) for c in response]
5899
+ return [ConfigItem(**c.to_dict()) for c in response]
5654
5900
 
5655
5901
  def bulk_delete_user_configurations_for_user(
5656
5902
  self, user_id: str, key_names: List[str]
5657
- ) -> List[UserConfigItem]:
5903
+ ) -> List[ConfigItem]:
5658
5904
  header = self._get_auth_header()
5659
5905
  with self._RESTClient(self) as rest_client:
5660
5906
  response = _rest_to_client_exceptions(
@@ -5664,15 +5910,15 @@ class H2OGPTE(H2OGPTESyncBase):
5664
5910
  _headers=header,
5665
5911
  )
5666
5912
  )
5667
- return [UserConfigItem(**c.to_dict()) for c in response]
5913
+ return [ConfigItem(**c.to_dict()) for c in response]
5668
5914
 
5669
5915
  def reset_user_configurations_for_user(
5670
5916
  self, key_name: str, user_id: str
5671
- ) -> List[UserConfigItem]:
5917
+ ) -> List[ConfigItem]:
5672
5918
  """Reset a user configuration for a specific user (to be used by admins only).
5673
5919
 
5674
5920
  Returns:
5675
- List[UserConfigItem]: List of user configurations.
5921
+ List[ConfigItem]: List of user configurations.
5676
5922
  """
5677
5923
  header = self._get_auth_header()
5678
5924
  with self._RESTClient(self) as rest_client:
@@ -5683,7 +5929,7 @@ class H2OGPTE(H2OGPTESyncBase):
5683
5929
  _headers=header,
5684
5930
  )
5685
5931
  )
5686
- return [UserConfigItem(**c.to_dict()) for c in response]
5932
+ return [ConfigItem(**c.to_dict()) for c in response]
5687
5933
 
5688
5934
  def delete_agent_directories(self, chat_session_id: str) -> bool:
5689
5935
  header = self._get_auth_header()
@@ -5698,6 +5944,82 @@ class H2OGPTE(H2OGPTESyncBase):
5698
5944
  )
5699
5945
  return result.status == "completed"
5700
5946
 
5947
+ def set_role_configuration(
5948
+ self, key_name: str, role_id: str, string_value: str, value_type: str = None
5949
+ ) -> List[ConfigItem]:
5950
+ """Set a role configuration, overrides the global configuration.
5951
+ Args:
5952
+ role_id:
5953
+ The role id you want to apply the config for.
5954
+ key_name:
5955
+ The name of the global config key.
5956
+ string_value:
5957
+ The value to be set for the config.
5958
+ value_type:
5959
+ The type of the value to be set for the config.
5960
+
5961
+ Returns:
5962
+ List[ConfigItem]: List of role configurations.
5963
+ """
5964
+ header = self._get_auth_header()
5965
+ with self._RESTClient(self) as rest_client:
5966
+ response = _rest_to_client_exceptions(
5967
+ lambda: rest_client.configuration_api.set_role_configuration(
5968
+ key_name=key_name,
5969
+ role_id=role_id,
5970
+ user_configuration_item=rest.UserConfigurationItem(
5971
+ key_name=key_name,
5972
+ string_value=string_value,
5973
+ value_type=value_type,
5974
+ ),
5975
+ _headers=header,
5976
+ )
5977
+ )
5978
+ return [ConfigItem(**c.to_dict()) for c in response]
5979
+
5980
+ def list_role_configurations(self, role_id: str) -> List[ConfigItem]:
5981
+ """Lists role configurations for a given role.
5982
+ Args:
5983
+ role_id:
5984
+ The role id to get configurations for.
5985
+
5986
+ Returns:
5987
+ List[ConfigItem]: List of role configurations.
5988
+ """
5989
+ header = self._get_auth_header()
5990
+ with self._RESTClient(self) as rest_client:
5991
+ response = _rest_to_client_exceptions(
5992
+ lambda: rest_client.configuration_api.list_role_configurations(
5993
+ role_id=role_id,
5994
+ _headers=header,
5995
+ )
5996
+ )
5997
+ return [ConfigItem(**c.to_dict()) for c in response]
5998
+
5999
+ def bulk_delete_role_configurations(
6000
+ self, role_id: str, keys: List[str]
6001
+ ) -> List[ConfigItem]:
6002
+ """Delete role configuration items for a given role.
6003
+ Args:
6004
+ role_id:
6005
+ The role id to delete configurations for.
6006
+ keys:
6007
+ List of configuration keys to delete.
6008
+
6009
+ Returns:
6010
+ List[ConfigItem]: List of remaining role configurations.
6011
+ """
6012
+ header = self._get_auth_header()
6013
+ with self._RESTClient(self) as rest_client:
6014
+ response = _rest_to_client_exceptions(
6015
+ lambda: rest_client.configuration_api.delete_role_configurations(
6016
+ key_names=keys,
6017
+ role_id=role_id,
6018
+ _headers=header,
6019
+ )
6020
+ )
6021
+ return [ConfigItem(**c.to_dict()) for c in response]
6022
+
5701
6023
  def delete_multiple_agent_directories(
5702
6024
  self, chat_session_ids: List[str], dir_types: List[str]
5703
6025
  ) -> bool:
@@ -6077,3 +6399,101 @@ class H2OGPTE(H2OGPTESyncBase):
6077
6399
  )
6078
6400
  )
6079
6401
  return response.count
6402
+
6403
+ def add_custom_agent_tool(
6404
+ self, tool_type: str, tool_args: dict, custom_tool_path: Optional[str] = None
6405
+ ) -> list:
6406
+ header = self._get_auth_header()
6407
+ custom_tool_path = str(custom_tool_path) if custom_tool_path else None
6408
+ with self._RESTClient(self) as rest_client:
6409
+ response = _rest_to_client_exceptions(
6410
+ lambda: rest_client.agent_api.add_custom_agent_tool(
6411
+ file=custom_tool_path,
6412
+ tool_type=tool_type,
6413
+ tool_args=json.dumps(tool_args),
6414
+ custom_tool_path=custom_tool_path,
6415
+ filename=os.path.basename(custom_tool_path)
6416
+ if custom_tool_path
6417
+ else None,
6418
+ _headers=header,
6419
+ )
6420
+ )
6421
+ return [obj.agent_custom_tool_id for obj in response]
6422
+
6423
+ def delete_custom_agent_tool(self, tool_ids: List[str]) -> int:
6424
+ header = self._get_auth_header()
6425
+ with self._RESTClient(self) as rest_client:
6426
+ response = _rest_to_client_exceptions(
6427
+ lambda: rest_client.agent_api.delete_custom_agent_tool(
6428
+ tool_ids=tool_ids,
6429
+ _headers=header,
6430
+ )
6431
+ )
6432
+ return response.count
6433
+
6434
+ def update_custom_agent_tool(
6435
+ self,
6436
+ tool_id: str,
6437
+ tool_args: dict,
6438
+ ) -> str:
6439
+ """Updates a custom agent tool's arguments.
6440
+
6441
+ Args:
6442
+ tool_id: The ID of the tool to update
6443
+ tool_args: New tool arguments
6444
+
6445
+ Returns:
6446
+ The updated tool ID
6447
+ """
6448
+ header = self._get_auth_header()
6449
+
6450
+ # Build request body with only tool_args
6451
+ request_obj = rest.UpdateCustomAgentToolRequest(tool_args=tool_args)
6452
+
6453
+ with self._RESTClient(self) as rest_client:
6454
+ response = _rest_to_client_exceptions(
6455
+ lambda: rest_client.agent_api.update_custom_agent_tool(
6456
+ tool_id=tool_id,
6457
+ update_custom_agent_tool_request=request_obj,
6458
+ _headers=header,
6459
+ )
6460
+ )
6461
+ return response.agent_custom_tool_id
6462
+
6463
+ def get_custom_agent_tools(self) -> List[dict]:
6464
+ """Gets all custom agent tools for the current user.
6465
+
6466
+ Returns:
6467
+ List[dict]: A list of custom agent tools with their details.
6468
+ Each tool contains: id, tool_name, tool_type, tool_args, owner_email
6469
+ """
6470
+ header = self._get_auth_header()
6471
+ with self._RESTClient(self) as rest_client:
6472
+ response = _rest_to_client_exceptions(
6473
+ lambda: rest_client.agent_api.list_custom_agent_tools(_headers=header)
6474
+ )
6475
+ return response
6476
+
6477
+ def set_role_priority(self, role_id: str, priority: int) -> UserRole:
6478
+ """Sets the priority for a role.
6479
+ Args:
6480
+ role_id:
6481
+ String: The id of the role to set the priority for.
6482
+ priority:
6483
+ Int: The priority value to set for the role. ex: 100, 200, 300...etc.
6484
+ The lower the number, the higher the priority.
6485
+ Returns:
6486
+ UserRole: The updated user role with the new priority.
6487
+ """
6488
+ header = self._get_auth_header()
6489
+ with self._RESTClient(self) as rest_client:
6490
+ response = _rest_to_client_exceptions(
6491
+ lambda: rest_client.permission_api.set_role_priority(
6492
+ role_id=role_id,
6493
+ set_role_priority_request=rest.SetRolePriorityRequest(
6494
+ priority=priority
6495
+ ),
6496
+ _headers=header,
6497
+ )
6498
+ )
6499
+ return UserRole(**response.to_dict())