h2ogpte 1.6.54rc4__py3-none-any.whl → 1.7.0rc1__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.
- h2ogpte/__init__.py +1 -1
- h2ogpte/h2ogpte.py +184 -20
- h2ogpte/h2ogpte_async.py +184 -20
- h2ogpte/rest_async/__init__.py +3 -2
- h2ogpte/rest_async/api/agents_api.py +25 -25
- h2ogpte/rest_async/api/chat_api.py +1077 -21
- h2ogpte/rest_async/api/models_api.py +35 -67
- h2ogpte/rest_async/api_client.py +1 -1
- h2ogpte/rest_async/configuration.py +1 -1
- h2ogpte/rest_async/models/__init__.py +2 -1
- h2ogpte/rest_async/models/chat_completion_request.py +6 -2
- h2ogpte/rest_async/models/chat_settings.py +6 -2
- h2ogpte/rest_async/models/chat_settings_tags.py +140 -0
- h2ogpte/rest_async/models/extractor.py +26 -2
- h2ogpte/rest_async/models/extractor_create_request.py +29 -5
- h2ogpte/rest_async/models/ingest_from_confluence_body.py +4 -2
- h2ogpte/rest_async/models/{create_topic_model_job_request.py → tag_filter.py} +11 -9
- h2ogpte/rest_sync/__init__.py +3 -2
- h2ogpte/rest_sync/api/agents_api.py +25 -25
- h2ogpte/rest_sync/api/chat_api.py +1077 -21
- h2ogpte/rest_sync/api/models_api.py +35 -67
- h2ogpte/rest_sync/api_client.py +1 -1
- h2ogpte/rest_sync/configuration.py +1 -1
- h2ogpte/rest_sync/models/__init__.py +2 -1
- h2ogpte/rest_sync/models/chat_completion_request.py +6 -2
- h2ogpte/rest_sync/models/chat_settings.py +6 -2
- h2ogpte/rest_sync/models/chat_settings_tags.py +140 -0
- h2ogpte/rest_sync/models/extractor.py +26 -2
- h2ogpte/rest_sync/models/extractor_create_request.py +29 -5
- h2ogpte/rest_sync/models/ingest_from_confluence_body.py +4 -2
- h2ogpte/rest_sync/models/{create_topic_model_job_request.py → tag_filter.py} +11 -9
- h2ogpte/session.py +13 -6
- h2ogpte/session_async.py +11 -3
- h2ogpte/types.py +27 -1
- {h2ogpte-1.6.54rc4.dist-info → h2ogpte-1.7.0rc1.dist-info}/METADATA +1 -1
- {h2ogpte-1.6.54rc4.dist-info → h2ogpte-1.7.0rc1.dist-info}/RECORD +39 -37
- {h2ogpte-1.6.54rc4.dist-info → h2ogpte-1.7.0rc1.dist-info}/WHEEL +1 -1
- {h2ogpte-1.6.54rc4.dist-info → h2ogpte-1.7.0rc1.dist-info}/entry_points.txt +0 -0
- {h2ogpte-1.6.54rc4.dist-info → h2ogpte-1.7.0rc1.dist-info}/top_level.txt +0 -0
h2ogpte/__init__.py
CHANGED
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],
|
|
@@ -2496,6 +2513,7 @@ class H2OGPTE(H2OGPTESyncBase):
|
|
|
2496
2513
|
base_url: str,
|
|
2497
2514
|
page_id: Union[str, List[str]],
|
|
2498
2515
|
credentials: ConfluenceCredential,
|
|
2516
|
+
include_attachments: Union[bool, None] = None,
|
|
2499
2517
|
gen_doc_summaries: Union[bool, None] = None,
|
|
2500
2518
|
gen_doc_questions: Union[bool, None] = None,
|
|
2501
2519
|
audio_input_language: Union[str, None] = None,
|
|
@@ -2519,6 +2537,8 @@ class H2OGPTE(H2OGPTESyncBase):
|
|
|
2519
2537
|
The page id or ids of pages to be ingested.
|
|
2520
2538
|
credentials:
|
|
2521
2539
|
The object with Confluence credentials.
|
|
2540
|
+
include_attachments:
|
|
2541
|
+
A flag indicating whether to also ingest attachments with the page.
|
|
2522
2542
|
gen_doc_summaries:
|
|
2523
2543
|
Whether to auto-generate document summaries (uses LLM)
|
|
2524
2544
|
gen_doc_questions:
|
|
@@ -2560,6 +2580,7 @@ class H2OGPTE(H2OGPTESyncBase):
|
|
|
2560
2580
|
page_ids=[page_id] if isinstance(page_id, str) else page_id,
|
|
2561
2581
|
credentials=rest.ConfluenceCredentials(**credentials.__dict__),
|
|
2562
2582
|
metadata=metadata,
|
|
2583
|
+
include_attachments=include_attachments,
|
|
2563
2584
|
),
|
|
2564
2585
|
gen_doc_summaries=gen_doc_summaries,
|
|
2565
2586
|
gen_doc_questions=gen_doc_questions,
|
|
@@ -2741,7 +2762,20 @@ class H2OGPTE(H2OGPTESyncBase):
|
|
|
2741
2762
|
handwriting_check:
|
|
2742
2763
|
Check pages for handwriting. Will use specialized models if handwriting is found.
|
|
2743
2764
|
metadata:
|
|
2744
|
-
|
|
2765
|
+
Dictionary mapping upload_ids to their metadata. Each key must be an upload_id
|
|
2766
|
+
from the upload_ids list, and each value is a dictionary of metadata key-value
|
|
2767
|
+
pairs to associate with that document.
|
|
2768
|
+
|
|
2769
|
+
Example::
|
|
2770
|
+
|
|
2771
|
+
# Single document
|
|
2772
|
+
metadata = {upload_id: {"category": "reports", "year": "2024"}}
|
|
2773
|
+
|
|
2774
|
+
# Multiple documents
|
|
2775
|
+
metadata = {
|
|
2776
|
+
upload_id_1: {"category": "reports"},
|
|
2777
|
+
upload_id_2: {"category": "invoices"}
|
|
2778
|
+
}
|
|
2745
2779
|
timeout:
|
|
2746
2780
|
Timeout in seconds.
|
|
2747
2781
|
ingest_mode:
|
|
@@ -4514,6 +4548,11 @@ class H2OGPTE(H2OGPTESyncBase):
|
|
|
4514
4548
|
Requires 1 LLM or Agent call.
|
|
4515
4549
|
:code:`"agent_only"` Agent Only - Answer the query with only original files passed to agent.
|
|
4516
4550
|
Requires 1 Agent call.
|
|
4551
|
+
:code:`"agentic_rag"` Agentic RAG - Agent with RAG tool that retrieves and answers from collection.
|
|
4552
|
+
Requires 1 Agent call with RAG tool execution.
|
|
4553
|
+
:code:`"rlm_rag"` RLM RAG - Agent programmatically analyzes documents using Python code
|
|
4554
|
+
execution and sub-LLM calls. Best for complex multi-hop reasoning over large documents.
|
|
4555
|
+
Requires 1 Agent call.
|
|
4517
4556
|
:code:`"rag"` RAG (Retrieval Augmented Generation) - Use supporting document contexts
|
|
4518
4557
|
to answer the query. Requires 1 LLM or Agent call.
|
|
4519
4558
|
:code:`"hyde1"` LLM Only + RAG composite - HyDE RAG (Hypothetical Document Embedding).
|
|
@@ -7132,6 +7171,41 @@ class H2OGPTE(H2OGPTESyncBase):
|
|
|
7132
7171
|
def add_custom_agent_tool(
|
|
7133
7172
|
self, tool_type: str, tool_args: dict, custom_tool_path: Optional[str] = None
|
|
7134
7173
|
) -> list:
|
|
7174
|
+
"""Adds a custom agent tool.
|
|
7175
|
+
|
|
7176
|
+
Args:
|
|
7177
|
+
tool_type: The type of custom tool being added. Valid values:
|
|
7178
|
+
- 'local_mcp': Model Context Protocol server running locally
|
|
7179
|
+
- 'remote_mcp': Model Context Protocol server running remotely
|
|
7180
|
+
- 'browser_action': Custom browser automation actions
|
|
7181
|
+
- 'general_code': General purpose code execution tools
|
|
7182
|
+
|
|
7183
|
+
tool_args: Dictionary containing tool-specific arguments. Structure varies by tool_type:
|
|
7184
|
+
|
|
7185
|
+
For 'remote_mcp':
|
|
7186
|
+
{
|
|
7187
|
+
"mcp_config_json": "JSON string with MCP server configuration",
|
|
7188
|
+
"enable_by_default": True/False (optional, defaults to True)
|
|
7189
|
+
}
|
|
7190
|
+
|
|
7191
|
+
For 'local_mcp', 'browser_action', and 'general_code':
|
|
7192
|
+
{
|
|
7193
|
+
"tool_name": "string (optional, defaults to filename without extension)",
|
|
7194
|
+
"description": "string (optional, tool description)",
|
|
7195
|
+
"enable_by_default": True/False (optional, defaults to True),
|
|
7196
|
+
"should_unzip": True/False (optional, for general_code .zip files only),
|
|
7197
|
+
"tool_usage_mode": ["runner", "creator"] (optional list of strings, for remote_mcp)
|
|
7198
|
+
}
|
|
7199
|
+
|
|
7200
|
+
custom_tool_path: Path to the tool file to upload (optional). Requirements vary by tool_type:
|
|
7201
|
+
- 'local_mcp': .zip file containing MCP server code
|
|
7202
|
+
- 'remote_mcp': Optional .json file with MCP configuration
|
|
7203
|
+
- 'browser_action': .py file (must start with 'browser_') or .zip containing browser action scripts
|
|
7204
|
+
- 'general_code': .py or .zip file with custom code
|
|
7205
|
+
|
|
7206
|
+
Returns:
|
|
7207
|
+
list: List of created custom agent tool IDs
|
|
7208
|
+
"""
|
|
7135
7209
|
header = self._get_auth_header()
|
|
7136
7210
|
custom_tool_path = str(custom_tool_path) if custom_tool_path else None
|
|
7137
7211
|
with self._RESTClient(self) as rest_client:
|
|
@@ -7189,6 +7263,96 @@ class H2OGPTE(H2OGPTESyncBase):
|
|
|
7189
7263
|
)
|
|
7190
7264
|
return response.agent_custom_tool_id
|
|
7191
7265
|
|
|
7266
|
+
def pause_chat(self, question_id: str) -> Result:
|
|
7267
|
+
"""Pause a streaming chat response.
|
|
7268
|
+
|
|
7269
|
+
Args:
|
|
7270
|
+
question_id: The ID of the chat message/question to pause.
|
|
7271
|
+
|
|
7272
|
+
Returns:
|
|
7273
|
+
Result: Status of the pause operation.
|
|
7274
|
+
|
|
7275
|
+
Raises:
|
|
7276
|
+
Exception: If the user is not authorized to pause this chat or if the operation fails.
|
|
7277
|
+
"""
|
|
7278
|
+
header = self._get_auth_header()
|
|
7279
|
+
with self._RESTClient(self) as rest_client:
|
|
7280
|
+
_rest_to_client_exceptions(
|
|
7281
|
+
lambda: rest_client.chat_api.pause_chat_message(
|
|
7282
|
+
question_id=question_id, _headers=header
|
|
7283
|
+
)
|
|
7284
|
+
)
|
|
7285
|
+
return Result(status="completed")
|
|
7286
|
+
|
|
7287
|
+
def resume_chat(self, question_id: str) -> Result:
|
|
7288
|
+
"""Resume a paused chat response.
|
|
7289
|
+
|
|
7290
|
+
Args:
|
|
7291
|
+
question_id: The ID of the chat message/question to resume.
|
|
7292
|
+
|
|
7293
|
+
Returns:
|
|
7294
|
+
Result: Status of the resume operation.
|
|
7295
|
+
|
|
7296
|
+
Raises:
|
|
7297
|
+
Exception: If the user is not authorized to resume this chat or if the operation fails.
|
|
7298
|
+
"""
|
|
7299
|
+
header = self._get_auth_header()
|
|
7300
|
+
with self._RESTClient(self) as rest_client:
|
|
7301
|
+
_rest_to_client_exceptions(
|
|
7302
|
+
lambda: rest_client.chat_api.resume_chat_message(
|
|
7303
|
+
question_id=question_id, _headers=header
|
|
7304
|
+
)
|
|
7305
|
+
)
|
|
7306
|
+
return Result(status="completed")
|
|
7307
|
+
|
|
7308
|
+
def finish_chat(self, question_id: str) -> Result:
|
|
7309
|
+
"""Signal the LLM to complete its current thought and finish naturally.
|
|
7310
|
+
|
|
7311
|
+
Unlike stop_chat which immediately halts response generation, finish_chat allows
|
|
7312
|
+
the LLM to complete its current thought naturally, providing a more coherent ending.
|
|
7313
|
+
|
|
7314
|
+
Args:
|
|
7315
|
+
question_id: The ID of the chat message/question to finish gracefully.
|
|
7316
|
+
|
|
7317
|
+
Returns:
|
|
7318
|
+
Result: Status of the finish operation.
|
|
7319
|
+
|
|
7320
|
+
Raises:
|
|
7321
|
+
Exception: If the user is not authorized to finish this chat or if the operation fails.
|
|
7322
|
+
"""
|
|
7323
|
+
header = self._get_auth_header()
|
|
7324
|
+
with self._RESTClient(self) as rest_client:
|
|
7325
|
+
_rest_to_client_exceptions(
|
|
7326
|
+
lambda: rest_client.chat_api.finish_chat_message(
|
|
7327
|
+
question_id=question_id, _headers=header
|
|
7328
|
+
)
|
|
7329
|
+
)
|
|
7330
|
+
return Result(status="completed")
|
|
7331
|
+
|
|
7332
|
+
def stop_chat(self, question_id: str) -> Result:
|
|
7333
|
+
"""Immediately stop/cancel a streaming chat response.
|
|
7334
|
+
|
|
7335
|
+
This will immediately halt response generation, which may result in an incomplete
|
|
7336
|
+
sentence or thought. For a more graceful termination, use finish_chat instead.
|
|
7337
|
+
|
|
7338
|
+
Args:
|
|
7339
|
+
question_id: The ID of the chat message/question to stop immediately.
|
|
7340
|
+
|
|
7341
|
+
Returns:
|
|
7342
|
+
Result: Status of the cancel operation.
|
|
7343
|
+
|
|
7344
|
+
Raises:
|
|
7345
|
+
Exception: If the user is not authorized to cancel this chat or if the operation fails.
|
|
7346
|
+
"""
|
|
7347
|
+
header = self._get_auth_header()
|
|
7348
|
+
with self._RESTClient(self) as rest_client:
|
|
7349
|
+
_rest_to_client_exceptions(
|
|
7350
|
+
lambda: rest_client.chat_api.stop_chat_message(
|
|
7351
|
+
question_id=question_id, _headers=header
|
|
7352
|
+
)
|
|
7353
|
+
)
|
|
7354
|
+
return Result(status="completed")
|
|
7355
|
+
|
|
7192
7356
|
def get_custom_agent_tools(self) -> List[dict]:
|
|
7193
7357
|
"""Gets all custom agent tools for the current user.
|
|
7194
7358
|
|
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],
|
|
@@ -2698,6 +2715,7 @@ class H2OGPTEAsync:
|
|
|
2698
2715
|
base_url: str,
|
|
2699
2716
|
page_id: Union[str, List[str]],
|
|
2700
2717
|
credentials: ConfluenceCredential,
|
|
2718
|
+
include_attachments: Union[bool, None] = None,
|
|
2701
2719
|
gen_doc_summaries: Union[bool, None] = None,
|
|
2702
2720
|
gen_doc_questions: Union[bool, None] = None,
|
|
2703
2721
|
audio_input_language: Union[str, None] = None,
|
|
@@ -2721,6 +2739,8 @@ class H2OGPTEAsync:
|
|
|
2721
2739
|
The page id or ids of pages to be ingested.
|
|
2722
2740
|
credentials:
|
|
2723
2741
|
The object with Confluence credentials.
|
|
2742
|
+
include_attachments:
|
|
2743
|
+
A flag indicating whether to also ingest attachments with the page.
|
|
2724
2744
|
gen_doc_summaries:
|
|
2725
2745
|
Whether to auto-generate document summaries (uses LLM)
|
|
2726
2746
|
gen_doc_questions:
|
|
@@ -2762,6 +2782,7 @@ class H2OGPTEAsync:
|
|
|
2762
2782
|
page_ids=[page_id] if isinstance(page_id, str) else page_id,
|
|
2763
2783
|
credentials=rest.ConfluenceCredentials(**credentials.__dict__),
|
|
2764
2784
|
metadata=metadata,
|
|
2785
|
+
include_attachments=include_attachments,
|
|
2765
2786
|
),
|
|
2766
2787
|
gen_doc_summaries=gen_doc_summaries,
|
|
2767
2788
|
gen_doc_questions=gen_doc_questions,
|
|
@@ -2939,7 +2960,20 @@ class H2OGPTEAsync:
|
|
|
2939
2960
|
handwriting_check:
|
|
2940
2961
|
Check pages for handwriting. Will use specialized models if handwriting is found.
|
|
2941
2962
|
metadata:
|
|
2942
|
-
|
|
2963
|
+
Dictionary mapping upload_ids to their metadata. Each key must be an upload_id
|
|
2964
|
+
from the upload_ids list, and each value is a dictionary of metadata key-value
|
|
2965
|
+
pairs to associate with that document.
|
|
2966
|
+
|
|
2967
|
+
Example::
|
|
2968
|
+
|
|
2969
|
+
# Single document
|
|
2970
|
+
metadata = {upload_id: {"category": "reports", "year": "2024"}}
|
|
2971
|
+
|
|
2972
|
+
# Multiple documents
|
|
2973
|
+
metadata = {
|
|
2974
|
+
upload_id_1: {"category": "reports"},
|
|
2975
|
+
upload_id_2: {"category": "invoices"}
|
|
2976
|
+
}
|
|
2943
2977
|
timeout:
|
|
2944
2978
|
Timeout in seconds.
|
|
2945
2979
|
ingest_mode:
|
|
@@ -4722,6 +4756,11 @@ class H2OGPTEAsync:
|
|
|
4722
4756
|
Requires 1 LLM or Agent call.
|
|
4723
4757
|
:code:`"agent_only"` Agent Only - Answer the query with only original files passed to agent.
|
|
4724
4758
|
Requires 1 Agent call.
|
|
4759
|
+
:code:`"agentic_rag"` Agentic RAG - Agent with RAG tool that retrieves and answers from collection.
|
|
4760
|
+
Requires 1 Agent call with RAG tool execution.
|
|
4761
|
+
:code:`"rlm_rag"` RLM RAG - Agent programmatically analyzes documents using Python code
|
|
4762
|
+
execution and sub-LLM calls. Best for complex multi-hop reasoning over large documents.
|
|
4763
|
+
Requires 1 Agent call.
|
|
4725
4764
|
:code:`"rag"` RAG (Retrieval Augmented Generation) - Use supporting document contexts
|
|
4726
4765
|
to answer the query. Requires 1 LLM or Agent call.
|
|
4727
4766
|
:code:`"hyde1"` LLM Only + RAG composite - HyDE RAG (Hypothetical Document Embedding).
|
|
@@ -7387,6 +7426,41 @@ class H2OGPTEAsync:
|
|
|
7387
7426
|
async def add_custom_agent_tool(
|
|
7388
7427
|
self, tool_type: str, tool_args: dict, custom_tool_path: Optional[str] = None
|
|
7389
7428
|
) -> list:
|
|
7429
|
+
"""Adds a custom agent tool.
|
|
7430
|
+
|
|
7431
|
+
Args:
|
|
7432
|
+
tool_type: The type of custom tool being added. Valid values:
|
|
7433
|
+
- 'local_mcp': Model Context Protocol server running locally
|
|
7434
|
+
- 'remote_mcp': Model Context Protocol server running remotely
|
|
7435
|
+
- 'browser_action': Custom browser automation actions
|
|
7436
|
+
- 'general_code': General purpose code execution tools
|
|
7437
|
+
|
|
7438
|
+
tool_args: Dictionary containing tool-specific arguments. Structure varies by tool_type:
|
|
7439
|
+
|
|
7440
|
+
For 'remote_mcp':
|
|
7441
|
+
{
|
|
7442
|
+
"mcp_config_json": "JSON string with MCP server configuration",
|
|
7443
|
+
"enable_by_default": True/False (optional, defaults to True)
|
|
7444
|
+
}
|
|
7445
|
+
|
|
7446
|
+
For 'local_mcp', 'browser_action', and 'general_code':
|
|
7447
|
+
{
|
|
7448
|
+
"tool_name": "string (optional, defaults to filename without extension)",
|
|
7449
|
+
"description": "string (optional, tool description)",
|
|
7450
|
+
"enable_by_default": True/False (optional, defaults to True),
|
|
7451
|
+
"should_unzip": True/False (optional, for general_code .zip files only),
|
|
7452
|
+
"tool_usage_mode": ["runner", "creator"] (optional list of strings, for remote_mcp)
|
|
7453
|
+
}
|
|
7454
|
+
|
|
7455
|
+
custom_tool_path: Path to the tool file to upload (optional). Requirements vary by tool_type:
|
|
7456
|
+
- 'local_mcp': .zip file containing MCP server code
|
|
7457
|
+
- 'remote_mcp': Optional .json file with MCP configuration
|
|
7458
|
+
- 'browser_action': .py file (must start with 'browser_') or .zip containing browser action scripts
|
|
7459
|
+
- 'general_code': .py or .zip file with custom code
|
|
7460
|
+
|
|
7461
|
+
Returns:
|
|
7462
|
+
list: List of created custom agent tool IDs
|
|
7463
|
+
"""
|
|
7390
7464
|
header = await self._get_auth_header()
|
|
7391
7465
|
custom_tool_path = str(custom_tool_path) if custom_tool_path else None
|
|
7392
7466
|
async with self._RESTClient(self) as rest_client:
|
|
@@ -7444,6 +7518,96 @@ class H2OGPTEAsync:
|
|
|
7444
7518
|
)
|
|
7445
7519
|
return response.agent_custom_tool_id
|
|
7446
7520
|
|
|
7521
|
+
async def pause_chat(self, question_id: str) -> Result:
|
|
7522
|
+
"""Pause a streaming chat response.
|
|
7523
|
+
|
|
7524
|
+
Args:
|
|
7525
|
+
question_id: The ID of the chat message/question to pause.
|
|
7526
|
+
|
|
7527
|
+
Returns:
|
|
7528
|
+
Result: Status of the pause operation.
|
|
7529
|
+
|
|
7530
|
+
Raises:
|
|
7531
|
+
Exception: If the user is not authorized to pause this chat or if the operation fails.
|
|
7532
|
+
"""
|
|
7533
|
+
header = await self._get_auth_header()
|
|
7534
|
+
async with self._RESTClient(self) as rest_client:
|
|
7535
|
+
await _rest_to_client_exceptions(
|
|
7536
|
+
rest_client.chat_api.pause_chat_message(
|
|
7537
|
+
question_id=question_id, _headers=header
|
|
7538
|
+
)
|
|
7539
|
+
)
|
|
7540
|
+
return Result(status="completed")
|
|
7541
|
+
|
|
7542
|
+
async def resume_chat(self, question_id: str) -> Result:
|
|
7543
|
+
"""Resume a paused chat response.
|
|
7544
|
+
|
|
7545
|
+
Args:
|
|
7546
|
+
question_id: The ID of the chat message/question to resume.
|
|
7547
|
+
|
|
7548
|
+
Returns:
|
|
7549
|
+
Result: Status of the resume operation.
|
|
7550
|
+
|
|
7551
|
+
Raises:
|
|
7552
|
+
Exception: If the user is not authorized to resume this chat or if the operation fails.
|
|
7553
|
+
"""
|
|
7554
|
+
header = await self._get_auth_header()
|
|
7555
|
+
async with self._RESTClient(self) as rest_client:
|
|
7556
|
+
await _rest_to_client_exceptions(
|
|
7557
|
+
rest_client.chat_api.resume_chat_message(
|
|
7558
|
+
question_id=question_id, _headers=header
|
|
7559
|
+
)
|
|
7560
|
+
)
|
|
7561
|
+
return Result(status="completed")
|
|
7562
|
+
|
|
7563
|
+
async def finish_chat(self, question_id: str) -> Result:
|
|
7564
|
+
"""Signal the LLM to complete its current thought and finish naturally.
|
|
7565
|
+
|
|
7566
|
+
Unlike stop_chat which immediately halts response generation, finish_chat allows
|
|
7567
|
+
the LLM to complete its current thought naturally, providing a more coherent ending.
|
|
7568
|
+
|
|
7569
|
+
Args:
|
|
7570
|
+
question_id: The ID of the chat message/question to finish gracefully.
|
|
7571
|
+
|
|
7572
|
+
Returns:
|
|
7573
|
+
Result: Status of the finish operation.
|
|
7574
|
+
|
|
7575
|
+
Raises:
|
|
7576
|
+
Exception: If the user is not authorized to finish this chat or if the operation fails.
|
|
7577
|
+
"""
|
|
7578
|
+
header = await self._get_auth_header()
|
|
7579
|
+
async with self._RESTClient(self) as rest_client:
|
|
7580
|
+
await _rest_to_client_exceptions(
|
|
7581
|
+
rest_client.chat_api.finish_chat_message(
|
|
7582
|
+
question_id=question_id, _headers=header
|
|
7583
|
+
)
|
|
7584
|
+
)
|
|
7585
|
+
return Result(status="completed")
|
|
7586
|
+
|
|
7587
|
+
async def stop_chat(self, question_id: str) -> Result:
|
|
7588
|
+
"""Immediately stop/cancel a streaming chat response.
|
|
7589
|
+
|
|
7590
|
+
This will immediately halt response generation, which may result in an incomplete
|
|
7591
|
+
sentence or thought. For a more graceful termination, use finish_chat instead.
|
|
7592
|
+
|
|
7593
|
+
Args:
|
|
7594
|
+
question_id: The ID of the chat message/question to stop immediately.
|
|
7595
|
+
|
|
7596
|
+
Returns:
|
|
7597
|
+
Result: Status of the cancel operation.
|
|
7598
|
+
|
|
7599
|
+
Raises:
|
|
7600
|
+
Exception: If the user is not authorized to cancel this chat or if the operation fails.
|
|
7601
|
+
"""
|
|
7602
|
+
header = await self._get_auth_header()
|
|
7603
|
+
async with self._RESTClient(self) as rest_client:
|
|
7604
|
+
await _rest_to_client_exceptions(
|
|
7605
|
+
rest_client.chat_api.stop_chat_message(
|
|
7606
|
+
question_id=question_id, _headers=header
|
|
7607
|
+
)
|
|
7608
|
+
)
|
|
7609
|
+
return Result(status="completed")
|
|
7610
|
+
|
|
7447
7611
|
async def get_custom_agent_tools(self) -> List[dict]:
|
|
7448
7612
|
"""Gets all custom agent tools for the current user.
|
|
7449
7613
|
|
h2ogpte/rest_async/__init__.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
""" # noqa: E501
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
__version__ = "1.
|
|
17
|
+
__version__ = "1.7.0-dev1"
|
|
18
18
|
|
|
19
19
|
# import apis into sdk package
|
|
20
20
|
from h2ogpte.rest_async.api.api_keys_api import APIKeysApi
|
|
@@ -69,6 +69,7 @@ from h2ogpte.rest_async.models.chat_message_reference import ChatMessageReferenc
|
|
|
69
69
|
from h2ogpte.rest_async.models.chat_session import ChatSession
|
|
70
70
|
from h2ogpte.rest_async.models.chat_session_update_request import ChatSessionUpdateRequest
|
|
71
71
|
from h2ogpte.rest_async.models.chat_settings import ChatSettings
|
|
72
|
+
from h2ogpte.rest_async.models.chat_settings_tags import ChatSettingsTags
|
|
72
73
|
from h2ogpte.rest_async.models.chunk import Chunk
|
|
73
74
|
from h2ogpte.rest_async.models.chunk_search_result import ChunkSearchResult
|
|
74
75
|
from h2ogpte.rest_async.models.collection import Collection
|
|
@@ -88,7 +89,6 @@ from h2ogpte.rest_async.models.create_import_collection_to_collection_job_reques
|
|
|
88
89
|
from h2ogpte.rest_async.models.create_insert_document_to_collection_job_request import CreateInsertDocumentToCollectionJobRequest
|
|
89
90
|
from h2ogpte.rest_async.models.create_secret201_response import CreateSecret201Response
|
|
90
91
|
from h2ogpte.rest_async.models.create_secret_request import CreateSecretRequest
|
|
91
|
-
from h2ogpte.rest_async.models.create_topic_model_job_request import CreateTopicModelJobRequest
|
|
92
92
|
from h2ogpte.rest_async.models.delete_chat_sessions_job_request import DeleteChatSessionsJobRequest
|
|
93
93
|
from h2ogpte.rest_async.models.delete_collections_job_request import DeleteCollectionsJobRequest
|
|
94
94
|
from h2ogpte.rest_async.models.delete_documents_job_request import DeleteDocumentsJobRequest
|
|
@@ -158,6 +158,7 @@ from h2ogpte.rest_async.models.suggested_question import SuggestedQuestion
|
|
|
158
158
|
from h2ogpte.rest_async.models.summarize_request import SummarizeRequest
|
|
159
159
|
from h2ogpte.rest_async.models.tag import Tag
|
|
160
160
|
from h2ogpte.rest_async.models.tag_create_request import TagCreateRequest
|
|
161
|
+
from h2ogpte.rest_async.models.tag_filter import TagFilter
|
|
161
162
|
from h2ogpte.rest_async.models.tag_update_request import TagUpdateRequest
|
|
162
163
|
from h2ogpte.rest_async.models.update_agent_key_request import UpdateAgentKeyRequest
|
|
163
164
|
from h2ogpte.rest_async.models.update_agent_tool_preference_request import UpdateAgentToolPreferenceRequest
|