h2ogpte 1.6.41rc5__py3-none-any.whl → 1.6.43__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/cli/__init__.py +0 -0
- h2ogpte/cli/commands/__init__.py +0 -0
- h2ogpte/cli/commands/command_handlers/__init__.py +0 -0
- h2ogpte/cli/commands/command_handlers/agent.py +41 -0
- h2ogpte/cli/commands/command_handlers/chat.py +37 -0
- h2ogpte/cli/commands/command_handlers/clear.py +8 -0
- h2ogpte/cli/commands/command_handlers/collection.py +67 -0
- h2ogpte/cli/commands/command_handlers/config.py +113 -0
- h2ogpte/cli/commands/command_handlers/disconnect.py +36 -0
- h2ogpte/cli/commands/command_handlers/exit.py +37 -0
- h2ogpte/cli/commands/command_handlers/help.py +8 -0
- h2ogpte/cli/commands/command_handlers/history.py +29 -0
- h2ogpte/cli/commands/command_handlers/rag.py +146 -0
- h2ogpte/cli/commands/command_handlers/research_agent.py +45 -0
- h2ogpte/cli/commands/command_handlers/session.py +77 -0
- h2ogpte/cli/commands/command_handlers/status.py +33 -0
- h2ogpte/cli/commands/dispatcher.py +79 -0
- h2ogpte/cli/core/__init__.py +0 -0
- h2ogpte/cli/core/app.py +105 -0
- h2ogpte/cli/core/config.py +199 -0
- h2ogpte/cli/core/encryption.py +104 -0
- h2ogpte/cli/core/session.py +171 -0
- h2ogpte/cli/integrations/__init__.py +0 -0
- h2ogpte/cli/integrations/agent.py +338 -0
- h2ogpte/cli/integrations/rag.py +442 -0
- h2ogpte/cli/main.py +90 -0
- h2ogpte/cli/ui/__init__.py +0 -0
- h2ogpte/cli/ui/hbot_prompt.py +435 -0
- h2ogpte/cli/ui/prompts.py +129 -0
- h2ogpte/cli/ui/status_bar.py +133 -0
- h2ogpte/cli/utils/__init__.py +0 -0
- h2ogpte/cli/utils/file_manager.py +411 -0
- h2ogpte/connectors.py +11 -0
- h2ogpte/h2ogpte.py +619 -69
- h2ogpte/h2ogpte_async.py +631 -70
- h2ogpte/h2ogpte_sync_base.py +8 -1
- h2ogpte/rest_async/__init__.py +8 -3
- h2ogpte/rest_async/api/chat_api.py +29 -0
- h2ogpte/rest_async/api/collections_api.py +293 -0
- h2ogpte/rest_async/api/document_ingestion_api.py +1365 -436
- h2ogpte/rest_async/api/extractors_api.py +2874 -70
- h2ogpte/rest_async/api/prompt_templates_api.py +32 -32
- h2ogpte/rest_async/api_client.py +1 -1
- h2ogpte/rest_async/configuration.py +1 -1
- h2ogpte/rest_async/models/__init__.py +7 -2
- h2ogpte/rest_async/models/chat_completion.py +4 -2
- h2ogpte/rest_async/models/chat_completion_delta.py +5 -3
- h2ogpte/rest_async/models/chat_completion_request.py +1 -1
- h2ogpte/rest_async/models/chat_session.py +4 -2
- h2ogpte/rest_async/models/chat_settings.py +1 -1
- h2ogpte/rest_async/models/collection.py +4 -2
- h2ogpte/rest_async/models/collection_create_request.py +4 -2
- h2ogpte/rest_async/models/confluence_credentials.py +89 -0
- h2ogpte/rest_async/models/create_chat_session_request.py +87 -0
- h2ogpte/rest_async/models/extraction_request.py +1 -1
- h2ogpte/rest_async/models/extractor.py +4 -2
- h2ogpte/rest_async/models/guardrails_settings.py +8 -4
- h2ogpte/rest_async/models/guardrails_settings_create_request.py +1 -1
- h2ogpte/rest_async/models/ingest_from_confluence_body.py +97 -0
- h2ogpte/rest_async/models/process_document_job_request.py +1 -1
- h2ogpte/rest_async/models/question_request.py +1 -1
- h2ogpte/rest_async/models/{reset_and_share_prompt_template_request.py → reset_and_share_request.py} +6 -6
- 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
- h2ogpte/rest_async/models/summarize_request.py +1 -1
- h2ogpte/rest_async/models/update_collection_privacy_request.py +6 -4
- h2ogpte/rest_async/models/update_collection_workspace_request.py +87 -0
- h2ogpte/rest_async/models/update_extractor_privacy_request.py +87 -0
- h2ogpte/rest_sync/__init__.py +8 -3
- h2ogpte/rest_sync/api/chat_api.py +29 -0
- h2ogpte/rest_sync/api/collections_api.py +293 -0
- h2ogpte/rest_sync/api/document_ingestion_api.py +1365 -436
- h2ogpte/rest_sync/api/extractors_api.py +2874 -70
- h2ogpte/rest_sync/api/prompt_templates_api.py +32 -32
- h2ogpte/rest_sync/api_client.py +1 -1
- h2ogpte/rest_sync/configuration.py +1 -1
- h2ogpte/rest_sync/models/__init__.py +7 -2
- h2ogpte/rest_sync/models/chat_completion.py +4 -2
- h2ogpte/rest_sync/models/chat_completion_delta.py +5 -3
- h2ogpte/rest_sync/models/chat_completion_request.py +1 -1
- h2ogpte/rest_sync/models/chat_session.py +4 -2
- h2ogpte/rest_sync/models/chat_settings.py +1 -1
- h2ogpte/rest_sync/models/collection.py +4 -2
- h2ogpte/rest_sync/models/collection_create_request.py +4 -2
- h2ogpte/rest_sync/models/confluence_credentials.py +89 -0
- h2ogpte/rest_sync/models/create_chat_session_request.py +87 -0
- h2ogpte/rest_sync/models/extraction_request.py +1 -1
- h2ogpte/rest_sync/models/extractor.py +4 -2
- h2ogpte/rest_sync/models/guardrails_settings.py +8 -4
- h2ogpte/rest_sync/models/guardrails_settings_create_request.py +1 -1
- h2ogpte/rest_sync/models/ingest_from_confluence_body.py +97 -0
- h2ogpte/rest_sync/models/process_document_job_request.py +1 -1
- h2ogpte/rest_sync/models/question_request.py +1 -1
- h2ogpte/rest_sync/models/{reset_and_share_prompt_template_request.py → reset_and_share_request.py} +6 -6
- 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
- h2ogpte/rest_sync/models/summarize_request.py +1 -1
- h2ogpte/rest_sync/models/update_collection_privacy_request.py +6 -4
- h2ogpte/rest_sync/models/update_collection_workspace_request.py +87 -0
- h2ogpte/rest_sync/models/update_extractor_privacy_request.py +87 -0
- h2ogpte/session.py +14 -2
- h2ogpte/session_async.py +33 -6
- h2ogpte/types.py +9 -1
- {h2ogpte-1.6.41rc5.dist-info → h2ogpte-1.6.43.dist-info}/METADATA +5 -1
- {h2ogpte-1.6.41rc5.dist-info → h2ogpte-1.6.43.dist-info}/RECORD +107 -64
- h2ogpte-1.6.43.dist-info/entry_points.txt +2 -0
- {h2ogpte-1.6.41rc5.dist-info → h2ogpte-1.6.43.dist-info}/WHEEL +0 -0
- {h2ogpte-1.6.41rc5.dist-info → h2ogpte-1.6.43.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
h2oGPTe REST API
|
|
5
|
+
|
|
6
|
+
# Overview Users can easily interact with the h2oGPTe API through its REST API, allowing HTTP requests from any programming language. ## Authorization: Getting an API key Sign up/in at Enterprise h2oGPTe and generate one of the following two types of API keys: - **Global API key**: If a Collection is not specified when creating a new API Key, that key is considered to be a global API Key. Use global API Keys to grant full user impersonation and system-wide access to all of your work. Anyone with access to one of your global API Keys can create, delete, or interact with any of your past, current, and future Collections, Documents, Chats, and settings. - **Collection-specific API key**: Use Collection-specific API Keys to grant external access to only Chat with a specified Collection and make related API calls to it. Collection-specific API keys do not allow other API calls, such as creation, deletion, or access to other Collections or Chats. Access Enterprise h2oGPTe through your [H2O Generative AI](https://genai.h2o.ai/appstore) app store account, available with a freemium tier. ## Authorization: Using an API key All h2oGPTe REST API requests must include an API Key in the \"Authorization\" HTTP header, formatted as follows: ``` Authorization: Bearer sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ``` ```sh curl -X 'POST' \\ 'https://h2ogpte.genai.h2o.ai/api/v1/collections' \\ -H 'accept: application/json' \\ -H 'Content-Type: application/json' \\ -H 'Authorization: Bearer sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \\ -d '{ \"name\": \"The name of my Collection\", \"description\": \"The description of my Collection\", \"embedding_model\": \"BAAI/bge-large-en-v1.5\" }' ``` ## Interactive h2oGPTe API testing This page only showcases the h2oGPTe REST API; you can test it directly in the [Swagger UI](https://h2ogpte.genai.h2o.ai/swagger-ui/). Ensure that you are logged into your Enterprise h2oGPTe account.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: v1.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class UpdateCollectionWorkspaceRequest(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
UpdateCollectionWorkspaceRequest
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
workspace: StrictStr = Field(description="The name of the workspace to be associated with the collection.")
|
|
30
|
+
__properties: ClassVar[List[str]] = ["workspace"]
|
|
31
|
+
|
|
32
|
+
model_config = ConfigDict(
|
|
33
|
+
populate_by_name=True,
|
|
34
|
+
validate_assignment=True,
|
|
35
|
+
protected_namespaces=(),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def to_str(self) -> str:
|
|
40
|
+
"""Returns the string representation of the model using alias"""
|
|
41
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
42
|
+
|
|
43
|
+
def to_json(self) -> str:
|
|
44
|
+
"""Returns the JSON representation of the model using alias"""
|
|
45
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
46
|
+
return json.dumps(self.to_dict())
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
50
|
+
"""Create an instance of UpdateCollectionWorkspaceRequest from a JSON string"""
|
|
51
|
+
return cls.from_dict(json.loads(json_str))
|
|
52
|
+
|
|
53
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
54
|
+
"""Return the dictionary representation of the model using alias.
|
|
55
|
+
|
|
56
|
+
This has the following differences from calling pydantic's
|
|
57
|
+
`self.model_dump(by_alias=True)`:
|
|
58
|
+
|
|
59
|
+
* `None` is only added to the output dict for nullable fields that
|
|
60
|
+
were set at model initialization. Other fields with value `None`
|
|
61
|
+
are ignored.
|
|
62
|
+
"""
|
|
63
|
+
excluded_fields: Set[str] = set([
|
|
64
|
+
])
|
|
65
|
+
|
|
66
|
+
_dict = self.model_dump(
|
|
67
|
+
by_alias=True,
|
|
68
|
+
exclude=excluded_fields,
|
|
69
|
+
exclude_none=True,
|
|
70
|
+
)
|
|
71
|
+
return _dict
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
75
|
+
"""Create an instance of UpdateCollectionWorkspaceRequest from a dict"""
|
|
76
|
+
if obj is None:
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
if not isinstance(obj, dict):
|
|
80
|
+
return cls.model_validate(obj)
|
|
81
|
+
|
|
82
|
+
_obj = cls.model_validate({
|
|
83
|
+
"workspace": obj.get("workspace")
|
|
84
|
+
})
|
|
85
|
+
return _obj
|
|
86
|
+
|
|
87
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
h2oGPTe REST API
|
|
5
|
+
|
|
6
|
+
# Overview Users can easily interact with the h2oGPTe API through its REST API, allowing HTTP requests from any programming language. ## Authorization: Getting an API key Sign up/in at Enterprise h2oGPTe and generate one of the following two types of API keys: - **Global API key**: If a Collection is not specified when creating a new API Key, that key is considered to be a global API Key. Use global API Keys to grant full user impersonation and system-wide access to all of your work. Anyone with access to one of your global API Keys can create, delete, or interact with any of your past, current, and future Collections, Documents, Chats, and settings. - **Collection-specific API key**: Use Collection-specific API Keys to grant external access to only Chat with a specified Collection and make related API calls to it. Collection-specific API keys do not allow other API calls, such as creation, deletion, or access to other Collections or Chats. Access Enterprise h2oGPTe through your [H2O Generative AI](https://genai.h2o.ai/appstore) app store account, available with a freemium tier. ## Authorization: Using an API key All h2oGPTe REST API requests must include an API Key in the \"Authorization\" HTTP header, formatted as follows: ``` Authorization: Bearer sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ``` ```sh curl -X 'POST' \\ 'https://h2ogpte.genai.h2o.ai/api/v1/collections' \\ -H 'accept: application/json' \\ -H 'Content-Type: application/json' \\ -H 'Authorization: Bearer sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \\ -d '{ \"name\": \"The name of my Collection\", \"description\": \"The description of my Collection\", \"embedding_model\": \"BAAI/bge-large-en-v1.5\" }' ``` ## Interactive h2oGPTe API testing This page only showcases the h2oGPTe REST API; you can test it directly in the [Swagger UI](https://h2ogpte.genai.h2o.ai/swagger-ui/). Ensure that you are logged into your Enterprise h2oGPTe account.
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: v1.0.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool
|
|
21
|
+
from typing import Any, ClassVar, Dict, List
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class UpdateExtractorPrivacyRequest(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
UpdateExtractorPrivacyRequest
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
is_public: StrictBool = Field(description="A flag specifying whether a extractor is private or public.")
|
|
30
|
+
__properties: ClassVar[List[str]] = ["is_public"]
|
|
31
|
+
|
|
32
|
+
model_config = ConfigDict(
|
|
33
|
+
populate_by_name=True,
|
|
34
|
+
validate_assignment=True,
|
|
35
|
+
protected_namespaces=(),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def to_str(self) -> str:
|
|
40
|
+
"""Returns the string representation of the model using alias"""
|
|
41
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
42
|
+
|
|
43
|
+
def to_json(self) -> str:
|
|
44
|
+
"""Returns the JSON representation of the model using alias"""
|
|
45
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
46
|
+
return json.dumps(self.to_dict())
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
50
|
+
"""Create an instance of UpdateExtractorPrivacyRequest from a JSON string"""
|
|
51
|
+
return cls.from_dict(json.loads(json_str))
|
|
52
|
+
|
|
53
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
54
|
+
"""Return the dictionary representation of the model using alias.
|
|
55
|
+
|
|
56
|
+
This has the following differences from calling pydantic's
|
|
57
|
+
`self.model_dump(by_alias=True)`:
|
|
58
|
+
|
|
59
|
+
* `None` is only added to the output dict for nullable fields that
|
|
60
|
+
were set at model initialization. Other fields with value `None`
|
|
61
|
+
are ignored.
|
|
62
|
+
"""
|
|
63
|
+
excluded_fields: Set[str] = set([
|
|
64
|
+
])
|
|
65
|
+
|
|
66
|
+
_dict = self.model_dump(
|
|
67
|
+
by_alias=True,
|
|
68
|
+
exclude=excluded_fields,
|
|
69
|
+
exclude_none=True,
|
|
70
|
+
)
|
|
71
|
+
return _dict
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
75
|
+
"""Create an instance of UpdateExtractorPrivacyRequest from a dict"""
|
|
76
|
+
if obj is None:
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
if not isinstance(obj, dict):
|
|
80
|
+
return cls.model_validate(obj)
|
|
81
|
+
|
|
82
|
+
_obj = cls.model_validate({
|
|
83
|
+
"is_public": obj.get("is_public")
|
|
84
|
+
})
|
|
85
|
+
return _obj
|
|
86
|
+
|
|
87
|
+
|
h2ogpte/session.py
CHANGED
|
@@ -149,6 +149,7 @@ class Session:
|
|
|
149
149
|
ssl_context=ssl_context,
|
|
150
150
|
open_timeout=self._open_timeout,
|
|
151
151
|
close_timeout=self._close_timeout,
|
|
152
|
+
max_size=5 * 1024 * 1024, # 5 MB limit for large responses
|
|
152
153
|
)
|
|
153
154
|
return self._connection
|
|
154
155
|
except (ConnectionClosedError, InvalidURI, InvalidHandshake) as e:
|
|
@@ -261,6 +262,7 @@ class Session:
|
|
|
261
262
|
json_preserve_system_prompt (bool, default: None) — Whether to preserve system prompt in JSON response.
|
|
262
263
|
client_metadata (str, default: None) — Additional metadata to send with the request.
|
|
263
264
|
min_chars_per_yield (int, default: 1) — Minimum characters to yield in streaming response.
|
|
265
|
+
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.
|
|
264
266
|
cost_controls: Optional dictionary
|
|
265
267
|
max_cost (float) - Sets the maximum allowed cost in USD per LLM call when doing Automatic model routing. If the estimated cost based on input and output token counts is higher than this limit, the request will fail as early as possible.
|
|
266
268
|
max_cost_per_million_tokens (float) - Only consider models that cost less than this value in USD per million tokens when doing automatic routing. Using the max of input and output cost.
|
|
@@ -276,6 +278,14 @@ class Session:
|
|
|
276
278
|
agent_timeout (int, default: None) — Timeout in seconds for each agent turn.
|
|
277
279
|
agent_total_timeout (int, default: 3600) — Total timeout in seconds for all agent processing.
|
|
278
280
|
agent_min_time (int, default: 0) — Minimum time in seconds for all agent processing.
|
|
281
|
+
final_answer_guidelines_mode (str, default: "auto") — Mode for formatting agent final answers. Options:
|
|
282
|
+
* auto: chooses "detailed" for now, but may later adapt
|
|
283
|
+
* detailed: full deep_research like final answer guidelines
|
|
284
|
+
* detailed_no_file_links: Like detailed, but without files provided to LLM for final answer so LLM doesn't over-emphasize showing file links except what it auto-decides from chat history
|
|
285
|
+
* detailed_no_image_links: Like detailed, but without images provided to LLM for final answer so LLM doesn't over-emphasize showing image links except what it auto-decides from chat history
|
|
286
|
+
* detailed_no_links: Like detailed, but without files or images provided to LLM for final answer so LLM doesn't over-emphasize showing file or image links except what it auto-decides from chat history
|
|
287
|
+
* file_template: Use file final_answer_guidelines_template.txt (in agent_files or original_agent_files) that has optional f-strings: agent_accuracy, new_image_files, new_non_image_files, formatted_references
|
|
288
|
+
* raw_LLM: Bypasses final answer guidelines and just stops after own final LLM response that has no executable code.
|
|
279
289
|
agent_code_writer_system_message (str, default: None) — System message for agent code writer.
|
|
280
290
|
agent_num_executable_code_blocks_limit (int, default: 1) — Maximum number of executable code blocks.
|
|
281
291
|
agent_system_site_packages (bool, default: True) — Whether agent has access to system site packages.
|
|
@@ -288,6 +298,8 @@ class Session:
|
|
|
288
298
|
agent_planning_forced_mode (Optional[bool], default: None) — Whether to force planning mode for agent.
|
|
289
299
|
agent_too_soon_forced_mode (Optional[bool], default: None) — Whether to force "too soon" mode for agent.
|
|
290
300
|
agent_critique_forced_mode (Optional[int], default: None) — Whether to force critique mode for agent.
|
|
301
|
+
agent_query_understanding_parallel_calls (Optional[int], default: None) — Number of parallel calls for query understanding.
|
|
302
|
+
tool_building_mode (Optional[str], default: None) — Mode for tool building configuration.
|
|
291
303
|
agent_stream_files (bool, default: True) — Whether to stream files from agent.
|
|
292
304
|
self_reflection_config:
|
|
293
305
|
Dictionary of arguments for self-reflection, can contain the following
|
|
@@ -426,7 +438,7 @@ class Session:
|
|
|
426
438
|
deadline = time.time() + timeout
|
|
427
439
|
|
|
428
440
|
current_retries = 0
|
|
429
|
-
while current_retries
|
|
441
|
+
while current_retries <= retries:
|
|
430
442
|
try:
|
|
431
443
|
self.connection.send(serialize(request))
|
|
432
444
|
break
|
|
@@ -441,7 +453,7 @@ class Session:
|
|
|
441
453
|
|
|
442
454
|
current_retries = 0
|
|
443
455
|
request_id: Optional[str] = None
|
|
444
|
-
while current_retries
|
|
456
|
+
while current_retries <= retries:
|
|
445
457
|
try:
|
|
446
458
|
while True:
|
|
447
459
|
try:
|
h2ogpte/session_async.py
CHANGED
|
@@ -29,6 +29,7 @@ from h2ogpte.types import (
|
|
|
29
29
|
ChatRequest,
|
|
30
30
|
ChatResponse,
|
|
31
31
|
SessionError,
|
|
32
|
+
PartialChatMessage,
|
|
32
33
|
)
|
|
33
34
|
from h2ogpte.errors import (
|
|
34
35
|
UnauthorizedError,
|
|
@@ -111,7 +112,9 @@ class SessionAsync:
|
|
|
111
112
|
metadata_filter: Optional[Dict[str, Any]] = None,
|
|
112
113
|
timeout: Optional[float] = None,
|
|
113
114
|
retries: int = 3,
|
|
114
|
-
callback: Optional[
|
|
115
|
+
callback: Optional[
|
|
116
|
+
Callable[[Union[ChatMessage, PartialChatMessage]], None]
|
|
117
|
+
] = None,
|
|
115
118
|
) -> ChatMessage:
|
|
116
119
|
"""Retrieval-augmented generation for a query on a collection.
|
|
117
120
|
Finds a collection of chunks relevant to the query using similarity scores.
|
|
@@ -172,6 +175,7 @@ class SessionAsync:
|
|
|
172
175
|
json_preserve_system_prompt (bool, default: None) — Whether to preserve system prompt in JSON response.
|
|
173
176
|
client_metadata (str, default: None) — Additional metadata to send with the request.
|
|
174
177
|
min_chars_per_yield (int, default: 1) — Minimum characters to yield in streaming response.
|
|
178
|
+
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.
|
|
175
179
|
cost_controls: Optional dictionary
|
|
176
180
|
max_cost (float) - Sets the maximum allowed cost in USD per LLM call when doing Automatic model routing. If the estimated cost based on input and output token counts is higher than this limit, the request will fail as early as possible.
|
|
177
181
|
max_cost_per_million_tokens (float) - Only consider models that cost less than this value in USD per million tokens when doing automatic routing. Using the max of input and output cost.
|
|
@@ -187,6 +191,14 @@ class SessionAsync:
|
|
|
187
191
|
agent_timeout (int, default: None) — Timeout in seconds for each agent turn.
|
|
188
192
|
agent_total_timeout (int, default: 3600) — Total timeout in seconds for all agent processing.
|
|
189
193
|
agent_min_time (int, default: 0) — Minimum time in seconds for all agent processing.
|
|
194
|
+
final_answer_guidelines_mode (str, default: "auto") — Mode for formatting agent final answers. Options:
|
|
195
|
+
* auto: chooses "detailed" for now, but may later adapt
|
|
196
|
+
* detailed: full deep_research like final answer guidelines
|
|
197
|
+
* detailed_no_file_links: Like detailed, but without files provided to LLM for final answer so LLM doesn't over-emphasize showing file links except what it auto-decides from chat history
|
|
198
|
+
* detailed_no_image_links: Like detailed, but without images provided to LLM for final answer so LLM doesn't over-emphasize showing image links except what it auto-decides from chat history
|
|
199
|
+
* detailed_no_links: Like detailed, but without files or images provided to LLM for final answer so LLM doesn't over-emphasize showing file or image links except what it auto-decides from chat history
|
|
200
|
+
* file_template: Use file final_answer_guidelines_template.txt (in agent_files or original_agent_files) that has optional f-strings: agent_accuracy, new_image_files, new_non_image_files, formatted_references
|
|
201
|
+
* raw_LLM: Bypasses final answer guidelines and just stops after own final LLM response that has no executable code.
|
|
190
202
|
agent_code_writer_system_message (str, default: None) — System message for agent code writer.
|
|
191
203
|
agent_num_executable_code_blocks_limit (int, default: 1) — Maximum number of executable code blocks.
|
|
192
204
|
agent_system_site_packages (bool, default: True) — Whether agent has access to system site packages.
|
|
@@ -199,6 +211,8 @@ class SessionAsync:
|
|
|
199
211
|
agent_planning_forced_mode (Optional[bool], default: None) — Whether to force planning mode for agent.
|
|
200
212
|
agent_too_soon_forced_mode (Optional[bool], default: None) — Whether to force "too soon" mode for agent.
|
|
201
213
|
agent_critique_forced_mode (Optional[int], default: None) — Whether to force critique mode for agent.
|
|
214
|
+
agent_query_understanding_parallel_calls (Optional[int], default: None) — Number of parallel calls for query understanding.
|
|
215
|
+
tool_building_mode (Optional[str], default: None) — Mode for tool building configuration.
|
|
202
216
|
agent_stream_files (bool, default: True) — Whether to stream files from agent.
|
|
203
217
|
self_reflection_config:
|
|
204
218
|
Dictionary of arguments for self-reflection, can contain the following
|
|
@@ -336,7 +350,7 @@ class SessionAsync:
|
|
|
336
350
|
return info.message
|
|
337
351
|
|
|
338
352
|
current_retries = 0
|
|
339
|
-
while current_retries
|
|
353
|
+
while current_retries <= retries:
|
|
340
354
|
try:
|
|
341
355
|
return await asyncio.wait_for(send_recv_query(), timeout=timeout)
|
|
342
356
|
except (ConnectionClosed, ConnectionClosedError) as e:
|
|
@@ -423,9 +437,17 @@ class SessionAsync:
|
|
|
423
437
|
elif not info.message.id:
|
|
424
438
|
info.message.id = info.message_id
|
|
425
439
|
info.message.content = res.body
|
|
426
|
-
if info.callback:
|
|
427
|
-
info.callback(
|
|
440
|
+
if res.t in ["cp", "cm"] and info.callback:
|
|
441
|
+
info.callback(
|
|
442
|
+
PartialChatMessage(
|
|
443
|
+
id=info.message.id,
|
|
444
|
+
content=info.message.content,
|
|
445
|
+
reply_to=info.message.reply_to,
|
|
446
|
+
)
|
|
447
|
+
)
|
|
428
448
|
if res.t == "ca":
|
|
449
|
+
if info.callback:
|
|
450
|
+
info.callback(info.message)
|
|
429
451
|
info.done = True
|
|
430
452
|
|
|
431
453
|
async def connect(self):
|
|
@@ -456,6 +478,7 @@ class SessionAsync:
|
|
|
456
478
|
open_timeout=self._open_timeout,
|
|
457
479
|
close_timeout=self._close_timeout,
|
|
458
480
|
ssl=ssl_context,
|
|
481
|
+
max_size=5 * 1024 * 1024, # 5 MB limit for large responses
|
|
459
482
|
)
|
|
460
483
|
return self._websocket
|
|
461
484
|
except (ConnectionClosedError, InvalidURI, InvalidHandshake) as e:
|
|
@@ -511,10 +534,14 @@ class _QueryInfo:
|
|
|
511
534
|
def __init__(
|
|
512
535
|
self,
|
|
513
536
|
correlation_id: str,
|
|
514
|
-
callback: Optional[
|
|
537
|
+
callback: Optional[
|
|
538
|
+
Callable[[Union[ChatMessage, PartialChatMessage]], None]
|
|
539
|
+
] = None,
|
|
515
540
|
):
|
|
516
541
|
self.correlation_id = correlation_id
|
|
517
|
-
self.callback: Optional[
|
|
542
|
+
self.callback: Optional[
|
|
543
|
+
Callable[[Union[ChatMessage, PartialChatMessage]], None]
|
|
544
|
+
] = callback
|
|
518
545
|
self.query_id: Optional[str] = None
|
|
519
546
|
self.message_id: Optional[str] = None
|
|
520
547
|
self.done: bool = False
|
h2ogpte/types.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from pydantic import BaseModel
|
|
@@ -11,6 +11,7 @@ class JobKind(str, Enum):
|
|
|
11
11
|
IngestAgentOnlyToStandardJob = "IngestAgentOnlyToStandardJob"
|
|
12
12
|
IngestFromFileSystemJob = "IngestFromFileSystemJob"
|
|
13
13
|
IngestFromCloudStorageJob = "IngestFromCloudStorageJob"
|
|
14
|
+
IngestWithScheduledConnectorJob = "IngestWithScheduledConnectorJob"
|
|
14
15
|
IngestPlainTextJob = "IngestPlainTextJob"
|
|
15
16
|
IngestUploadsJob = "IngestUploadsJob"
|
|
16
17
|
IngestWebsiteJob = "IngestWebsiteJob"
|
|
@@ -150,6 +151,7 @@ class ChatSessionInfo(BaseModel):
|
|
|
150
151
|
collection_name: Optional[str] = None
|
|
151
152
|
prompt_template_id: Optional[str] = None
|
|
152
153
|
updated_at: datetime
|
|
154
|
+
workspace: Optional[str] = None
|
|
153
155
|
|
|
154
156
|
|
|
155
157
|
class QuestionReplyData(BaseModel):
|
|
@@ -244,6 +246,7 @@ class Collection(BaseModel):
|
|
|
244
246
|
expiry_date: Optional[datetime] = None
|
|
245
247
|
inactivity_interval: Optional[int] = None
|
|
246
248
|
size_limit: Optional[int] = None
|
|
249
|
+
workspace: Optional[str] = None
|
|
247
250
|
|
|
248
251
|
|
|
249
252
|
class CollectionCount(BaseModel):
|
|
@@ -267,6 +270,7 @@ class CollectionInfo(BaseModel):
|
|
|
267
270
|
archived_at: Optional[datetime] = None
|
|
268
271
|
size_limit: Optional[int] = None
|
|
269
272
|
metadata_dict: Optional[dict] = None
|
|
273
|
+
workspace: Optional[str] = None
|
|
270
274
|
|
|
271
275
|
|
|
272
276
|
class Document(BaseModel):
|
|
@@ -300,6 +304,7 @@ class Extractor(BaseModel):
|
|
|
300
304
|
llm: Optional[str] = None
|
|
301
305
|
# can't use name schema as it conflicts with BaseModel's internals
|
|
302
306
|
extractor_schema: Optional[Dict[str, Any]] = None
|
|
307
|
+
is_public: bool
|
|
303
308
|
|
|
304
309
|
|
|
305
310
|
class Tag(BaseModel):
|
|
@@ -476,6 +481,7 @@ class Meta(BaseModel):
|
|
|
476
481
|
user_configs: List[ConfigItem]
|
|
477
482
|
picture: Optional[str]
|
|
478
483
|
groups: Optional[List[str]]
|
|
484
|
+
workspaces: Optional[List[str]]
|
|
479
485
|
permissions: List[str]
|
|
480
486
|
ui_config: MetaUIConfig
|
|
481
487
|
|
|
@@ -614,6 +620,7 @@ class ChatAcknowledgement:
|
|
|
614
620
|
message_id: str
|
|
615
621
|
username: str
|
|
616
622
|
body: str
|
|
623
|
+
use_agent: Optional[bool] = None
|
|
617
624
|
|
|
618
625
|
|
|
619
626
|
@dataclass
|
|
@@ -624,6 +631,7 @@ class ChatResponse:
|
|
|
624
631
|
reply_to_id: str
|
|
625
632
|
body: str
|
|
626
633
|
error: str
|
|
634
|
+
meta: List[Any] = field(default_factory=list)
|
|
627
635
|
|
|
628
636
|
|
|
629
637
|
@dataclass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: h2ogpte
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.43
|
|
4
4
|
Summary: Client library for Enterprise h2oGPTe
|
|
5
5
|
Author-email: "H2O.ai, Inc." <support@h2o.ai>
|
|
6
6
|
Project-URL: Source, https://github.com/h2oai/h2ogpte
|
|
@@ -34,6 +34,10 @@ Requires-Dist: h2o_authn
|
|
|
34
34
|
Requires-Dist: packaging
|
|
35
35
|
Requires-Dist: filetype
|
|
36
36
|
Requires-Dist: tzlocal
|
|
37
|
+
Requires-Dist: rich>=13.7.0
|
|
38
|
+
Requires-Dist: pathspec>=0.12.0
|
|
39
|
+
Requires-Dist: gitpython>=3.1.40
|
|
40
|
+
Requires-Dist: toml>=0.10.2
|
|
37
41
|
|
|
38
42
|
### Python Client and Documentation
|
|
39
43
|
|