h2ogpte 1.6.38rc2__py3-none-any.whl → 1.6.39__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 (34) hide show
  1. h2ogpte/__init__.py +1 -1
  2. h2ogpte/errors.py +0 -4
  3. h2ogpte/h2ogpte.py +71 -264
  4. h2ogpte/h2ogpte_async.py +75 -271
  5. h2ogpte/h2ogpte_sync_base.py +0 -3
  6. h2ogpte/rest_async/__init__.py +3 -4
  7. h2ogpte/rest_async/api/configurations_api.py +137 -1006
  8. h2ogpte/rest_async/api/permissions_api.py +429 -177
  9. h2ogpte/rest_async/api/prompt_templates_api.py +303 -1240
  10. h2ogpte/rest_async/api_client.py +1 -1
  11. h2ogpte/rest_async/configuration.py +1 -1
  12. h2ogpte/rest_async/models/__init__.py +2 -3
  13. h2ogpte/{rest_sync/models/set_role_priority_request.py → rest_async/models/confirm_user_deletion_request.py} +8 -8
  14. h2ogpte/rest_async/models/prompt_template.py +2 -8
  15. h2ogpte/rest_async/models/role_info.py +3 -5
  16. h2ogpte/{rest_sync/models/update_prompt_template_privacy_request.py → rest_async/models/user_deletion_request.py} +8 -8
  17. h2ogpte/rest_sync/__init__.py +3 -4
  18. h2ogpte/rest_sync/api/configurations_api.py +137 -1006
  19. h2ogpte/rest_sync/api/permissions_api.py +429 -177
  20. h2ogpte/rest_sync/api/prompt_templates_api.py +303 -1240
  21. h2ogpte/rest_sync/api_client.py +1 -1
  22. h2ogpte/rest_sync/configuration.py +1 -1
  23. h2ogpte/rest_sync/models/__init__.py +2 -3
  24. h2ogpte/{rest_async/models/set_role_priority_request.py → rest_sync/models/confirm_user_deletion_request.py} +8 -8
  25. h2ogpte/rest_sync/models/prompt_template.py +2 -8
  26. h2ogpte/rest_sync/models/role_info.py +3 -5
  27. h2ogpte/{rest_async/models/update_prompt_template_privacy_request.py → rest_sync/models/user_deletion_request.py} +8 -8
  28. h2ogpte/types.py +4 -10
  29. {h2ogpte-1.6.38rc2.dist-info → h2ogpte-1.6.39.dist-info}/METADATA +1 -1
  30. {h2ogpte-1.6.38rc2.dist-info → h2ogpte-1.6.39.dist-info}/RECORD +32 -34
  31. h2ogpte/rest_async/models/update_default_prompt_template_visibility_request.py +0 -87
  32. h2ogpte/rest_sync/models/update_default_prompt_template_visibility_request.py +0 -87
  33. {h2ogpte-1.6.38rc2.dist-info → h2ogpte-1.6.39.dist-info}/WHEEL +0 -0
  34. {h2ogpte-1.6.38rc2.dist-info → h2ogpte-1.6.39.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.38rc2"
6
+ __version__ = "1.6.39"
7
7
 
8
8
  __all__ = [
9
9
  "H2OGPTE",
h2ogpte/errors.py CHANGED
@@ -37,10 +37,6 @@ class InternalServerError(H2OGPTEError):
37
37
  pass
38
38
 
39
39
 
40
- class NotImplementedError(H2OGPTEError):
41
- pass
42
-
43
-
44
40
  class FailedError(H2OGPTEError):
45
41
  pass
46
42
 
h2ogpte/h2ogpte.py CHANGED
@@ -3230,6 +3230,54 @@ class H2OGPTE(H2OGPTESyncBase):
3230
3230
  )
3231
3231
  return [User(**d.to_dict()) for d in response]
3232
3232
 
3233
+ def request_current_user_deletion(
3234
+ self,
3235
+ ) -> str:
3236
+ """Request deletion of the current user account.
3237
+
3238
+ This creates a deletion request and returns a delete ID that must be used
3239
+ to confirm the deletion within 5 minutes.
3240
+
3241
+ Returns:
3242
+ str: Delete ID that must be used to confirm deletion.
3243
+ """
3244
+ header = self._get_auth_header()
3245
+ with self._RESTClient(self) as rest_client:
3246
+ response = _rest_to_client_exceptions(
3247
+ lambda: rest_client.permission_api.request_current_user_deletion(
3248
+ _headers=header,
3249
+ )
3250
+ )
3251
+ return response.delete_id
3252
+
3253
+ def confirm_current_user_deletion(
3254
+ self,
3255
+ delete_id: str,
3256
+ timeout: Union[float, None] = None,
3257
+ ) -> None:
3258
+ """Confirm deletion of the current user data.
3259
+
3260
+ Args:
3261
+ delete_id:
3262
+ The delete ID returned from request_current_user_deletion().
3263
+ timeout:
3264
+ Timeout in seconds. Default is 300 seconds.
3265
+ """
3266
+ header = self._get_auth_header()
3267
+ if timeout is None:
3268
+ timeout = 300.0
3269
+
3270
+ with self._RESTClient(self) as rest_client:
3271
+ _rest_to_client_exceptions(
3272
+ lambda: rest_client.permission_api.confirm_current_user_deletion(
3273
+ confirm_user_deletion_request=rest.ConfirmUserDeletionRequest(
3274
+ delete_id=delete_id,
3275
+ ),
3276
+ timeout=timeout,
3277
+ _headers=header,
3278
+ )
3279
+ )
3280
+
3233
3281
  def share_collection(
3234
3282
  self, collection_id: str, permission: SharePermission
3235
3283
  ) -> ShareResponseStatus:
@@ -4230,78 +4278,6 @@ class H2OGPTE(H2OGPTESyncBase):
4230
4278
  )
