h2ogpte 1.6.55rc1__py3-none-any.whl → 1.7.0rc2__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 (41) hide show
  1. h2ogpte/__init__.py +1 -1
  2. h2ogpte/h2ogpte.py +213 -20
  3. h2ogpte/h2ogpte_async.py +213 -20
  4. h2ogpte/rest_async/__init__.py +3 -2
  5. h2ogpte/rest_async/api/agents_api.py +25 -25
  6. h2ogpte/rest_async/api/chat_api.py +1077 -21
  7. h2ogpte/rest_async/api/collections_api.py +281 -0
  8. h2ogpte/rest_async/api/models_api.py +35 -67
  9. h2ogpte/rest_async/api_client.py +1 -1
  10. h2ogpte/rest_async/configuration.py +1 -1
  11. h2ogpte/rest_async/models/__init__.py +2 -1
  12. h2ogpte/rest_async/models/chat_completion_request.py +6 -2
  13. h2ogpte/rest_async/models/chat_settings.py +6 -2
  14. h2ogpte/rest_async/models/chat_settings_tags.py +140 -0
  15. h2ogpte/rest_async/models/extractor.py +26 -2
  16. h2ogpte/rest_async/models/extractor_create_request.py +29 -5
  17. h2ogpte/rest_async/models/ingest_from_confluence_body.py +4 -2
  18. h2ogpte/rest_async/models/{create_topic_model_job_request.py → tag_filter.py} +11 -9
  19. h2ogpte/rest_sync/__init__.py +3 -2
  20. h2ogpte/rest_sync/api/agents_api.py +25 -25
  21. h2ogpte/rest_sync/api/chat_api.py +1077 -21
  22. h2ogpte/rest_sync/api/collections_api.py +281 -0
  23. h2ogpte/rest_sync/api/models_api.py +35 -67
  24. h2ogpte/rest_sync/api_client.py +1 -1
  25. h2ogpte/rest_sync/configuration.py +1 -1
  26. h2ogpte/rest_sync/models/__init__.py +2 -1
  27. h2ogpte/rest_sync/models/chat_completion_request.py +6 -2
  28. h2ogpte/rest_sync/models/chat_settings.py +6 -2
  29. h2ogpte/rest_sync/models/chat_settings_tags.py +140 -0
  30. h2ogpte/rest_sync/models/extractor.py +26 -2
  31. h2ogpte/rest_sync/models/extractor_create_request.py +29 -5
  32. h2ogpte/rest_sync/models/ingest_from_confluence_body.py +4 -2
  33. h2ogpte/rest_sync/models/{create_topic_model_job_request.py → tag_filter.py} +11 -9
  34. h2ogpte/session.py +10 -5
  35. h2ogpte/session_async.py +10 -2
  36. h2ogpte/types.py +28 -1
  37. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc2.dist-info}/METADATA +1 -1
  38. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc2.dist-info}/RECORD +41 -39
  39. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc2.dist-info}/WHEEL +0 -0
  40. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc2.dist-info}/entry_points.txt +0 -0
  41. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc2.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.55rc1"
6
+ __version__ = "1.7.0rc2"
7
7
 
8
8
  __all__ = [
9
9
  "H2OGPTE",
h2ogpte/h2ogpte.py CHANGED
@@ -470,25 +470,60 @@ class H2OGPTE(H2OGPTESyncBase):
470
470
  llm: str,
471
471
  extractor_schema: Dict[str, Any],
472
472
  description: str = "",
473
+ prompt: str = "",
474
+ pre_prompt_summary: str = "",
475
+ keep_intermediate_results: bool = False,
476
+ system_prompt: str = "",
477
+ max_num_chunks: int = 100,
478
+ vision: str = "auto",
479
+ vision_llm: str = "auto",
480
+ image_batch_image_prompt: str = "",
481
+ image_batch_final_prompt: str = "",
482
+ guardrails_settings: Optional[Dict] = None,
473
483
  ) -> Extractor:
