h2ogpte 1.6.42__py3-none-any.whl → 1.6.43rc1__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 (98) hide show
  1. h2ogpte/__init__.py +1 -1
  2. h2ogpte/cli/__init__.py +0 -0
  3. h2ogpte/cli/commands/__init__.py +0 -0
  4. h2ogpte/cli/commands/command_handlers/__init__.py +0 -0
  5. h2ogpte/cli/commands/command_handlers/agent.py +41 -0
  6. h2ogpte/cli/commands/command_handlers/chat.py +37 -0
  7. h2ogpte/cli/commands/command_handlers/clear.py +8 -0
  8. h2ogpte/cli/commands/command_handlers/collection.py +67 -0
  9. h2ogpte/cli/commands/command_handlers/config.py +113 -0
  10. h2ogpte/cli/commands/command_handlers/disconnect.py +36 -0
  11. h2ogpte/cli/commands/command_handlers/exit.py +37 -0
  12. h2ogpte/cli/commands/command_handlers/help.py +8 -0
  13. h2ogpte/cli/commands/command_handlers/history.py +29 -0
  14. h2ogpte/cli/commands/command_handlers/rag.py +146 -0
  15. h2ogpte/cli/commands/command_handlers/research_agent.py +45 -0
  16. h2ogpte/cli/commands/command_handlers/session.py +77 -0
  17. h2ogpte/cli/commands/command_handlers/status.py +33 -0
  18. h2ogpte/cli/commands/dispatcher.py +79 -0
  19. h2ogpte/cli/core/__init__.py +0 -0
  20. h2ogpte/cli/core/app.py +105 -0
  21. h2ogpte/cli/core/config.py +199 -0
  22. h2ogpte/cli/core/encryption.py +104 -0
  23. h2ogpte/cli/core/session.py +171 -0
  24. h2ogpte/cli/integrations/__init__.py +0 -0
  25. h2ogpte/cli/integrations/agent.py +338 -0
  26. h2ogpte/cli/integrations/rag.py +442 -0
  27. h2ogpte/cli/main.py +90 -0
  28. h2ogpte/cli/ui/__init__.py +0 -0
  29. h2ogpte/cli/ui/hbot_prompt.py +435 -0
  30. h2ogpte/cli/ui/prompts.py +129 -0
  31. h2ogpte/cli/ui/status_bar.py +133 -0
  32. h2ogpte/cli/utils/__init__.py +0 -0
  33. h2ogpte/cli/utils/file_manager.py +411 -0
  34. h2ogpte/h2ogpte.py +471 -67
  35. h2ogpte/h2ogpte_async.py +482 -68
  36. h2ogpte/h2ogpte_sync_base.py +8 -1
  37. h2ogpte/rest_async/__init__.py +6 -3
  38. h2ogpte/rest_async/api/chat_api.py +29 -0
  39. h2ogpte/rest_async/api/collections_api.py +293 -0
  40. h2ogpte/rest_async/api/extractors_api.py +2874 -70
  41. h2ogpte/rest_async/api/prompt_templates_api.py +32 -32
  42. h2ogpte/rest_async/api_client.py +1 -1
  43. h2ogpte/rest_async/configuration.py +1 -1
  44. h2ogpte/rest_async/models/__init__.py +5 -2
  45. h2ogpte/rest_async/models/chat_completion.py +4 -2
  46. h2ogpte/rest_async/models/chat_completion_delta.py +5 -3
  47. h2ogpte/rest_async/models/chat_completion_request.py +1 -1
  48. h2ogpte/rest_async/models/chat_session.py +4 -2
  49. h2ogpte/rest_async/models/chat_settings.py +1 -1
  50. h2ogpte/rest_async/models/collection.py +4 -2
  51. h2ogpte/rest_async/models/collection_create_request.py +4 -2
  52. h2ogpte/rest_async/models/create_chat_session_request.py +87 -0
  53. h2ogpte/rest_async/models/extraction_request.py +1 -1
  54. h2ogpte/rest_async/models/extractor.py +4 -2
  55. h2ogpte/rest_async/models/guardrails_settings.py +8 -4
  56. h2ogpte/rest_async/models/guardrails_settings_create_request.py +1 -1
  57. h2ogpte/rest_async/models/process_document_job_request.py +1 -1
  58. h2ogpte/rest_async/models/question_request.py +1 -1
  59. h2ogpte/rest_async/models/{reset_and_share_prompt_template_request.py → reset_and_share_request.py} +6 -6
  60. h2ogpte/{rest_sync/models/reset_and_share_prompt_template_with_groups_request.py → rest_async/models/reset_and_share_with_groups_request.py} +6 -6
  61. h2ogpte/rest_async/models/summarize_request.py +1 -1
  62. h2ogpte/rest_async/models/update_collection_workspace_request.py +87 -0
  63. h2ogpte/rest_async/models/update_extractor_privacy_request.py +87 -0
  64. h2ogpte/rest_sync/__init__.py +6 -3
  65. h2ogpte/rest_sync/api/chat_api.py +29 -0
  66. h2ogpte/rest_sync/api/collections_api.py +293 -0
  67. h2ogpte/rest_sync/api/extractors_api.py +2874 -70
  68. h2ogpte/rest_sync/api/prompt_templates_api.py +32 -32
  69. h2ogpte/rest_sync/api_client.py +1 -1
  70. h2ogpte/rest_sync/configuration.py +1 -1
  71. h2ogpte/rest_sync/models/__init__.py +5 -2
  72. h2ogpte/rest_sync/models/chat_completion.py +4 -2
  73. h2ogpte/rest_sync/models/chat_completion_delta.py +5 -3
  74. h2ogpte/rest_sync/models/chat_completion_request.py +1 -1
  75. h2ogpte/rest_sync/models/chat_session.py +4 -2
  76. h2ogpte/rest_sync/models/chat_settings.py +1 -1
  77. h2ogpte/rest_sync/models/collection.py +4 -2
  78. h2ogpte/rest_sync/models/collection_create_request.py +4 -2
  79. h2ogpte/rest_sync/models/create_chat_session_request.py +87 -0
  80. h2ogpte/rest_sync/models/extraction_request.py +1 -1
  81. h2ogpte/rest_sync/models/extractor.py +4 -2
  82. h2ogpte/rest_sync/models/guardrails_settings.py +8 -4
  83. h2ogpte/rest_sync/models/guardrails_settings_create_request.py +1 -1
  84. h2ogpte/rest_sync/models/process_document_job_request.py +1 -1
  85. h2ogpte/rest_sync/models/question_request.py +1 -1
  86. h2ogpte/rest_sync/models/{reset_and_share_prompt_template_request.py → reset_and_share_request.py} +6 -6
  87. h2ogpte/{rest_async/models/reset_and_share_prompt_template_with_groups_request.py → rest_sync/models/reset_and_share_with_groups_request.py} +6 -6
  88. h2ogpte/rest_sync/models/summarize_request.py +1 -1
  89. h2ogpte/rest_sync/models/update_collection_workspace_request.py +87 -0
  90. h2ogpte/rest_sync/models/update_extractor_privacy_request.py +87 -0
  91. h2ogpte/session.py +3 -2
  92. h2ogpte/session_async.py +22 -6
  93. h2ogpte/types.py +6 -0
  94. {h2ogpte-1.6.42.dist-info → h2ogpte-1.6.43rc1.dist-info}/METADATA +5 -1
  95. {h2ogpte-1.6.42.dist-info → h2ogpte-1.6.43rc1.dist-info}/RECORD +98 -59
  96. h2ogpte-1.6.43rc1.dist-info/entry_points.txt +2 -0
  97. {h2ogpte-1.6.42.dist-info → h2ogpte-1.6.43rc1.dist-info}/WHEEL +0 -0
  98. {h2ogpte-1.6.42.dist-info → h2ogpte-1.6.43rc1.dist-info}/top_level.txt +0 -0