4231
4279
  return [PromptTemplate(**d.to_dict()) for d in response]
4232
4280
 
4233
- def list_all_recent_prompt_templates(
4234
- self, offset: int, limit: int
4235
- ) -> List[PromptTemplate]:
4236
- """Fetch user's prompt templates sorted by last update time.
4237
-
4238
- Note: Users with permission to manage prompt templates can use this to list hidden default prompt templates.
4239
-
4240
- Args:
4241
- offset:
4242
- How many prompt templates to skip before returning.
4243
- limit:
4244
- How many prompt templates to return.
4245
-
4246
- Returns:
4247
- list of PromptTemplate: set of prompts
4248
- """
4249
- header = self._get_auth_header()
4250
- with self._RESTClient(self) as rest_client:
4251
- response = _rest_to_client_exceptions(
4252
- lambda: rest_client.prompt_template_api.list_all_prompt_templates(
4253
- offset=offset,
4254
- limit=limit,
4255
- _headers=header,
4256
- )
4257
- )
4258
- return [PromptTemplate(**d.to_dict()) for d in response]
4259
-
4260
- def list_all_recent_prompt_templates_sort(
4261
- self,
4262
- offset: int,
4263
- limit: int,
4264
- sort_column: str,
4265
- ascending: bool,
4266
- template_type: str = "all",
4267
- filter: str = "",
4268
- ) -> List[PromptTemplate]:
4269
- """Fetch user's prompt templates sorted by last update time.
4270
-
4271
- Note: Users with permission to manage prompt templates can use this to list hidden default prompt templates.
4272
-
4273
- Args:
4274
- offset:
4275
- How many prompt templates to skip before returning.
4276
- limit:
4277
- How many prompt templates to return.
4278
- sort_column:
4279
- Sort column.
4280
- ascending:
4281
- When True, return sorted by sort_column in ascending order.
4282
- template_type:
4283
- When set, will be used as a type filter, possible values are: all, user, system.
4284
- filter:
4285
- When set, will be used as a filter on some prompt template columns.
4286
-
4287
- Returns:
4288
- list of PromptTemplate: set of prompts
4289
- """
4290
- header = self._get_auth_header()
4291
- with self._RESTClient(self) as rest_client:
4292
- response = _rest_to_client_exceptions(
4293
- lambda: rest_client.prompt_template_api.list_all_prompt_templates(
4294
- offset=offset,
4295
- limit=limit,
4296
- sort_column=sort_column,
4297
- ascending=ascending,
4298
- template_type=template_type,
4299
- filter=filter,
4300
- _headers=header,
4301
- )
4302
- )
4303
- return [PromptTemplate(**d.to_dict()) for d in response]
4304
-
4305
4281
  def get_prompt_template(self, id: Optional[str] = None) -> PromptTemplate:
4306
4282
  """Get a prompt template
4307
4283
 
@@ -4769,49 +4745,6 @@ class H2OGPTE(H2OGPTESyncBase):
4769
4745
  )
4770
4746
  return result
4771
4747
 
4772
- def make_prompt_template_public(self, prompt_template_id: str):
4773
- """Make a prompt template public
4774
-
4775
- Once a prompt template is public, it can be seen and used by all users.
4776
-
4777
- Args:
4778
- prompt_template_id:
4779
- ID of the prompt template to make public.
4780
- """
4781
- header = self._get_auth_header()
4782
- with self._RESTClient(self) as rest_client:
4783
- _rest_to_client_exceptions(
4784
- lambda: rest_client.prompt_template_api.update_prompt_template_privacy(
4785
- prompt_template_id=prompt_template_id,
4786
- update_prompt_template_privacy_request=rest.UpdatePromptTemplatePrivacyRequest(
4787
- is_public=True
4788
- ),
4789
- _headers=header,
4790
- )
4791
- )
4792
-
4793
- def make_prompt_template_private(self, prompt_template_id: str):
4794
- """Make a prompt template private
4795
-
4796
- Once a prompt template is private, other users will no longer
4797
- be able to see or use it unless it has been shared individually or by group.
4798
-
4799
- Args:
4800
- prompt_template_id:
4801
- ID of the prompt template to make private.
4802
- """
4803
- header = self._get_auth_header()
4804
- with self._RESTClient(self) as rest_client:
4805
- _rest_to_client_exceptions(
4806
- lambda: rest_client.prompt_template_api.update_prompt_template_privacy(
4807
- prompt_template_id=prompt_template_id,
4808
- update_prompt_template_privacy_request=rest.UpdatePromptTemplatePrivacyRequest(
4809
- is_public=False
4810
- ),
4811
- _headers=header,
4812
- )
4813
- )
4814
-
4815
4748
  def list_prompt_permissions(self, prompt_id: str) -> List[SharePermission]:
4816
4749
  """Returns a list of access permissions for a given prompt template.
4817
4750
 
@@ -4858,32 +4791,6 @@ class H2OGPTE(H2OGPTESyncBase):
4858
4791
  )
4859
4792
  return [GroupSharePermission(**d.to_dict()) for d in response]
4860
4793
 
4861
- def set_default_prompt_template_visibility(self, prompt_id: str, is_visible: bool):
4862
- """
4863
- Updates a flag specifying whether a default prompt template is visible or hidden to users.
4864
-
4865
- Once you hide a default prompt template, users will no longer be able to use this prompt template.
4866
- This will also affect collections and chats that have this as a default prompt template.
4867
- Once you show a default prompt template, all users will be able to see and use this prompt template.
4868
-
4869
- Args:
4870
- prompt_id:
4871
- ID of the default prompt template you would like to change the visibility of.
4872
- is_visible:
4873
- Whether the default prompt template should be visible.
4874
- """
4875
- header = self._get_auth_header()
4876
- with self._RESTClient(self) as rest_client:
4877
- _rest_to_client_exceptions(
4878
- lambda: rest_client.prompt_template_api.update_default_prompt_template_visibility(
4879
- prompt_template_id=prompt_id,
4880
- update_default_prompt_template_visibility_request=rest.UpdateDefaultPromptTemplateVisibilityRequest(
4881
- is_visible=is_visible
4882
- ),
4883
- _headers=header,
4884
- )
4885
- )
4886
-
4887
4794
  def set_collection_prompt_template(
4888
4795
  self,
4889
4796
  collection_id: str,
@@ -5604,7 +5511,7 @@ class H2OGPTE(H2OGPTESyncBase):
5604
5511
  can_overwrite: bool,
5605
5512
  is_public: bool,
5606
5513
  value_type: str = None,
5607
- ) -> List[GlobalConfigItem]:
5514
+ ) -> List[ConfigItem]:
5608
5515
  """Set a global configuration.
5609
5516
 
5610
5517
  Note: Both default collection size limit and inactivity interval can be disabled. To do so, pass '-1' as the string_value.
@@ -5622,7 +5529,7 @@ class H2OGPTE(H2OGPTESyncBase):
5622
5529
  The type of the value to be set for the global config.
5623
5530
 
5624
5531
  Returns:
5625
- List[GlobalConfigItem]: List of global configurations.
5532
+ List[ConfigItem]: List of global configurations.
5626
5533
  """