474
484
  """Creates a new extractor.
475
485
 
476
486
  Args:
477
487
  name: Name of the extractor.
478
488
  llm: LLM to use for extraction.
479
- extractor_schema: JSON schema defining the extraction structure.
489
+ extractor_schema: JSON schema defining the extraction structure. If not empty, extractor will return data as JSON object.
480
490
  description: Optional description of the extractor.
491
+ prompt: Optional prompt text for the extractor. If combined with extractor_schema, prompt can modify the output, but not its format as it's set to be JSON object.
492
+ pre_prompt_summary: Optional pre-prompt summary text for the extractor.
493
+ keep_intermediate_results: Optional flag indicating whether to keep intermediate results during extraction.
494
+ system_prompt: Optional system prompt text for the extractor.
495
+ max_num_chunks: Optional maximum number of chunks to process.
496
+ vision: Optional vision mode setting.
497
+ vision_llm: Optional vision LLM model identifier.
498
+ image_batch_image_prompt: Optional image batch processing prompt.
499
+ image_batch_final_prompt: Optional final prompt for image batch processing.
500
+ guardrails_settings: Optional guardrails settings configuration as a dictionary.
481
501
 
482
502
  Returns:
483
503
  Extractor: Details of the newly created extractor.
484
504
  """
485
505
  header = self._get_auth_header()
486
506
 
507
+ # Convert guardrails_settings dict to GuardrailsSettings object if provided
508
+ guardrails_settings_obj = None
509
+ if guardrails_settings is not None:
510
+ guardrails_settings_obj = rest.GuardrailsSettings(**guardrails_settings)
511
+
487
512
  request_body = rest.ExtractorCreateRequest(
488
513
  name=name,
489
514
  description=description,
490
515
  llm=llm,
491
516
  schema=json.dumps(extractor_schema),
517
+ prompt=prompt,
518
+ pre_prompt_summary=pre_prompt_summary,
519
+ keep_intermediate_results=keep_intermediate_results,
520
+ system_prompt=system_prompt,
521
+ max_num_chunks=max_num_chunks,
522
+ vision=vision,
523
+ vision_llm=vision_llm,
524
+ image_batch_image_prompt=image_batch_image_prompt,
525
+ image_batch_final_prompt=image_batch_final_prompt,
526
+ guardrails_settings=guardrails_settings_obj,
492
527
  )
493
528
 
494
529
  with self._RESTClient(self) as rest_client:
@@ -1013,24 +1048,6 @@ class H2OGPTE(H2OGPTESyncBase):
1013
1048
  )
1014
1049
  return self._wait_for_completion(response.id, timeout=timeout)
1015
1050
 
1016
- def create_topic_model(
1017
- self,
1018
- collection_id: str,
1019
- timeout: Union[float, None] = None,
1020
- ) -> Job:
1021
- header = self._get_auth_header()
1022
- with self._RESTClient(self) as rest_client:
1023
- response = _rest_to_client_exceptions(
1024
- lambda: rest_client.model_api.create_topic_model_job(
1025
- create_topic_model_job_request=rest.CreateTopicModelJobRequest(
1026
- collection_id=collection_id,
1027
- ),
1028
- timeout=timeout,
1029
- _headers=header,
1030
- )
1031
- )
1032
- return self._wait_for_completion(response.id, timeout=timeout)
1033
-
1034
1051
  def delete_chat_sessions(
1035
1052
  self,
1036
1053
  chat_session_ids: Iterable[str],
@@ -1450,6 +1467,7 @@ class H2OGPTE(H2OGPTESyncBase):
1450
1467
  handwriting_check: Union[bool, None] = None,
1451
1468
  timeout: Union[float, None] = None,
1452
1469
  ingest_mode: Union[str, None] = None,
1470
+ preserve_document_status: Union[bool, None] = None,
1453
1471
  ):
1454
1472
  """Import all documents from a collection into an existing collection
1455
1473
 
@@ -1486,6 +1504,10 @@ class H2OGPTE(H2OGPTESyncBase):
1486
1504
  "standard" - Files will be ingested for use with RAG
1487
1505
  "lite" - Files will be ingested for use with RAG, but minimal processing will be done, favoring ingest speed over accuracy
1488
1506
  "agent_only" - Bypasses standard ingestion. Files can only be used with agents.
1507
+ preserve_document_status:
1508
+ Whether to preserve each document's original ingest mode (agent_only vs standard) when importing.
1509
+ When True, documents with agent_only status remain agent_only in the target collection.
1510
+ When False, all documents use the ingest_mode parameter uniformly.
1489
1511
  """
1490
1512
  header = self._get_auth_header()
1491
1513
  with self._RESTClient(self) as rest_client:
@@ -1504,6 +1526,7 @@ class H2OGPTE(H2OGPTESyncBase):
1504
1526
  chunk_by_page=chunk_by_page,
1505
1527
  handwriting_check=handwriting_check,
1506
1528
  ingest_mode=ingest_mode,
1529
+ preserve_document_status=preserve_document_status,
1507
1530
  timeout=timeout,
1508
1531
  _headers=header,
1509
1532
  )