h2ogpte/h2ogpte_async.py CHANGED
@@ -10,7 +10,7 @@ import json
10
10
  import time
11
11
  import uuid
12
12
  from pathlib import Path
13
- from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
13
+ from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, Callable
14
14
  from collections import defaultdict
15
15
  from h2o_authn import AsyncTokenProvider
16
16
  from urllib.parse import quote
@@ -170,6 +170,7 @@ class H2OGPTEAsync:
170
170
  self.configuration_api = None
171
171
  self.agent_api = None
172
172
  self.secrets_api = None
173
+ self.extractor_api = None
173
174
 
174
175
  async def __aenter__(self):
175
176
  if not self._h2ogpte._version_checked:
@@ -296,19 +297,65 @@ class H2OGPTEAsync:
296
297
  Default value is to use the first model (0th index).
297
298
  llm_args:
298
299
  Dictionary of kwargs to pass to the llm. Valid keys:
300
+ # Core generation parameters
299
301
  temperature (float, default: 0) — The value used to modulate the next token probabilities. Most deterministic: 0, Most creative: 1
300
- seed (int, default: 0) — The seed for the random number generator, only used if temperature > 0, seed=0 will pick a random number for each call, seed > 0 will be fixed.
301
- top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering.
302
- top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation.
303
- repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty.
304
- max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction.
305
- min_max_new_tokens (int, default: 512) — minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
306
- response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"].
307
- guided_json (dict, default: None) — If specified, the output will follow the JSON schema.
308
- guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
309
- guided_choice (Optional[List[str]], default: None — If specified, the output will be exactly one of the choices. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
310
- guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
311
- guided_whitespace_pattern (str, default: "") — If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
302
+ seed (int, default: 0) — The seed for the random number generator, only used if temperature > 0, seed=0 will pick a random number for each call, seed > 0 will be fixed
303
+ top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering
304
+ top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation
305
+ repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty
306
+ max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction
307
+ min_max_new_tokens (int, default: 512) — Minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
308
+ min_chars_per_yield (int) — Minimum number of characters to yield at a time during streaming
309
+ reasoning_effort (int, default: 0) — Level of reasoning effort for the model (higher values = deeper reasoning, e.g., 10000-65000). Use for models that support chain-of-thought reasoning. 0 means no additional reasoning effort
310
+
311
+ # Output format parameters
312
+ response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"]
313
+ guided_json (dict, default: None) — If specified, the output will follow the JSON schema
314
+ guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation: check output of get_llms() for guided_vllm flag
315
+ guided_choice (Optional[List[str]], default: None) — If specified, the output will be exactly one of the choices. Only for models that support guided generation
316
+ guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation
317
+ guided_whitespace_pattern (str, default: "") — If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation
318
+ json_preserve_system_prompt (bool) — Whether to preserve the system prompt when using JSON response format
319
+
320
+ # Vision and image parameters
321
+ images_num_max (int) — Maximum number of images to process
322
+ visible_vision_models (list) — List of vision models that can be used
323
+
324
+ # Agent parameters
325
+ use_agent (bool, default: False) — Whether to enable agent functionality for advanced task processing with access to tools
326
+ shared_agent (bool, default: False) — Whether to use shared agent instance across multiple requests for efficiency
327
+ agent_type (str, default: "auto") — Type of agent to use. Options: ["auto", "agent_analysis", "agent_chat_history_md", "agent_code", "agent_rag"]
328
+ selected_tool_type (str, default: "auto") — Type of tools to make available to the agent. Options: ["auto", "all", "any"] or specific tool names
329
+ agent_accuracy (str, default: "standard") — Accuracy level for agent operations. Options:
330
+ "quick" - Fastest, less verification (max_turns=10, timeout=30s)
331
+ "basic" - Best for simple tasks (max_turns=20, timeout=60s)
332
+ "standard" - Good for most tasks (max_turns=40, timeout=120s)
333
+ "maximum" - Highest accuracy, can take a long time (max_turns=80, timeout=240s)
334
+ agent_max_turns (Union[str, int], default: "auto") — Maximum number of back-and-forth turns the agent can take. Either "auto" or an integer
335
+ agent_original_files (list) — List of file paths for agent to process and analyze
336
+ agent_timeout (int) — Timeout in seconds for each individual agent turn/operation
337
+ agent_total_timeout (int, default: 3600) — Total timeout in seconds for all agent operations combined
338
+ agent_min_time (int) — Minimum time in seconds to run the agent before allowing completion
339
+ agent_tools (Union[str, list], default: "auto") — List of specific tools available to the agent. Options: "auto", "all", "any", or list of tool names
340
+ user_persona (str) — User persona description for agent context to customize agent behavior
341
+ agent_code_writer_system_message (str) — Custom system message for code writing agent to guide code generation
342
+ agent_code_restrictions_level (int) — Level of code execution restrictions for agent (typically 0 for unrestricted)
343
+ agent_num_executable_code_blocks_limit (int) — Maximum number of code blocks the agent can execute in a single session
344
+ agent_system_site_packages (bool, default: False) — Whether agent can use system site packages when executing code
345
+ agent_main_model (str) — Main model to use for agent operations (e.g., specific LLM name)
346
+ agent_max_stream_length (int, default: -1) — Maximum length for agent streaming responses, -1 for unlimited
347
+ agent_max_memory_usage (int) — Maximum memory usage in bytes for agent operations
348
+ agent_main_reasoning_effort (int) — Level of reasoning effort for main agent model (higher values = more reasoning, e.g., 10000)
349
+ agent_advanced_reasoning_effort (int) — Level of reasoning effort for advanced agent operations (e.g., 20000)
350
+ agent_max_confidence_level (int) — Maximum confidence level for agent decisions (typically 0, 1, or 2)
351
+ agent_planning_forced_mode (bool) — Whether to force planning mode for agent (True to always plan first)
352
+ agent_too_soon_forced_mode (bool) — Whether to force handling of premature agent decisions
353
+ agent_critique_forced_mode (int) — Whether to force critique mode for agent self-evaluation
354
+ agent_stream_files (bool, default: True) — Whether to stream files from agent operations for real-time updates
355
+
356
+ # Other parameters
357
+ max_time (int) — Maximum time in seconds for the operation
358
+ client_metadata (dict) — Metadata to include with the request
312
359
  chat_conversation:
313
360
  List of tuples for (human, bot) conversation that will be pre-appended
314
361
  to an (question, None) case for a query.
@@ -420,18 +467,19 @@ class H2OGPTEAsync:
420
467
  llm_args:
421
468
  Dictionary of kwargs to pass to the llm. Valid keys:
422
469
  temperature (float, default: 0) — The value used to modulate the next token probabilities. Most deterministic: 0, Most creative: 1
423
- seed (int, default: 0) — The seed for the random number generator, only used if temperature > 0, seed=0 will pick a random number for each call, seed > 0 will be fixed.
424
- top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering.
425
- top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation.
426
- repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty.
427
- max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction.
428
- min_max_new_tokens (int, default: 512) — minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
429
- response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"].
430
- guided_json (dict, default: None) — If specified, the output will follow the JSON schema.
431
- guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
432
- guided_choice (Optional[List[str]], default: None — If specified, the output will be exactly one of the choices. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
433
- guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
434
- guided_whitespace_pattern (str, default: "") — If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
470
+ seed (int, default: 0) — The seed for the random number generator, only used if temperature > 0, seed=0 will pick a random number for each call, seed > 0 will be fixed
471
+ top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering
472
+ top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation
473
+ repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty
474
+ max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction
475
+ min_max_new_tokens (int, default: 512) — Minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
476
+ reasoning_effort (int, default: 0) — Level of reasoning effort for the model (higher values = deeper reasoning, e.g., 10000-65000). Use for models that support chain-of-thought reasoning. 0 means no additional reasoning effort
477
+ response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"]
478
+ guided_json (dict, default: None) — If specified, the output will follow the JSON schema
479
+ guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation
480
+ guided_choice (Optional[List[str]], default: None) — If specified, the output will be exactly one of the choices. Only for models that support guided generation
481
+ guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation
482
+ guided_whitespace_pattern (str, default: "") — If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation
435
483
  guardrails_settings:
436
484
  Guardrails Settings.
437
485
  timeout:
@@ -530,18 +578,19 @@ class H2OGPTEAsync:
530
578
  llm_args:
531
579
  Dictionary of kwargs to pass to the llm. Valid keys:
532
580
  temperature (float, default: 0) — The value used to modulate the next token probabilities. Most deterministic: 0, Most creative: 1
533
- seed (int, default: 0) — The seed for the random number generator, only used if temperature > 0, seed=0 will pick a random number for each call, seed > 0 will be fixed.
534
- top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering.
535
- top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation.
536
- repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty.
537
- max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction.
538
- min_max_new_tokens (int, default: 512) — minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
539
- response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"].
540
- guided_json (dict, default: None) — If specified, the output will follow the JSON schema.
541
- guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
542
- guided_choice (Optional[List[str]], default: None — If specified, the output will be exactly one of the choices. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
543
- guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
544
- guided_whitespace_pattern (str, default: "") — If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
581
+ seed (int, default: 0) — The seed for the random number generator, only used if temperature > 0, seed=0 will pick a random number for each call, seed > 0 will be fixed
582
+ top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering
583
+ top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation
584
+ repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty
585
+ max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction
586
+ min_max_new_tokens (int, default: 512) — Minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
587
+ reasoning_effort (int, default: 0) — Level of reasoning effort for the model (higher values = deeper reasoning, e.g., 10000-65000). Use for models that support chain-of-thought reasoning. 0 means no additional reasoning effort
588
+ response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"]
589
+ guided_json (dict, default: None) — If specified, the output will follow the JSON schema
590
+ guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation
591
+ guided_choice (Optional[List[str]], default: None) — If specified, the output will be exactly one of the choices. Only for models that support guided generation
592
+ guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation
593
+ guided_whitespace_pattern (str, default: "") — If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation
545
594
  guardrails_settings:
546
595
  Guardrails Settings.
547
596
  timeout:
@@ -849,13 +898,18 @@ class H2OGPTEAsync:
849
898
  )
850
899
  return result
851
900
 
852
- async def create_chat_session(self, collection_id: Optional[str] = None) -> str:
901
+ async def create_chat_session(
902
+ self, collection_id: Optional[str] = None, workspace: Optional[str] = None
903
+ ) -> str:
853
904
  """Creates a new chat session for asking questions (of documents).
854
905
 
855
906
  Args:
856
907
  collection_id:
857
908
  String id of the collection to chat with.
858
909
  If None, chat with LLM directly.
910
+ workspace:
911
+ String id of the workspace this chat will be associated with.
912
+ If None, the user's default workspace will be used.
859
913
 
860
914
  Returns:
861
915
  str: The ID of the newly created chat session.
@@ -864,7 +918,11 @@ class H2OGPTEAsync:
864
918
  async with self._RESTClient(self) as rest_client:
865
919
  response = await _rest_to_client_exceptions(
866
920
  rest_client.chat_api.create_chat_session(
867
- collection_id=collection_id, _headers=header
921
+ collection_id=collection_id,
922
+ create_chat_session_request=rest.CreateChatSessionRequest(
923
+ workspace=workspace,
924
+ ),
925
+ _headers=header,
868
926
  )
869
927
  )
870
928
  return response.id
@@ -879,7 +937,8 @@ class H2OGPTEAsync:
879
937
  async with self._RESTClient(self) as rest_client:
880
938
  response = await _rest_to_client_exceptions(
881
939
  rest_client.chat_api.create_chat_session(
882
- collection_id="default", _headers=header
940
+ collection_id="default",
941
+ _headers=header,
883
942
  )
884
943
  )
885
944
  return response.id
@@ -966,6 +1025,7 @@ class H2OGPTEAsync:
966
1025
  collection_settings: Union[dict, None] = None,
967
1026
  thumbnail: Union[Path, None] = None,
968
1027
  chat_settings: Union[dict, None] = None,
1028
+ workspace: Union[str, None] = None,
969
1029
  ) -> str:
970
1030
  r"""Creates a new collection.
971
1031
 
@@ -1012,8 +1072,8 @@ class H2OGPTEAsync:
1012
1072
  guardrails_labels_to_flag: list of entities to be flagged as safety violations in user prompts. Must be a subset of guardrails_entities, if provided.
1013
1073
  guardrails_safe_category: (Optional) name of the safe category for guardrails. Must be a key in guardrails_entities, if provided. Otherwise uses system defaults.
1014
1074
  guardrails_entities: (Optional) dictionary of entities and their descriptions for the guardrails model to classify. The first entry is the "safe" class, the rest are "unsafe" classes.
1015
- column_redaction_custom_entities_to_flag: list of entities to redact in tabular data files. Must be a subset of column_redaction_custom_entities, if provided.
1016
- column_redaction_custom_entities: (Optional) dictionary of entities and a short description for the LLM to check for and redact columns containing PII in tabular data files.
1075
+ custom_pii_entities_to_flag: list of entities to redact in tabular data files. Must be a subset of custom_pii_entities, if provided.
1076
+ custom_pii_entities: (Optional) dictionary of entities and a short description for the LLM to check for and redact columns containing PII in tabular data files.
1017
1077
  guardrails_llm: LLM to use for guardrails and PII detection. Use "auto" for automatic. Use `H2OGPTE.get_llms()` to see all available options.
1018
1078
  Example:
1019
1079
  Note: Call client.get_guardrails_settings() to see all options for guardrails_settings.
@@ -1045,10 +1105,10 @@ class H2OGPTEAsync:
1045
1105
  "Intellectual Property": "Messages that may violate the intellectual property rights of any third party",
1046
1106
  "Code Interpreter Abuse": "Messages that seek to abuse code interpreters, including those that enable denial of service attacks, container escapes or privilege escalation exploits",
1047
1107
  },
1048
- column_redaction_custom_entities_to_flag=[
1108
+ custom_pii_entities_to_flag=[
1049
1109
  "Mother's Maiden Name"
1050
1110
  ],
1051
- column_redaction_custom_entities={
1111
+ custom_pii_entities={
1052
1112
  "Mother's Maiden Name": "Mother's maiden name."
1053
1113
  },
1054
1114
  guardrails_llm="meta-llama/Llama-3.3-70B-Instruct",
@@ -1059,12 +1119,14 @@ class H2OGPTEAsync:
1059
1119
  chat_settings:
1060
1120
  (Optional) Dictionary with key/value pairs to configure the default values for certain chat specific settings
1061
1121
  The following keys are supported, see the client.session() documentation for more details.
1062
- llm: str
1063
- llm_args: dict
1064
- self_reflection_config: dict
1065
- rag_config: dict
1066
- include_chat_history: bool
1067
- tags: list[str]
1122
+ llm: str — Default LLM to use for chat sessions in this collection
1123
+ llm_args: dict — Default LLM arguments (see answer_question method for full list of valid keys)
1124
+ self_reflection_config: dict — Configuration for self-reflection functionality
1125
+ rag_config: dict — Configuration for RAG (Retrieval-Augmented Generation)
1126
+ include_chat_history: bool — Whether to include chat history in context
1127
+ tags: list[str] — Tags to associate with the collection
1128
+ workspace:
1129
+ (Optional) The workspace id to be associated with this collection. None to use the default workspace.
1068
1130
  Returns:
1069
1131
  str: The ID of the newly created collection.
1070
1132
  """
@@ -1078,6 +1140,7 @@ class H2OGPTEAsync:
1078
1140
  collection_settings
1079
1141
  ),
1080
1142
  chat_settings=rest.ChatSettings.from_dict(chat_settings),
1143
+ workspace=workspace,
1081
1144
  )
1082
1145
  collection = await _rest_to_client_exceptions(
1083
1146
  rest_client.collection_api.create_collection(request, _headers=headers)
@@ -1759,20 +1822,21 @@ class H2OGPTEAsync:
1759
1822
  llm_args:
1760
1823
  Dictionary of kwargs to pass to the llm. Valid keys:
1761
1824
  temperature (float, default: 0) — The value used to modulate the next token probabilities. Most deterministic: 0, Most creative: 1
1762
- top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering.
1763
- top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation.
1764
- seed (int, default: 0) — The seed for the random number generator when sampling during generation (if temp>0 or top_k>1 or top_p<1), seed=0 picks a random seed.
1765
- repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty.
1766
- max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction.
1767
- min_max_new_tokens (int, default: 512) — minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
1768
- response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"].
1769
- guided_json (dict, default: None) — If specified, the output will follow the JSON schema.
1770
- guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
1771
- guided_choice (Optional[List[str]], default: None — If specified, the output will be exactly one of the choices. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
1772
- guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
1773
- guided_whitespace_pattern (str, default: "") — If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation: check output of get_llms() for guided_vllm flag.
1774
- enable_vision (str, default: "auto") - Controls vision mode, send images to the LLM in addition to text chunks. Only if have models that support vision, use get_vision_capable_llm_names() to see list. One of ["on", "off", "auto"].
1775
- visible_vision_models (List[str], default: ["auto"]) - Controls which vision model to use when processing images. Use get_vision_capable_llm_names() to see list. Must provide exactly one model. ["auto"] for automatic.
1825
+ top_k (int, default: 1) — The number of highest probability vocabulary tokens to keep for top-k-filtering
1826
+ top_p (float, default: 1.0) — If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation
1827
+ seed (int, default: 0) — The seed for the random number generator when sampling during generation (if temp>0 or top_k>1 or top_p<1), seed=0 picks a random seed
1828
+ repetition_penalty (float, default: 1.07) — The parameter for repetition penalty. 1.0 means no penalty
1829
+ max_new_tokens (int, default: 1024) — Maximum number of new tokens to generate. This limit applies to each (map+reduce) step during summarization and each (map) step during extraction
1830
+ reasoning_effort (int, default: 0) — Level of reasoning effort for the model (higher values = deeper reasoning, e.g., 10000-65000). Use for models that support chain-of-thought reasoning. 0 means no additional reasoning effort
1831
+ min_max_new_tokens (int, default: 512) — Minimum value for max_new_tokens when auto-adjusting for content of prompt, docs, etc.
1832
+ response_format (str, default: "text") — Output type, one of ["text", "json_object", "json_code"]
1833
+ guided_json (dict, default: None) — If specified, the output will follow the JSON schema
1834
+ guided_regex (str, default: "") — If specified, the output will follow the regex pattern. Only for models that support guided generation
1835
+ guided_choice (Optional[List[str]], default: None) — If specified, the output will be exactly one of the choices. Only for models that support guided generation
1836
+ guided_grammar (str, default: "") — If specified, the output will follow the context free grammar. Only for models that support guided generation
1837
+ guided_whitespace_pattern (str, default: "") If specified, will override the default whitespace pattern for guided json decoding. Only for models that support guided generation
1838
+ enable_vision (str, default: "auto") Controls vision mode, send images to the LLM in addition to text chunks. Only if have models that support vision, use get_vision_capable_llm_names() to see list. One of ["on", "off", "auto"]
1839
+ visible_vision_models (List[str], default: ["auto"]) — Controls which vision model to use when processing images. Use get_vision_capable_llm_names() to see list. Must provide exactly one model. ["auto"] for automatic
1776
1840
  max_num_chunks:
1777
1841
  Max limit of chunks to send to the summarizer
1778
1842
  sampling_strategy:
@@ -2727,6 +2791,7 @@ class H2OGPTEAsync:
2727
2791
  metadata: Union[Dict[str, Any], None] = None,
2728
2792
  timeout: Union[float, None] = None,
2729
2793
  ingest_mode: Union[str, None] = None,
2794
+ callback: Optional[Callable[[Job], None]] = None,
2730
2795
  ) -> Job:
2731
2796
  """Add uploaded documents into a specific collection.
2732
2797
 
@@ -2773,6 +2838,8 @@ class H2OGPTEAsync:
2773
2838
  "standard" - Files will be ingested for use with RAG
2774
2839
  "lite" - Files will be ingested for use with RAG, but minimal processing will be done, favoring ingest speed over accuracy
2775
2840
  "agent_only" - Bypasses standard ingestion. Files can only be used with agents.
2841
+ callback:
2842
+ Function for processing job status info during the upload.
2776
2843
  """
2777
2844
  header = await self._get_auth_header()
2778
2845
  async with self._RESTClient(self) as rest_client:
@@ -2800,7 +2867,9 @@ class H2OGPTEAsync:
2800
2867
  _headers=header,
2801
2868
  )
2802
2869
  )
2803
- return await self._wait_for_completion(response.id, timeout=timeout)
2870
+ return await self._wait_for_completion(
2871
+ response.id, timeout=timeout, callback=callback
2872
+ )
2804
2873
 
2805
2874
  async def ingest_website(
2806
2875
  self,
@@ -3925,6 +3994,300 @@ class H2OGPTEAsync:
3925
3994
  )
3926
3995
  return result
3927
3996
 
3997
+ async def list_extractor_permissions(
3998
+ self, extractor_id: str
3999
+ ) -> List[SharePermission]:
4000
+ """Returns a list of access permissions for a given extractor.
4001
+
4002
+ The returned list of permissions denotes who has access to
4003
+ the extractor and their access level.
4004
+
4005
+ Args:
4006
+ extractor_id:
4007
+ ID of the extractor to inspect.
4008
+
4009
+ Returns:
4010
+ list of SharePermission: Sharing permissions list for the given extractor.
4011
+ """
4012
+ header = await self._get_auth_header()
4013
+ async with self._RESTClient(self) as rest_client:
4014
+ response = await _rest_to_client_exceptions(
4015
+ rest_client.extractor_api.get_extractor_permissions(
4016
+ extractor_id=extractor_id,
4017
+ _headers=header,
4018
+ )
4019
+ )
4020
+ return [SharePermission(**d.to_dict()) for d in response]
4021
+
4022
+ async def list_extractor_group_permissions(
4023
+ self, extractor_id: str
4024
+ ) -> List[GroupSharePermission]:
4025
+ """Returns a list of group access permissions for a given extractor.
4026
+
4027
+ The returned list of group permissions denoting which groups have access to
4028
+ the extractor and their access level.
4029
+
4030
+ Args:
4031
+ extractor_id:
4032
+ ID of the extractor to inspect.
4033
+
4034
+ Returns:
4035
+ list of GroupSharePermission: Group sharing permissions list for the given extractor.
4036
+ """
4037
+ header = await self._get_auth_header()
4038
+ async with self._RESTClient(self) as rest_client:
4039
+ response = await _rest_to_client_exceptions(
4040
+ rest_client.extractor_api.get_extractor_group_permissions(
4041
+ extractor_id=extractor_id,
4042
+ _headers=header,
4043
+ )
4044
+ )
4045
+ return [GroupSharePermission(**d.to_dict()) for d in response]
4046
+
4047
+ async def share_extractor(
4048
+ self, extractor_id: str, permission: SharePermission
4049
+ ) -> ShareResponseStatus:
4050
+ """Share an extractor to a user.
4051
+
4052
+ The permission attribute defined the level of access,
4053
+ and who can access the extractor, the extractor_id attribute
4054
+ denotes the extractor to be shared.
4055
+
4056
+ Args:
4057
+ extractor_id:
4058
+ ID of the extractor to share.
4059
+ permission:
4060
+ Defines the rule for sharing, i.e. permission level.
4061
+
4062
+ Returns:
4063
+ ShareResponseStatus: Status of share request.
4064
+ """
4065
+ header = await self._get_auth_header()
4066
+ async with self._RESTClient(self) as rest_client:
4067
+ result = await _get_share_permission_status(
4068
+ _rest_to_client_exceptions(
4069
+ rest_client.extractor_api.share_extractor(
4070
+ extractor_id=extractor_id,
4071
+ username=permission.username,
4072
+ _headers=header,
4073
+ )
4074
+ )
4075
+ )
4076
+ return result
4077
+
4078
+ async def unshare_extractor(
4079
+ self, extractor_id: str, permission: SharePermission
4080
+ ) -> ShareResponseStatus:
4081
+ """Remove sharing of an extractor to a user.
4082
+
4083
+ The permission attribute defined the level of access,
4084
+ and who can access the extractor, the extractor_id attribute
4085
+ denotes the extractor to be shared.
4086
+
4087
+ In case of un-sharing, the SharePermission's user is sufficient.
4088
+
4089
+ Args:
4090
+ extractor_id:
4091
+ ID of the extractor to un-share.
4092
+ permission:
4093
+ Defines the user for which extractor access is revoked.
4094
+
4095
+ ShareResponseStatus: Status of share request.
4096
+ """
4097
+ header = await self._get_auth_header()
4098
+ async with self._RESTClient(self) as rest_client:
4099
+ result = await _get_share_permission_status(
4100
+ _rest_to_client_exceptions(
4101
+ rest_client.extractor_api.unshare_extractor(
4102
+ extractor_id=extractor_id,
4103
+ username=permission.username,
4104
+ _headers=header,
4105
+ )
4106
+ )
4107
+ )
4108
+ return result
4109
+
4110
+ async def reset_and_share_extractor(
4111
+ self, extractor_id: str, new_usernames: List[str]
4112
+ ) -> ShareResponseStatus:
4113
+ """Remove all users who have access to an extractor (except for the owner) and share it with the provided list of new users.
4114
+
4115
+ Args:
4116
+ extractor_id:
4117
+ ID of the extractor to un-share.
4118
+ new_usernames:
4119
+ The list of usernames belonging to the users this extractor will be shared with.
4120
+
4121
+ ShareResponseStatus: Status of share request.
4122
+ """
4123
+ header = await self._get_auth_header()
4124
+ async with self._RESTClient(self) as rest_client:
4125
+ result = await _get_share_permission_status(
4126
+ _rest_to_client_exceptions(
4127
+ rest_client.extractor_api.reset_and_share_extractor(
4128
+ extractor_id=extractor_id,
4129
+ reset_and_share_request=rest.ResetAndShareRequest(
4130
+ usernames=new_usernames,
4131
+ ),
4132
+ _headers=header,
4133
+ )
4134
+ )
4135
+ )
4136
+ return result
4137
+
4138
+ async def unshare_extractor_for_all(self, extractor_id: str) -> ShareResponseStatus:
4139
+ """Remove sharing of an extractor to all other users but the original owner.
4140
+
4141
+ Args:
4142
+ extractor_id:
4143
+ ID of the extractor to un-share.
4144
+
4145
+ ShareResponseStatus: Status of share request.
4146
+ """
4147
+ header = await self._get_auth_header()
4148
+ async with self._RESTClient(self) as rest_client:
4149
+ result = await _get_share_permission_status(
4150
+ _rest_to_client_exceptions(
4151
+ rest_client.extractor_api.unshare_extractor_for_all(
4152
+ extractor_id=extractor_id,
4153
+ _headers=header,
4154
+ )
4155
+ )
4156
+ )
4157
+ return result
4158
+
4159
+ async def share_extractor_with_group(
4160
+ self, extractor_id: str, permission: GroupSharePermission
4161
+ ) -> ShareResponseStatus:
4162
+ """Share an extractor to a group.
4163
+
4164
+ The permission attribute defines which group can access the extractor,
4165
+ the extractor_id attribute denotes the extractor to be shared.
4166
+
4167
+ Args:
4168
+ extractor_id:
4169
+ ID of the extractor to share.
4170
+ permission:
4171
+ Defines the group for sharing with.
4172
+
4173
+ Returns:
4174
+ ShareResponseStatus: Status of share request.
4175
+ """
4176
+ header = await self._get_auth_header()
4177
+ async with self._RESTClient(self) as rest_client:
4178
+ result = await _get_share_permission_status(
4179
+ _rest_to_client_exceptions(
4180
+ rest_client.extractor_api.share_extractor_with_group(
4181
+ extractor_id=extractor_id,
4182
+ group_id=permission.group_id,
4183
+ _headers=header,
4184
+ )
4185
+ )
4186
+ )
4187
+ return result
4188
+
4189
+ async def unshare_extractor_from_group(
4190
+ self, extractor_id: str, permission: GroupSharePermission
4191
+ ) -> ShareResponseStatus:
4192
+ """Remove sharing of an extractor from a group.
4193
+
4194
+ The permission attribute defines which group to remove access from,
4195
+ the extractor_id attribute denotes the extractor to be unshared.
4196
+
4197
+
4198
+ Args:
4199
+ extractor_id:
4200
+ ID of the extractor to un-share.
4201
+ permission:
4202
+ Defines the group for which extractor access is revoked.
4203
+
4204
+ Returns:
4205
+ ShareResponseStatus: Status of share request.
4206
+ """
4207
+ header = await self._get_auth_header()
4208
+ async with self._RESTClient(self) as rest_client:
4209
+ result = await _get_share_permission_status(
4210
+ _rest_to_client_exceptions(
4211
+ rest_client.extractor_api.unshare_extractor_from_group(
4212
+ extractor_id=extractor_id,
4213
+ group_id=permission.group_id,
4214
+ _headers=header,
4215
+ )
4216
+ )
4217
+ )
4218
+ return result
4219
+
4220
+ async def reset_and_share_extractor_with_groups(
4221
+ self, extractor_id: str, new_groups: List[str]
4222
+ ) -> ShareResponseStatus:
4223
+ """Remove all groups who have access to an extractor and share it with the provided list of new group ids.
4224
+
4225
+ Args:
4226
+ extractor_id:
4227
+ ID of the extractor to un-share.
4228
+ new_groups:
4229
+ The list of group ids this extractor will be shared with.
4230
+
4231
+ ShareResponseStatus: Status of share request.
4232
+ """
4233
+ header = await self._get_auth_header()
4234
+ async with self._RESTClient(self) as rest_client:
4235
+ result = await _get_share_permission_status(
4236
+ _rest_to_client_exceptions(
4237
+ rest_client.extractor_api.reset_and_share_extractor_with_groups(
4238
+ extractor_id=extractor_id,
4239
+ reset_and_share_with_groups_request=rest.ResetAndShareWithGroupsRequest(
4240
+ groups=new_groups,
4241
+ ),
4242
+ _headers=header,
4243
+ )
4244
+ )
4245
+ )
4246
+ return result
4247
+
4248
+ async def make_extractor_public(self, extractor_id: str):
4249
+ """Make an extractor public
4250
+
4251
+ Once an extractor is public, it can be seen and used by all users.
4252
+
4253
+ Args:
4254
+ extractor_id:
4255
+ ID of the extractor to make public.
4256
+ """
4257
+ header = await self._get_auth_header()
4258
+ async with self._RESTClient(self) as rest_client:
4259
+ await _rest_to_client_exceptions(
4260
+ rest_client.extractor_api.update_extractor_privacy(
4261
+ extractor_id=extractor_id,
4262
+ update_extractor_privacy_request=rest.UpdateExtractorPrivacyRequest(
4263
+ is_public=True
4264
+ ),
4265
+ _headers=header,
4266
+ )
4267
+ )
4268
+
4269
+ async def make_extractor_private(self, extractor_id: str):
4270
+ """Make an extractor private
4271
+
4272
+ Once a extractor is private, other users will no longer
4273
+ be able to see or use it unless it has been shared individually or by group.
4274
+
4275
+ Args:
4276
+ extractore_id:
4277
+ ID of the extractor to make private.
4278
+ """
4279
+ header = await self._get_auth_header()
4280
+ async with self._RESTClient(self) as rest_client:
4281
+ await _rest_to_client_exceptions(
4282
+ rest_client.extractor_api.update_extractor_privacy(
4283
+ extractor_id=extractor_id,
4284
+ update_extractor_privacy_request=rest.UpdateExtractorPrivacyRequest(
4285
+ is_public=False
4286
+ ),
4287
+ _headers=header,
4288
+ )
4289
+ )
4290
+
3928
4291
  async def list_recent_documents(
3929
4292
  self, offset: int, limit: int, metadata_filter: dict = {}
3930
4293
  ) -> List[DocumentInfo]:
@@ -4353,6 +4716,31 @@ class H2OGPTEAsync:
4353
4716
  )
4354
4717
  return collection_id
4355
4718
 
4719
+ async def update_collection_workspace(
4720
+ self, collection_id: str, workspace: str
4721
+ ) -> str:
4722
+ """Update the workspace associated with a collection.
4723
+
4724
+ Args:
4725
+ collection_id:
4726
+ ID of the collection to update.
4727
+ workspace:
4728
+ The workspace associated with the collection.
4729
+ """
4730
+
4731
+ header = await self._get_auth_header()
4732
+ async with self._RESTClient(self) as rest_client:
4733
+ await _rest_to_client_exceptions(
4734
+ rest_client.collection_api.update_collection_workspace(
4735
+ collection_id=collection_id,
4736
+ update_collection_workspace_request=rest.UpdateCollectionWorkspaceRequest(
4737
+ workspace=workspace
4738
+ ),
4739
+ _headers=header,
4740
+ )
4741
+ )
4742
+ return collection_id
4743
+
4356
4744
  async def update_document_name(self, document_id: str, name: str) -> str:
4357
4745
  """Update the name metadata for a given document.
4358
4746
 
@@ -5251,7 +5639,7 @@ class H2OGPTEAsync:
5251
5639
  _rest_to_client_exceptions(
5252
5640
  rest_client.prompt_template_api.reset_and_share_prompt_template_with_groups(
5253
5641
  prompt_template_id=prompt_id,
5254
- reset_and_share_prompt_template_with_groups_request=rest.ResetAndSharePromptTemplateWithGroupsRequest(
5642
+ reset_and_share_with_groups_request=rest.ResetAndShareWithGroupsRequest(
5255
5643
  groups=new_groups,
5256
5644
  ),
5257
5645
  _headers=header,
@@ -5299,7 +5687,7 @@ class H2OGPTEAsync:
5299
5687
  _rest_to_client_exceptions(
5300
5688
  rest_client.prompt_template_api.reset_and_share_prompt_template(
5301
5689
  prompt_template_id=prompt_id,
5302
- reset_and_share_prompt_template_request=rest.ResetAndSharePromptTemplateRequest(
5690
+ reset_and_share_request=rest.ResetAndShareRequest(
5303
5691
  usernames=new_usernames,
5304
5692
  ),
5305
5693
  _headers=header,
@@ -5574,6 +5962,27 @@ class H2OGPTEAsync:
5574
5962
 
5575
5963
  return await self.get_prompt_template(rest_session.prompt_template_id)
5576
5964
 
5965
+ async def get_chat_session_workspace(self, chat_session_id: str) -> str:
5966
+ """Get the workspace associated with the chat session.
5967
+
5968
+ Args:
5969
+ chat_session_id:
5970
+ String id of the chat session to search for.
5971
+
5972
+ Returns:
5973
+ str: The identifier of the workspace
5974
+ """
5975
+ header = await self._get_auth_header()
5976
+ async with self._RESTClient(self) as rest_client:
5977
+ response = await _rest_to_client_exceptions(
5978
+ rest_client.chat_api.get_chat_session(
5979
+ session_id=chat_session_id,
5980
+ _headers=header,
5981
+ )
5982
+ )
5983
+
5984
+ return response.workspace
5985
+
5577
5986
  async def set_chat_session_collection(
5578
5987
  self, chat_session_id: str, collection_id: Union[str, None]
5579
5988
  ) -> str:
@@ -6976,7 +7385,10 @@ class H2OGPTEAsync:
6976
7385
  return await self._post("/rpc/sharing", args)
6977
7386
 
6978
7387
  async def _wait_for_completion(
6979
- self, job_id: str, timeout: Optional[float] = None
7388
+ self,
7389
+ job_id: str,
7390
+ timeout: Optional[float] = None,
7391
+ callback: Optional[Callable[[Job], None]] = None,
6980
7392
  ) -> Job:
6981
7393
  if timeout is None:
6982
7394
  timeout = 86400
@@ -6984,6 +7396,8 @@ class H2OGPTEAsync:
6984
7396
  last_job: Optional[Job] = None
6985
7397
  while True:
6986
7398
  job = await self.get_job(job_id)
7399
+ if callback:
7400
+ callback(job)
6987
7401
  if job.completed or job.canceled:
6988
7402
  # will reach here if processing times out (self cancels since quit is set to 1)
6989
7403
  break