5627
5534
  header = self._get_auth_header()
5628
5535
  with self._RESTClient(self) as rest_client:
@@ -5638,9 +5545,9 @@ class H2OGPTE(H2OGPTESyncBase):
5638
5545
  _headers=header,
5639
5546
  )
5640
5547
  )
5641
- return [GlobalConfigItem(**c.to_dict()) for c in response]
5548
+ return [ConfigItem(**c.to_dict()) for c in response]
5642
5549
 
5643
- def get_global_configurations_by_admin(self) -> List[GlobalConfigItem]:
5550
+ def get_global_configurations_by_admin(self) -> List[ConfigItem]:
5644
5551
  header = self._get_auth_header()
5645
5552
  with self._RESTClient(self) as rest_client:
5646
5553
  response = _rest_to_client_exceptions(
@@ -5649,9 +5556,9 @@ class H2OGPTE(H2OGPTESyncBase):
5649
5556
  _headers=header,
5650
5557
  )
5651
5558
  )
5652
- return [GlobalConfigItem(**c.to_dict()) for c in response]
5559
+ return [ConfigItem(**c.to_dict()) for c in response]
5653
5560
 
5654
- def get_global_configurations(self) -> List[GlobalConfigItem]:
5561
+ def get_global_configurations(self) -> List[ConfigItem]:
5655
5562
  header = self._get_auth_header()
5656
5563
  with self._RESTClient(self) as rest_client:
5657
5564
  response = _rest_to_client_exceptions(
@@ -5660,11 +5567,11 @@ class H2OGPTE(H2OGPTESyncBase):
5660
5567
  _headers=header,
5661
5568
  )
5662
5569
  )
5663
- return [GlobalConfigItem(**c.to_dict()) for c in response]
5570
+ return [ConfigItem(**c.to_dict()) for c in response]
5664
5571
 
5665
5572
  def bulk_delete_global_configurations(
5666
5573
  self, key_names: List[str]
5667
- ) -> List[GlobalConfigItem]:
5574
+ ) -> List[ConfigItem]:
5668
5575
  header = self._get_auth_header()
5669
5576
  with self._RESTClient(self) as rest_client:
5670
5577
  response = _rest_to_client_exceptions(
@@ -5673,11 +5580,11 @@ class H2OGPTE(H2OGPTESyncBase):
5673
5580
  _headers=header,
5674
5581
  )
5675
5582
  )
5676
- return [GlobalConfigItem(**c.to_dict()) for c in response]
5583
+ return [ConfigItem(**c.to_dict()) for c in response]
5677
5584
 
5678
5585
  def set_user_configuration_for_user(
5679
5586
  self, key_name: str, string_value: str, user_id: str, value_type: str = None
5680
- ) -> List[ConfigItem]:
5587
+ ) -> List[UserConfigItem]:
5681
5588
  """Set a user configuration for a specific user (overrides the global configuration and to be used by admins only).
5682
5589
 
5683
5590
  Note: Both default collection size limit and inactivity interval can be disabled. To do so, pass '-1' as the string_value.
@@ -5693,7 +5600,7 @@ class H2OGPTE(H2OGPTESyncBase):
5693
5600
  The type of the value to be set for the config.
5694
5601
 
5695
5602
  Returns:
5696
- List[ConfigItem]: List of user configurations.
5603
+ List[UserConfigItem]: List of user configurations.
5697
5604
  """
5698
5605
  header = self._get_auth_header()
5699
5606
  with self._RESTClient(self) as rest_client:
@@ -5708,9 +5615,9 @@ class H2OGPTE(H2OGPTESyncBase):
5708
5615
  _headers=header,
5709
5616
  )
5710
5617
  )
5711
- return [ConfigItem(**c.to_dict()) for c in response]
5618
+ return [UserConfigItem(**c.to_dict()) for c in response]
5712
5619
 
5713
- def get_user_configurations_for_user(self, user_id: str) -> List[ConfigItem]:
5620
+ def get_user_configurations_for_user(self, user_id: str) -> List[UserConfigItem]:
5714
5621
  """Gets the user configurations for a specific user (to be used by admins only).
5715
5622
 
5716
5623
  Args:
@@ -5718,7 +5625,7 @@ class H2OGPTE(H2OGPTESyncBase):
5718
5625
  The unique identifier of the user.
5719
5626
 
5720
5627
  Returns:
5721
- List[ConfigItem]: List of user configurations.
5628
+ List[UserConfigItem]: List of user configurations.
5722
5629
  """
5723
5630
  header = self._get_auth_header()
5724
5631
  with self._RESTClient(self) as rest_client:
@@ -5728,13 +5635,13 @@ class H2OGPTE(H2OGPTESyncBase):
5728
5635
  _headers=header,
5729
5636
  )
5730
5637
  )
5731
- return [ConfigItem(**c.to_dict()) for c in response]
5638
+ return [UserConfigItem(**c.to_dict()) for c in response]
5732
5639
 
5733
- def get_user_configurations(self) -> List[ConfigItem]:
5640
+ def get_user_configurations(self) -> List[UserConfigItem]:
5734
5641
  """Gets the user configurations for the current user.
5735
5642
 
5736
5643
  Returns:
5737
- List[ConfigItem]: List of user configurations.
5644
+ List[UserConfigItem]: List of user configurations.
5738
5645
  """
5739
5646
  header = self._get_auth_header()
5740
5647
  with self._RESTClient(self) as rest_client:
@@ -5743,11 +5650,11 @@ class H2OGPTE(H2OGPTESyncBase):
5743
5650
  _headers=header
5744
5651
  )
5745
5652
  )
5746
- return [ConfigItem(**c.to_dict()) for c in response]
5653
+ return [UserConfigItem(**c.to_dict()) for c in response]
5747
5654
 
5748
5655
  def bulk_delete_user_configurations_for_user(
5749
5656
  self, user_id: str, key_names: List[str]
5750
- ) -> List[ConfigItem]:
5657
+ ) -> List[UserConfigItem]:
5751
5658
  header = self._get_auth_header()
5752
5659
  with self._RESTClient(self) as rest_client:
5753
5660
  response = _rest_to_client_exceptions(
@@ -5757,15 +5664,15 @@ class H2OGPTE(H2OGPTESyncBase):
5757
5664
  _headers=header,
5758
5665
  )
5759
5666
  )
5760
- return [ConfigItem(**c.to_dict()) for c in response]
5667
+ return [UserConfigItem(**c.to_dict()) for c in response]
5761
5668
 
5762
5669
  def reset_user_configurations_for_user(
5763
5670
  self, key_name: str, user_id: str
5764
- ) -> List[ConfigItem]:
5671
+ ) -> List[UserConfigItem]:
5765
5672
  """Reset a user configuration for a specific user (to be used by admins only).
5766
5673
 
5767
5674
  Returns:
5768
- List[ConfigItem]: List of user configurations.
5675
+ List[UserConfigItem]: List of user configurations.
5769
5676
  """
5770
5677
  header = self._get_auth_header()
5771
5678
  with self._RESTClient(self) as rest_client:
@@ -5776,7 +5683,7 @@ class H2OGPTE(H2OGPTESyncBase):
5776
5683
  _headers=header,
5777
5684
  )
5778
5685
  )
5779
- return [ConfigItem(**c.to_dict()) for c in response]
5686
+ return [UserConfigItem(**c.to_dict()) for c in response]
5780
5687
 
5781
5688
  def delete_agent_directories(self, chat_session_id: str) -> bool:
5782
5689
  header = self._get_auth_header()
@@ -5791,82 +5698,6 @@ class H2OGPTE(H2OGPTESyncBase):
5791
5698
  )