@@ -2496,6 +2519,7 @@ class H2OGPTE(H2OGPTESyncBase):
2496
2519
  base_url: str,
2497
2520
  page_id: Union[str, List[str]],
2498
2521
  credentials: ConfluenceCredential,
2522
+ include_attachments: Union[bool, None] = None,
2499
2523
  gen_doc_summaries: Union[bool, None] = None,
2500
2524
  gen_doc_questions: Union[bool, None] = None,
2501
2525
  audio_input_language: Union[str, None] = None,
@@ -2519,6 +2543,8 @@ class H2OGPTE(H2OGPTESyncBase):
2519
2543
  The page id or ids of pages to be ingested.
2520
2544
  credentials:
2521
2545
  The object with Confluence credentials.
2546
+ include_attachments:
2547
+ A flag indicating whether to also ingest attachments with the page.
2522
2548
  gen_doc_summaries:
2523
2549
  Whether to auto-generate document summaries (uses LLM)
2524
2550
  gen_doc_questions:
@@ -2560,6 +2586,7 @@ class H2OGPTE(H2OGPTESyncBase):
2560
2586
  page_ids=[page_id] if isinstance(page_id, str) else page_id,
2561
2587
  credentials=rest.ConfluenceCredentials(**credentials.__dict__),
2562
2588
  metadata=metadata,
2589
+ include_attachments=include_attachments,
2563
2590
  ),
2564
2591
  gen_doc_summaries=gen_doc_summaries,
2565
2592
  gen_doc_questions=gen_doc_questions,
@@ -2741,7 +2768,20 @@ class H2OGPTE(H2OGPTESyncBase):
2741
2768
  handwriting_check:
2742
2769
  Check pages for handwriting. Will use specialized models if handwriting is found.
2743
2770
  metadata:
2744
- Metadata to be associated with the document.
2771
+ Dictionary mapping upload_ids to their metadata. Each key must be an upload_id
2772
+ from the upload_ids list, and each value is a dictionary of metadata key-value
2773
+ pairs to associate with that document.
2774
+
2775
+ Example::
2776
+
2777
+ # Single document
2778
+ metadata = {upload_id: {"category": "reports", "year": "2024"}}
2779
+
2780
+ # Multiple documents
2781
+ metadata = {
2782
+ upload_id_1: {"category": "reports"},
2783
+ upload_id_2: {"category": "invoices"}
2784
+ }
2745
2785
  timeout:
2746
2786
  Timeout in seconds.
2747
2787
  ingest_mode:
@@ -3628,6 +3668,29 @@ class H2OGPTE(H2OGPTESyncBase):
3628
3668
  )
3629
3669
  return [GroupSharePermission(**d.to_dict()) for d in response]
3630
3670
 
3671
+ def list_collection_public_permissions(self, collection_id: str) -> List[str]:
3672
+ """Returns the public permissions for a given collection.
3673
+
3674
+ The returned list contains the permission strings that apply to
3675
+ public access of the collection.
3676
+
3677
+ Args:
3678
+ collection_id:
3679
+ ID of the collection to inspect.
3680
+
3681
+ Returns:
3682
+ list of str: Public permissions list for the given collection.
3683
+ """
3684
+ header = self._get_auth_header()
3685
+ with self._RESTClient(self) as rest_client:
3686
+ response = _rest_to_client_exceptions(
3687
+ lambda: rest_client.collection_api.list_collection_public_permissions(
3688
+ collection_id=collection_id,
3689
+ _headers=header,
3690
+ )
3691
+ )
3692
+ return response
3693
+
3631
3694
  def list_users(self, offset: int, limit: int) -> List[User]:
3632
3695
  """List system users.
3633
3696
 
@@ -4514,6 +4577,11 @@ class H2OGPTE(H2OGPTESyncBase):
4514
4577
  Requires 1 LLM or Agent call.
4515
4578
  :code:`"agent_only"` Agent Only - Answer the query with only original files passed to agent.
4516
4579
  Requires 1 Agent call.
4580
+ :code:`"agentic_rag"` Agentic RAG - Agent with RAG tool that retrieves and answers from collection.
4581
+ Requires 1 Agent call with RAG tool execution.
4582
+ :code:`"rlm_rag"` RLM RAG - Agent programmatically analyzes documents using Python code
4583
+ execution and sub-LLM calls. Best for complex multi-hop reasoning over large documents.
4584
+ Requires 1 Agent call.
4517
4585
  :code:`"rag"` RAG (Retrieval Augmented Generation) - Use supporting document contexts
4518
4586
  to answer the query. Requires 1 LLM or Agent call.
4519
4587
  :code:`"hyde1"` LLM Only + RAG composite - HyDE RAG (Hypothetical Document Embedding).
@@ -7132,6 +7200,41 @@ class H2OGPTE(H2OGPTESyncBase):
7132
7200
  def add_custom_agent_tool(
7133
7201
  self, tool_type: str, tool_args: dict, custom_tool_path: Optional[str] = None
7134
7202
  ) -> list:
7203
+ """Adds a custom agent tool.
7204
+
7205
+ Args:
7206
+ tool_type: The type of custom tool being added. Valid values:
7207
+ - 'local_mcp': Model Context Protocol server running locally
7208
+ - 'remote_mcp': Model Context Protocol server running remotely
7209
+ - 'browser_action': Custom browser automation actions
7210
+ - 'general_code': General purpose code execution tools
7211
+
7212
+ tool_args: Dictionary containing tool-specific arguments. Structure varies by tool_type:
7213
+
7214
+ For 'remote_mcp':
7215
+ {
7216
+ "mcp_config_json": "JSON string with MCP server configuration",
7217
+ "enable_by_default": True/False (optional, defaults to True)
7218
+ }
7219
+
7220
+ For 'local_mcp', 'browser_action', and 'general_code':
7221
+ {
7222
+ "tool_name": "string (optional, defaults to filename without extension)",
7223
+ "description": "string (optional, tool description)",
7224
+ "enable_by_default": True/False (optional, defaults to True),
7225
+ "should_unzip": True/False (optional, for general_code .zip files only),
7226
+ "tool_usage_mode": ["runner", "creator"] (optional list of strings, for remote_mcp)
7227
+ }
7228
+
7229
+ custom_tool_path: Path to the tool file to upload (optional). Requirements vary by tool_type:
7230
+ - 'local_mcp': .zip file containing MCP server code
7231
+ - 'remote_mcp': Optional .json file with MCP configuration
7232
+ - 'browser_action': .py file (must start with 'browser_') or .zip containing browser action scripts
7233
+ - 'general_code': .py or .zip file with custom code
7234
+
7235
+ Returns:
7236
+ list: List of created custom agent tool IDs
7237
+ """
7135
7238
  header = self._get_auth_header()
7136
7239
  custom_tool_path = str(custom_tool_path) if custom_tool_path else None
7137
7240
  with self._RESTClient(self) as rest_client:
@@ -7189,6 +7292,96 @@ class H2OGPTE(H2OGPTESyncBase):
7189
7292
  )
7190
7293
  return response.agent_custom_tool_id
7191
7294
 
7295
+ def pause_chat(self, question_id: str) -> Result:
7296
+ """Pause a streaming chat response.
7297
+
7298
+ Args:
7299
+ question_id: The ID of the chat message/question to pause.
7300
+
7301
+ Returns:
7302
+ Result: Status of the pause operation.
7303
+
7304
+ Raises:
7305
+ Exception: If the user is not authorized to pause this chat or if the operation fails.
7306
+ """
7307
+ header = self._get_auth_header()
7308
+ with self._RESTClient(self) as rest_client:
7309
+ _rest_to_client_exceptions(
7310
+ lambda: rest_client.chat_api.pause_chat_message(
7311
+ question_id=question_id, _headers=header
7312
+ )
7313
+ )
7314
+ return Result(status="completed")
7315
+
7316
+ def resume_chat(self, question_id: str) -> Result:
7317
+ """Resume a paused chat response.
7318
+
7319
+ Args:
7320
+ question_id: The ID of the chat message/question to resume.
7321
+
7322
+ Returns:
7323
+ Result: Status of the resume operation.
7324
+
7325
+ Raises:
7326
+ Exception: If the user is not authorized to resume this chat or if the operation fails.
7327
+ """
7328
+ header = self._get_auth_header()
7329
+ with self._RESTClient(self) as rest_client:
7330
+ _rest_to_client_exceptions(
7331
+ lambda: rest_client.chat_api.resume_chat_message(
7332
+ question_id=question_id, _headers=header
7333
+ )
7334
+ )
7335
+ return Result(status="completed")
7336
+
7337
+ def finish_chat(self, question_id: str) -> Result:
7338
+ """Signal the LLM to complete its current thought and finish naturally.
7339
+
7340
+ Unlike stop_chat which immediately halts response generation, finish_chat allows
7341
+ the LLM to complete its current thought naturally, providing a more coherent ending.
7342
+
7343
+ Args:
7344
+ question_id: The ID of the chat message/question to finish gracefully.
7345
+
7346
+ Returns:
7347
+ Result: Status of the finish operation.
7348
+
7349
+ Raises:
7350
+ Exception: If the user is not authorized to finish this chat or if the operation fails.
7351
+ """
7352
+ header = self._get_auth_header()
7353
+ with self._RESTClient(self) as rest_client:
7354
+ _rest_to_client_exceptions(
7355
+ lambda: rest_client.chat_api.finish_chat_message(
7356
+ question_id=question_id, _headers=header
7357
+ )
7358
+ )
7359
+ return Result(status="completed")
7360
+
7361
+ def stop_chat(self, question_id: str) -> Result:
7362
+ """Immediately stop/cancel a streaming chat response.
7363
+
7364
+ This will immediately halt response generation, which may result in an incomplete
7365
+ sentence or thought. For a more graceful termination, use finish_chat instead.
7366
+
7367
+ Args:
7368
+ question_id: The ID of the chat message/question to stop immediately.
7369
+
7370
+ Returns:
7371
+ Result: Status of the cancel operation.
7372
+
7373
+ Raises:
7374
+ Exception: If the user is not authorized to cancel this chat or if the operation fails.
7375
+ """
7376
+ header = self._get_auth_header()
7377
+ with self._RESTClient(self) as rest_client:
7378
+ _rest_to_client_exceptions(
7379
+ lambda: rest_client.chat_api.stop_chat_message(
7380
+ question_id=question_id, _headers=header
7381
+ )
7382
+ )
7383
+ return Result(status="completed")
7384
+
7192
7385
  def get_custom_agent_tools(self) -> List[dict]:
7193
7386
  """Gets all custom agent tools for the current user.
7194
7387
 
h2ogpte/h2ogpte_async.py CHANGED
@@ -676,25 +676,60 @@ class H2OGPTEAsync:
676
676
  llm: str,
677
677
  extractor_schema: Dict[str, Any],
678
678
  description: str = "",
679
+ prompt: str = "",
680
+ pre_prompt_summary: str = "",
681
+ keep_intermediate_results: bool = False,
682
+ system_prompt: str = "",
683
+ max_num_chunks: int = 100,
684
+ vision: str = "auto",
685
+ vision_llm: str = "auto",
686
+ image_batch_image_prompt: str = "",
687
+ image_batch_final_prompt: str = "",
688
+ guardrails_settings: Optional[Dict] = None,
679
689
  ) -> Extractor:
680
690
  """Creates a new extractor.
681
691
 
682
692
  Args:
683
693
  name: Name of the extractor.
684
694
  llm: LLM to use for extraction.
685
- extractor_schema: JSON schema defining the extraction structure.
695
+ extractor_schema: JSON schema defining the extraction structure. If not empty, extractor will return data as JSON object.
686
696
  description: Optional description of the extractor.
697
+ prompt: Optional prompt text for the extractor. If combined with extractor_schema, prompt can modify the output, but not its format as it's set to be JSON object.
698
+ pre_prompt_summary: Optional pre-prompt summary text for the extractor.
699
+ keep_intermediate_results: Optional flag indicating whether to keep intermediate results during extraction.
700
+ system_prompt: Optional system prompt text for the extractor.
701
+ max_num_chunks: Optional maximum number of chunks to process.
702
+ vision: Optional vision mode setting.
703
+ vision_llm: Optional vision LLM model identifier.
704
+ image_batch_image_prompt: Optional image batch processing prompt.
705
+ image_batch_final_prompt: Optional final prompt for image batch processing.
706
+ guardrails_settings: Optional guardrails settings configuration as a dictionary.
687
707
 
688
708
  Returns:
689
709
  Extractor: Details of the newly created extractor.
690
710
  """
691
711
  header = await self._get_auth_header()
692
712
 
713
+ # Convert guardrails_settings dict to GuardrailsSettings object if provided
714
+ guardrails_settings_obj = None
715
+ if guardrails_settings is not None:
716
+ guardrails_settings_obj = rest.GuardrailsSettings(**guardrails_settings)
717
+
693
718
  request_body = rest.ExtractorCreateRequest(
694
719
  name=name,
695
720
  description=description,
696
721
  llm=llm,
697
722
  schema=json.dumps(extractor_schema),
723
+ prompt=prompt,
724
+ pre_prompt_summary=pre_prompt_summary,
725
+ keep_intermediate_results=keep_intermediate_results,
726
+ system_prompt=system_prompt,
727
+ max_num_chunks=max_num_chunks,
728
+ vision=vision,
729
+ vision_llm=vision_llm,
730
+ image_batch_image_prompt=image_batch_image_prompt,
731
+ image_batch_final_prompt=image_batch_final_prompt,
732
+ guardrails_settings=guardrails_settings_obj,
698
733
  )