5792
5699
  return result.status == "completed"
5793
5700
 
5794
- def set_role_configuration(
5795
- self, key_name: str, role_id: str, string_value: str, value_type: str = None
5796
- ) -> List[ConfigItem]:
5797
- """Set a role configuration, overrides the global configuration.
5798
- Args:
5799
- role_id:
5800
- The role id you want to apply the config for.
5801
- key_name:
5802
- The name of the global config key.
5803
- string_value:
5804
- The value to be set for the config.
5805
- value_type:
5806
- The type of the value to be set for the config.
5807
-
5808
- Returns:
5809
- List[ConfigItem]: List of role configurations.
5810
- """
5811
- header = self._get_auth_header()
5812
- with self._RESTClient(self) as rest_client:
5813
- response = _rest_to_client_exceptions(
5814
- lambda: rest_client.configuration_api.set_role_configuration(
5815
- key_name=key_name,
5816
- role_id=role_id,
5817
- user_configuration_item=rest.UserConfigurationItem(
5818
- key_name=key_name,
5819
- string_value=string_value,
5820
- value_type=value_type,
5821
- ),
5822
- _headers=header,
5823
- )
5824
- )
5825
- return [ConfigItem(**c.to_dict()) for c in response]
5826
-
5827
- def list_role_configurations(self, role_id: str) -> List[ConfigItem]:
5828
- """Lists role configurations for a given role.
5829
- Args:
5830
- role_id:
5831
- The role id to get configurations for.
5832
-
5833
- Returns:
5834
- List[ConfigItem]: List of role configurations.
5835
- """
5836
- header = self._get_auth_header()
5837
- with self._RESTClient(self) as rest_client:
5838
- response = _rest_to_client_exceptions(
5839
- lambda: rest_client.configuration_api.list_role_configurations(
5840
- role_id=role_id,
5841
- _headers=header,
5842
- )
5843
- )
5844
- return [ConfigItem(**c.to_dict()) for c in response]
5845
-
5846
- def bulk_delete_role_configurations(
5847
- self, role_id: str, keys: List[str]
5848
- ) -> List[ConfigItem]:
5849
- """Delete role configuration items for a given role.
5850
- Args:
5851
- role_id:
5852
- The role id to delete configurations for.
5853
- keys:
5854
- List of configuration keys to delete.
5855
-
5856
- Returns:
5857
- List[ConfigItem]: List of remaining role configurations.
5858
- """
5859
- header = self._get_auth_header()
5860
- with self._RESTClient(self) as rest_client:
5861
- response = _rest_to_client_exceptions(
5862
- lambda: rest_client.configuration_api.delete_role_configurations(
5863
- key_names=keys,
5864
- role_id=role_id,
5865
- _headers=header,
5866
- )
5867
- )
5868
- return [ConfigItem(**c.to_dict()) for c in response]
5869
-
5870
5701
  def delete_multiple_agent_directories(
5871
5702
  self, chat_session_ids: List[str], dir_types: List[str]
5872
5703
  ) -> bool:
@@ -6246,27 +6077,3 @@ class H2OGPTE(H2OGPTESyncBase):
6246
6077
  )
6247
6078
  )
6248
6079
  return response.count
6249
-
6250
- def set_role_priority(self, role_id: str, priority: int) -> UserRole:
6251
- """Sets the priority for a role.
6252
- Args:
6253
- role_id:
6254
- String: The id of the role to set the priority for.
6255
- priority:
6256
- Int: The priority value to set for the role. ex: 100, 200, 300...etc.
6257
- The lower the number, the higher the priority.
6258
- Returns:
6259
- UserRole: The updated user role with the new priority.
6260
- """
6261
- header = self._get_auth_header()
6262
- with self._RESTClient(self) as rest_client:
6263
- response = _rest_to_client_exceptions(
6264
- lambda: rest_client.permission_api.set_role_priority(
6265
- role_id=role_id,
6266
- set_role_priority_request=rest.SetRolePriorityRequest(
6267
- priority=priority
6268
- ),
6269
- _headers=header,
6270
- )
6271
- )
6272
- return UserRole(**response.to_dict())