699
734
 
700
735
  async with self._RESTClient(self) as rest_client:
@@ -1213,24 +1248,6 @@ class H2OGPTEAsync:
1213
1248
  )
1214
1249
  return await self._wait_for_completion(response.id, timeout=timeout)
1215
1250
 
1216
- async def create_topic_model(
1217
- self,
1218
- collection_id: str,
1219
- timeout: Union[float, None] = None,
1220
- ) -> Job:
1221
- header = await self._get_auth_header()
1222
- async with self._RESTClient(self) as rest_client:
1223
- response = await _rest_to_client_exceptions(
1224
- rest_client.model_api.create_topic_model_job(
1225
- create_topic_model_job_request=rest.CreateTopicModelJobRequest(
1226
- collection_id=collection_id,
1227
- ),
1228
- timeout=timeout,
1229
- _headers=header,
1230
- )
1231
- )
1232
- return await self._wait_for_completion(response.id, timeout=timeout)
1233
-
1234
1251
  async def delete_chat_sessions(
1235
1252
  self,
1236
1253
  chat_session_ids: Iterable[str],
@@ -1650,6 +1667,7 @@ class H2OGPTEAsync:
1650
1667
  handwriting_check: Union[bool, None] = None,
1651
1668
  timeout: Union[float, None] = None,
1652
1669
  ingest_mode: Union[str, None] = None,
1670
+ preserve_document_status: Union[bool, None] = None,
1653
1671
  ):
1654
1672
  """Import all documents from a collection into an existing collection
1655
1673
 
@@ -1686,6 +1704,10 @@ class H2OGPTEAsync:
1686
1704
  "standard" - Files will be ingested for use with RAG
1687
1705
  "lite" - Files will be ingested for use with RAG, but minimal processing will be done, favoring ingest speed over accuracy
1688
1706
  "agent_only" - Bypasses standard ingestion. Files can only be used with agents.
1707
+ preserve_document_status:
1708
+ Whether to preserve each document's original ingest mode (agent_only vs standard) when importing.
1709
+ When True, documents with agent_only status remain agent_only in the target collection.
1710
+ When False, all documents use the ingest_mode parameter uniformly.
1689
1711
  """
1690
1712
  header = await self._get_auth_header()
1691
1713
  async with self._RESTClient(self) as rest_client:
@@ -1704,6 +1726,7 @@ class H2OGPTEAsync:
1704
1726
  chunk_by_page=chunk_by_page,
1705
1727
  handwriting_check=handwriting_check,
1706
1728
  ingest_mode=ingest_mode,
1729
+ preserve_document_status=preserve_document_status,
1707
1730
  timeout=timeout,
1708
1731
  _headers=header,
1709
1732
  )
@@ -2698,6 +2721,7 @@ class H2OGPTEAsync:
2698
2721
  base_url: str,
2699
2722
  page_id: Union[str, List[str]],
2700
2723
  credentials: ConfluenceCredential,
2724
+ include_attachments: Union[bool, None] = None,
2701
2725
  gen_doc_summaries: Union[bool, None] = None,
2702
2726
  gen_doc_questions: Union[bool, None] = None,
2703
2727
  audio_input_language: Union[str, None] = None,
@@ -2721,6 +2745,8 @@ class H2OGPTEAsync:
2721
2745
  The page id or ids of pages to be ingested.
2722
2746
  credentials:
2723
2747
  The object with Confluence credentials.
2748
+ include_attachments:
2749
+ A flag indicating whether to also ingest attachments with the page.
2724
2750
  gen_doc_summaries:
2725
2751
  Whether to auto-generate document summaries (uses LLM)
2726
2752
  gen_doc_questions:
@@ -2762,6 +2788,7 @@ class H2OGPTEAsync:
2762
2788
  page_ids=[page_id] if isinstance(page_id, str) else page_id,
2763
2789
  credentials=rest.ConfluenceCredentials(**credentials.__dict__),
2764
2790
  metadata=metadata,
2791
+ include_attachments=include_attachments,
2765
2792
  ),
2766
2793
  gen_doc_summaries=gen_doc_summaries,
2767
2794
  gen_doc_questions=gen_doc_questions,
@@ -2939,7 +2966,20 @@ class H2OGPTEAsync:
2939
2966
  handwriting_check:
2940
2967
  Check pages for handwriting. Will use specialized models if handwriting is found.
2941
2968
  metadata:
2942
- Metadata to be associated with the document.
2969
+ Dictionary mapping upload_ids to their metadata. Each key must be an upload_id
2970
+ from the upload_ids list, and each value is a dictionary of metadata key-value
2971
+ pairs to associate with that document.
2972
+
2973
+ Example::
2974
+
2975
+ # Single document
2976
+ metadata = {upload_id: {"category": "reports", "year": "2024"}}
2977
+
2978
+ # Multiple documents
2979
+ metadata = {
2980
+ upload_id_1: {"category": "reports"},
2981
+ upload_id_2: {"category": "invoices"}
2982
+ }
2943
2983
  timeout:
2944
2984
  Timeout in seconds.
2945
2985
  ingest_mode:
@@ -3830,6 +3870,29 @@ class H2OGPTEAsync:
3830
3870
  )
3831
3871
  return [GroupSharePermission(**d.to_dict()) for d in response]
3832
3872
 
3873
+ async def list_collection_public_permissions(self, collection_id: str) -> List[str]:
3874
+ """Returns the public permissions for a given collection.
3875
+
3876
+ The returned list contains the permission strings that apply to
3877
+ public access of the collection.
3878
+
3879
+ Args:
3880
+ collection_id:
3881
+ ID of the collection to inspect.
3882
+
3883
+ Returns:
3884
+ list of str: Public permissions list for the given collection.
3885
+ """
3886
+ header = await self._get_auth_header()
3887
+ async with self._RESTClient(self) as rest_client:
3888
+ response = await _rest_to_client_exceptions(
3889
+ rest_client.collection_api.list_collection_public_permissions(
3890
+ collection_id=collection_id,
3891
+ _headers=header,
3892
+ )
3893
+ )
3894
+ return response
3895
+
3833
3896
  async def list_users(self, offset: int, limit: int) -> List[User]:
3834
3897
  """List system users.
3835
3898
 
@@ -4722,6 +4785,11 @@ class H2OGPTEAsync:
4722
4785
  Requires 1 LLM or Agent call.
4723
4786
  :code:`"agent_only"` Agent Only - Answer the query with only original files passed to agent.
4724
4787
  Requires 1 Agent call.
4788
+ :code:`"agentic_rag"` Agentic RAG - Agent with RAG tool that retrieves and answers from collection.
4789
+ Requires 1 Agent call with RAG tool execution.
4790
+ :code:`"rlm_rag"` RLM RAG - Agent programmatically analyzes documents using Python code
4791
+ execution and sub-LLM calls. Best for complex multi-hop reasoning over large documents.
4792
+ Requires 1 Agent call.
4725
4793
  :code:`"rag"` RAG (Retrieval Augmented Generation) - Use supporting document contexts
4726
4794
  to answer the query. Requires 1 LLM or Agent call.
4727
4795
  :code:`"hyde1"` LLM Only + RAG composite - HyDE RAG (Hypothetical Document Embedding).
@@ -7387,6 +7455,41 @@ class H2OGPTEAsync:
7387
7455
  async def add_custom_agent_tool(
7388
7456
  self, tool_type: str, tool_args: dict, custom_tool_path: Optional[str] = None
7389
7457
  ) -> list:
7458
+ """Adds a custom agent tool.
7459
+
7460
+ Args:
7461
+ tool_type: The type of custom tool being added. Valid values:
7462
+ - 'local_mcp': Model Context Protocol server running locally
7463
+ - 'remote_mcp': Model Context Protocol server running remotely
7464
+ - 'browser_action': Custom browser automation actions
7465
+ - 'general_code': General purpose code execution tools
7466
+
7467
+ tool_args: Dictionary containing tool-specific arguments. Structure varies by tool_type:
7468
+
7469
+ For 'remote_mcp':
7470
+ {
7471
+ "mcp_config_json": "JSON string with MCP server configuration",
7472
+ "enable_by_default": True/False (optional, defaults to True)
7473
+ }
7474
+
7475
+ For 'local_mcp', 'browser_action', and 'general_code':
7476
+ {
7477
+ "tool_name": "string (optional, defaults to filename without extension)",
7478
+ "description": "string (optional, tool description)",
7479
+ "enable_by_default": True/False (optional, defaults to True),
7480
+ "should_unzip": True/False (optional, for general_code .zip files only),
7481
+ "tool_usage_mode": ["runner", "creator"] (optional list of strings, for remote_mcp)
7482
+ }
7483
+
7484
+ custom_tool_path: Path to the tool file to upload (optional). Requirements vary by tool_type:
7485
+ - 'local_mcp': .zip file containing MCP server code
7486
+ - 'remote_mcp': Optional .json file with MCP configuration
7487
+ - 'browser_action': .py file (must start with 'browser_') or .zip containing browser action scripts
7488
+ - 'general_code': .py or .zip file with custom code
7489
+
7490
+ Returns:
7491
+ list: List of created custom agent tool IDs
7492
+ """
7390
7493
  header = await self._get_auth_header()
7391
7494
  custom_tool_path = str(custom_tool_path) if custom_tool_path else None
7392
7495
  async with self._RESTClient(self) as rest_client:
@@ -7444,6 +7547,96 @@ class H2OGPTEAsync:
7444
7547
  )
7445
7548
  return response.agent_custom_tool_id
7446
7549
 
7550
+ async def pause_chat(self, question_id: str) -> Result:
7551
+ """Pause a streaming chat response.
7552
+
7553
+ Args:
7554
+ question_id: The ID of the chat message/question to pause.
7555
+
7556
+ Returns:
7557
+ Result: Status of the pause operation.
7558
+
7559
+ Raises:
7560
+ Exception: If the user is not authorized to pause this chat or if the operation fails.
7561
+ """
7562
+ header = await self._get_auth_header()
7563
+ async with self._RESTClient(self) as rest_client:
7564
+ await _rest_to_client_exceptions(
7565
+ rest_client.chat_api.pause_chat_message(
7566
+ question_id=question_id, _headers=header
7567
+ )
7568
+ )
7569
+ return Result(status="completed")
7570
+
7571
+ async def resume_chat(self, question_id: str) -> Result:
7572
+ """Resume a paused chat response.
7573
+
7574
+ Args:
7575
+ question_id: The ID of the chat message/question to resume.
7576
+
7577
+ Returns:
7578
+ Result: Status of the resume operation.
7579
+
7580
+ Raises:
7581
+ Exception: If the user is not authorized to resume this chat or if the operation fails.
7582
+ """
7583
+ header = await self._get_auth_header()
7584
+ async with self._RESTClient(self) as rest_client:
7585
+ await _rest_to_client_exceptions(
7586
+ rest_client.chat_api.resume_chat_message(
7587
+ question_id=question_id, _headers=header
7588
+ )
7589
+ )
7590
+ return Result(status="completed")
7591
+
7592
+ async def finish_chat(self, question_id: str) -> Result:
7593
+ """Signal the LLM to complete its current thought and finish naturally.
7594
+
7595
+ Unlike stop_chat which immediately halts response generation, finish_chat allows
7596
+ the LLM to complete its current thought naturally, providing a more coherent ending.
7597
+
7598
+ Args:
7599
+ question_id: The ID of the chat message/question to finish gracefully.
7600
+
7601
+ Returns:
7602
+ Result: Status of the finish operation.
7603
+
7604
+ Raises:
7605
+ Exception: If the user is not authorized to finish this chat or if the operation fails.
7606
+ """
7607
+ header = await self._get_auth_header()
7608
+ async with self._RESTClient(self) as rest_client:
7609
+ await _rest_to_client_exceptions(
7610
+ rest_client.chat_api.finish_chat_message(
7611
+ question_id=question_id, _headers=header
7612
+ )
7613
+ )
7614
+ return Result(status="completed")
7615
+
7616
+ async def stop_chat(self, question_id: str) -> Result:
7617
+ """Immediately stop/cancel a streaming chat response.
7618
+
7619
+ This will immediately halt response generation, which may result in an incomplete
7620
+ sentence or thought. For a more graceful termination, use finish_chat instead.
7621
+
7622
+ Args:
7623
+ question_id: The ID of the chat message/question to stop immediately.
7624
+
7625
+ Returns:
7626
+ Result: Status of the cancel operation.
7627
+
7628
+ Raises:
7629
+ Exception: If the user is not authorized to cancel this chat or if the operation fails.
7630
+ """
7631
+ header = await self._get_auth_header()
7632
+ async with self._RESTClient(self) as rest_client:
7633
+ await _rest_to_client_exceptions(
7634
+ rest_client.chat_api.stop_chat_message(
7635
+ question_id=question_id, _headers=header
7636
+ )
7637
+ )
7638
+ return Result(status="completed")
7639
+
7447
7640
  async def get_custom_agent_tools(self) -> List[dict]:
7448
7641
  """Gets all custom agent tools for the current user.
7449
7642