h2ogpte 1.6.55rc1__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.
Files changed (39) hide show
  1. h2ogpte/__init__.py +1 -1
  2. h2ogpte/h2ogpte.py +184 -20
  3. h2ogpte/h2ogpte_async.py +184 -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/models_api.py +35 -67
  8. h2ogpte/rest_async/api_client.py +1 -1
  9. h2ogpte/rest_async/configuration.py +1 -1
  10. h2ogpte/rest_async/models/__init__.py +2 -1
  11. h2ogpte/rest_async/models/chat_completion_request.py +6 -2
  12. h2ogpte/rest_async/models/chat_settings.py +6 -2
  13. h2ogpte/rest_async/models/chat_settings_tags.py +140 -0
  14. h2ogpte/rest_async/models/extractor.py +26 -2
  15. h2ogpte/rest_async/models/extractor_create_request.py +29 -5
  16. h2ogpte/rest_async/models/ingest_from_confluence_body.py +4 -2
  17. h2ogpte/rest_async/models/{create_topic_model_job_request.py → tag_filter.py} +11 -9
  18. h2ogpte/rest_sync/__init__.py +3 -2
  19. h2ogpte/rest_sync/api/agents_api.py +25 -25
  20. h2ogpte/rest_sync/api/chat_api.py +1077 -21
  21. h2ogpte/rest_sync/api/models_api.py +35 -67
  22. h2ogpte/rest_sync/api_client.py +1 -1
  23. h2ogpte/rest_sync/configuration.py +1 -1
  24. h2ogpte/rest_sync/models/__init__.py +2 -1
  25. h2ogpte/rest_sync/models/chat_completion_request.py +6 -2
  26. h2ogpte/rest_sync/models/chat_settings.py +6 -2
  27. h2ogpte/rest_sync/models/chat_settings_tags.py +140 -0
  28. h2ogpte/rest_sync/models/extractor.py +26 -2
  29. h2ogpte/rest_sync/models/extractor_create_request.py +29 -5
  30. h2ogpte/rest_sync/models/ingest_from_confluence_body.py +4 -2
  31. h2ogpte/rest_sync/models/{create_topic_model_job_request.py → tag_filter.py} +11 -9
  32. h2ogpte/session.py +10 -5
  33. h2ogpte/session_async.py +10 -2
  34. h2ogpte/types.py +26 -1
  35. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc1.dist-info}/METADATA +1 -1
  36. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc1.dist-info}/RECORD +39 -37
  37. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc1.dist-info}/WHEEL +0 -0
  38. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc1.dist-info}/entry_points.txt +0 -0
  39. {h2ogpte-1.6.55rc1.dist-info → h2ogpte-1.7.0rc1.dist-info}/top_level.txt +0 -0
@@ -19,13 +19,11 @@ from typing_extensions import Annotated
19
19
  from pydantic import Field, StrictFloat, StrictInt, StrictStr, field_validator
20
20
  from typing import Dict, List, Optional, Union
21
21
  from typing_extensions import Annotated
22
- from h2ogpte.rest_sync.models.create_topic_model_job_request import CreateTopicModelJobRequest
23
22
  from h2ogpte.rest_sync.models.embedding_model import EmbeddingModel
24
23
  from h2ogpte.rest_sync.models.encode_chunks_for_retrieval_request import EncodeChunksForRetrievalRequest
25
24
  from h2ogpte.rest_sync.models.extraction_request import ExtractionRequest
26
25
  from h2ogpte.rest_sync.models.guardrails_settings import GuardrailsSettings
27
26
  from h2ogpte.rest_sync.models.guardrails_settings_create_request import GuardrailsSettingsCreateRequest
28
- from h2ogpte.rest_sync.models.job_details import JobDetails
29
27
  from h2ogpte.rest_sync.models.model import Model
30
28
  from h2ogpte.rest_sync.models.model_answer import ModelAnswer
31
29
  from h2ogpte.rest_sync.models.model_extraction_answer import ModelExtractionAnswer
@@ -907,10 +905,9 @@ class ModelsApi:
907
905
 
908
906
 
909
907
  @validate_call
910
- def create_topic_model_job(
908
+ def delete_topic_model(
911
909
  self,
912
- create_topic_model_job_request: CreateTopicModelJobRequest,
913
- timeout: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Timeout in seconds")] = None,
910
+ collection_id: Annotated[StrictStr, Field(description="Id of the collection")],
914
911
  _request_timeout: Union[
915
912
  None,
916
913
  Annotated[StrictFloat, Field(gt=0)],
@@ -923,15 +920,13 @@ class ModelsApi:
923
920
  _content_type: Optional[StrictStr] = None,
924
921
  _headers: Optional[Dict[StrictStr, Any]] = None,
925
922
  _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
926
- ) -> JobDetails:
927
- """Creates job for creation of a topic model.
923
+ ) -> None:
924
+ """Deletes the topic model from the collection.
928
925
 
929
- Creates job for creation of a topic model.
926
+ Deletes the topic model from the collection.
930
927
 
931
- :param create_topic_model_job_request: (required)
932
- :type create_topic_model_job_request: CreateTopicModelJobRequest
933
- :param timeout: Timeout in seconds
934
- :type timeout: float
928
+ :param collection_id: Id of the collection (required)
929
+ :type collection_id: str
935
930
  :param _request_timeout: timeout setting for this request. If one
936
931
  number provided, it will be total request
937
932
  timeout. It can also be a pair (tuple) of
@@ -954,9 +949,8 @@ class ModelsApi:
954
949
  :return: Returns the result object.
955
950
  """ # noqa: E501
956
951
 
957
- _param = self._create_topic_model_job_serialize(
958
- create_topic_model_job_request=create_topic_model_job_request,
959
- timeout=timeout,
952
+ _param = self._delete_topic_model_serialize(
953
+ collection_id=collection_id,
960
954
  _request_auth=_request_auth,
961
955
  _content_type=_content_type,
962
956
  _headers=_headers,
@@ -964,7 +958,7 @@ class ModelsApi:
964
958
  )
965
959
 
966
960
  _response_types_map: Dict[str, Optional[str]] = {
967
- '201': "JobDetails",
961
+ '204': None,
968
962
  '401': "EndpointError",
969
963
  }
970
964
  response_data = self.api_client.call_api(
@@ -979,10 +973,9 @@ class ModelsApi:
979
973
 
980
974
 
981
975
  @validate_call
982
- def create_topic_model_job_with_http_info(
976
+ def delete_topic_model_with_http_info(
983
977
  self,
984
- create_topic_model_job_request: CreateTopicModelJobRequest,
985
- timeout: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Timeout in seconds")] = None,
978
+ collection_id: Annotated[StrictStr, Field(description="Id of the collection")],
986
979
  _request_timeout: Union[
987
980
  None,
988
981
  Annotated[StrictFloat, Field(gt=0)],
@@ -995,15 +988,13 @@ class ModelsApi:
995
988
  _content_type: Optional[StrictStr] = None,
996
989
  _headers: Optional[Dict[StrictStr, Any]] = None,
997
990
  _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
998
- ) -> ApiResponse[JobDetails]:
999
- """Creates job for creation of a topic model.
991
+ ) -> ApiResponse[None]:
992
+ """Deletes the topic model from the collection.
1000
993
 
1001
- Creates job for creation of a topic model.
994
+ Deletes the topic model from the collection.
1002
995
 
1003
- :param create_topic_model_job_request: (required)
1004
- :type create_topic_model_job_request: CreateTopicModelJobRequest
1005
- :param timeout: Timeout in seconds
1006
- :type timeout: float
996
+ :param collection_id: Id of the collection (required)
997
+ :type collection_id: str
1007
998
  :param _request_timeout: timeout setting for this request. If one
1008
999
  number provided, it will be total request
1009
1000
  timeout. It can also be a pair (tuple) of
@@ -1026,9 +1017,8 @@ class ModelsApi:
1026
1017
  :return: Returns the result object.
1027
1018
  """ # noqa: E501
1028
1019
 
1029
- _param = self._create_topic_model_job_serialize(
1030
- create_topic_model_job_request=create_topic_model_job_request,
1031
- timeout=timeout,
1020
+ _param = self._delete_topic_model_serialize(
1021
+ collection_id=collection_id,
1032
1022
  _request_auth=_request_auth,
1033
1023
  _content_type=_content_type,
1034
1024
  _headers=_headers,
@@ -1036,7 +1026,7 @@ class ModelsApi:
1036
1026
  )
1037
1027
 
1038
1028
  _response_types_map: Dict[str, Optional[str]] = {
1039
- '201': "JobDetails",
1029
+ '204': None,
1040
1030
  '401': "EndpointError",
1041
1031
  }
1042
1032
  response_data = self.api_client.call_api(
@@ -1051,10 +1041,9 @@ class ModelsApi:
1051
1041
 
1052
1042
 
1053
1043
  @validate_call
1054
- def create_topic_model_job_without_preload_content(
1044
+ def delete_topic_model_without_preload_content(
1055
1045
  self,
1056
- create_topic_model_job_request: CreateTopicModelJobRequest,
1057
- timeout: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Timeout in seconds")] = None,
1046
+ collection_id: Annotated[StrictStr, Field(description="Id of the collection")],
1058
1047
  _request_timeout: Union[
1059
1048
  None,
1060
1049
  Annotated[StrictFloat, Field(gt=0)],
@@ -1068,14 +1057,12 @@ class ModelsApi:
1068
1057
  _headers: Optional[Dict[StrictStr, Any]] = None,
1069
1058
  _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
1070
1059
  ) -> RESTResponseType:
1071
- """Creates job for creation of a topic model.
1060
+ """Deletes the topic model from the collection.
1072
1061
 
1073
- Creates job for creation of a topic model.
1062
+ Deletes the topic model from the collection.
1074
1063
 
1075
- :param create_topic_model_job_request: (required)
1076
- :type create_topic_model_job_request: CreateTopicModelJobRequest
1077
- :param timeout: Timeout in seconds
1078
- :type timeout: float
1064
+ :param collection_id: Id of the collection (required)
1065
+ :type collection_id: str
1079
1066
  :param _request_timeout: timeout setting for this request. If one
1080
1067
  number provided, it will be total request
1081
1068
  timeout. It can also be a pair (tuple) of
@@ -1098,9 +1085,8 @@ class ModelsApi:
1098
1085
  :return: Returns the result object.
1099
1086
  """ # noqa: E501
1100
1087
 
1101
- _param = self._create_topic_model_job_serialize(
1102
- create_topic_model_job_request=create_topic_model_job_request,
1103
- timeout=timeout,
1088
+ _param = self._delete_topic_model_serialize(
1089
+ collection_id=collection_id,
1104
1090
  _request_auth=_request_auth,
1105
1091
  _content_type=_content_type,
1106
1092
  _headers=_headers,
@@ -1108,7 +1094,7 @@ class ModelsApi:
1108
1094
  )
1109
1095
 
1110
1096
  _response_types_map: Dict[str, Optional[str]] = {
1111
- '201': "JobDetails",
1097
+ '204': None,
1112
1098
  '401': "EndpointError",
1113
1099
  }
1114
1100
  response_data = self.api_client.call_api(
@@ -1118,10 +1104,9 @@ class ModelsApi:
1118
1104
  return response_data.response
1119
1105
 
1120
1106
 
1121
- def _create_topic_model_job_serialize(
1107
+ def _delete_topic_model_serialize(
1122
1108
  self,
1123
- create_topic_model_job_request,
1124
- timeout,
1109
+ collection_id,
1125
1110
  _request_auth,
1126
1111
  _content_type,
1127
1112
  _headers,
@@ -1143,16 +1128,12 @@ class ModelsApi:
1143
1128
  _body_params: Optional[bytes] = None
1144
1129
 
1145
1130
  # process the path parameters
1131
+ if collection_id is not None:
1132
+ _path_params['collection_id'] = collection_id
1146
1133
  # process the query parameters
1147
- if timeout is not None:
1148
-
1149
- _query_params.append(('timeout', timeout))
1150
-
1151
1134
  # process the header parameters
1152
1135
  # process the form parameters
1153
1136
  # process the body parameter
1154
- if create_topic_model_job_request is not None:
1155
- _body_params = create_topic_model_job_request
1156
1137
 
1157
1138
 
1158
1139
  # set the HTTP header `Accept`
@@ -1163,19 +1144,6 @@ class ModelsApi:
1163
1144
  ]
1164
1145
  )
1165
1146
 
1166
- # set the HTTP header `Content-Type`
1167
- if _content_type:
1168
- _header_params['Content-Type'] = _content_type
1169
- else:
1170
- _default_content_type = (
1171
- self.api_client.select_header_content_type(
1172
- [
1173
- 'application/json'
1174
- ]
1175
- )
1176
- )
1177
- if _default_content_type is not None:
1178
- _header_params['Content-Type'] = _default_content_type
1179
1147
 
1180
1148
  # authentication setting
1181
1149
  _auth_settings: List[str] = [
@@ -1183,8 +1151,8 @@ class ModelsApi:
1183
1151
  ]
1184
1152
 
1185
1153
  return self.api_client.param_serialize(
1186
- method='POST',
1187
- resource_path='/models/create_topic_model_job',
1154
+ method='DELETE',
1155
+ resource_path='/collections/{collection_id}/topic_model',
1188
1156
  path_params=_path_params,
1189
1157
  query_params=_query_params,
1190
1158
  header_params=_header_params,
@@ -90,7 +90,7 @@ class ApiClient:
90
90
  self.default_headers[header_name] = header_value
91
91
  self.cookie = cookie
92
92
  # Set default User-Agent.
93
- self.user_agent = 'OpenAPI-Generator/1.6.55-dev1/python'
93
+ self.user_agent = 'OpenAPI-Generator/1.7.0-dev1/python'
94
94
  self.client_side_validation = configuration.client_side_validation
95
95
 
96
96
  def __enter__(self):
@@ -503,7 +503,7 @@ class Configuration:
503
503
  "OS: {env}\n"\
504
504
  "Python Version: {pyversion}\n"\
505
505
  "Version of the API: v1.0.0\n"\
506
- "SDK Package Version: 1.6.55-dev1".\
506
+ "SDK Package Version: 1.7.0-dev1".\
507
507
  format(env=sys.platform, pyversion=sys.version)
508
508
 
509
509
  def get_host_settings(self) -> List[HostSetting]:
@@ -38,6 +38,7 @@ from h2ogpte.rest_sync.models.chat_message_reference import ChatMessageReference
38
38
  from h2ogpte.rest_sync.models.chat_session import ChatSession
39
39
  from h2ogpte.rest_sync.models.chat_session_update_request import ChatSessionUpdateRequest
40
40
  from h2ogpte.rest_sync.models.chat_settings import ChatSettings
41
+ from h2ogpte.rest_sync.models.chat_settings_tags import ChatSettingsTags
41
42
  from h2ogpte.rest_sync.models.chunk import Chunk
42
43
  from h2ogpte.rest_sync.models.chunk_search_result import ChunkSearchResult
43
44
  from h2ogpte.rest_sync.models.collection import Collection
@@ -57,7 +58,6 @@ from h2ogpte.rest_sync.models.create_import_collection_to_collection_job_request
57
58
  from h2ogpte.rest_sync.models.create_insert_document_to_collection_job_request import CreateInsertDocumentToCollectionJobRequest
58
59
  from h2ogpte.rest_sync.models.create_secret201_response import CreateSecret201Response
59
60
  from h2ogpte.rest_sync.models.create_secret_request import CreateSecretRequest
60
- from h2ogpte.rest_sync.models.create_topic_model_job_request import CreateTopicModelJobRequest
61
61
  from h2ogpte.rest_sync.models.delete_chat_sessions_job_request import DeleteChatSessionsJobRequest
62
62
  from h2ogpte.rest_sync.models.delete_collections_job_request import DeleteCollectionsJobRequest
63
63
  from h2ogpte.rest_sync.models.delete_documents_job_request import DeleteDocumentsJobRequest
@@ -127,6 +127,7 @@ from h2ogpte.rest_sync.models.suggested_question import SuggestedQuestion
127
127
  from h2ogpte.rest_sync.models.summarize_request import SummarizeRequest
128
128
  from h2ogpte.rest_sync.models.tag import Tag
129
129
  from h2ogpte.rest_sync.models.tag_create_request import TagCreateRequest
130
+ from h2ogpte.rest_sync.models.tag_filter import TagFilter
130
131
  from h2ogpte.rest_sync.models.tag_update_request import TagUpdateRequest
131
132
  from h2ogpte.rest_sync.models.update_agent_key_request import UpdateAgentKeyRequest
132
133
  from h2ogpte.rest_sync.models.update_agent_tool_preference_request import UpdateAgentToolPreferenceRequest
@@ -19,6 +19,7 @@ import json
19
19
 
20
20
  from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
+ from h2ogpte.rest_sync.models.chat_settings_tags import ChatSettingsTags
22
23
  from typing import Optional, Set
23
24
  from typing_extensions import Self
24
25
 
@@ -37,7 +38,7 @@ class ChatCompletionRequest(BaseModel):
37
38
  self_reflection_config: Optional[Dict[str, Any]] = Field(default=None, description="A map with self reflection settings: * `llm_reflection` **(type=string, example=gpt-4-0613)** * `prompt_reflection` **(type=string, example=\\\"\\\"\\\"Prompt:\\\\\\\\n%s\\\\\\\\n\\\"\\\"\\\"\\\\\\\\n\\\\\\\\n\\\"\\\"\\\")** * `system_prompt_reflection` **(type=string)** * `llm_args_reflection` **(type=string, example={})** ")
38
39
  rag_config: Optional[Dict[str, Any]] = Field(default=None, description="A map with arguments to control RAG (retrieval-augmented-generation) types.: * `rag_type` **(type=enum[auto, llm_only, rag, hyde1, hyde2, rag+, all_data])** RAG type options: * `auto` - Automatically select the best rag_type. * `llm_only` LLM Only - Answer the query without any supporting document contexts. Requires 1 LLM call. * `rag` RAG (Retrieval Augmented Generation) - Use supporting document contexts to answer the query. Requires 1 LLM call. * `hyde1` LLM Only + RAG composite - HyDE RAG (Hypothetical Document Embedding). Use 'LLM Only' response to find relevant contexts from a collection for generating a response. Requires 2 LLM calls. * `hyde2` HyDE + RAG composite - Use the 'HyDE RAG' response to find relevant contexts from a collection for generating a response. Requires 3 LLM calls. * `rag+` Summary RAG - Like RAG, but uses more context and recursive summarization to overcome LLM context limits. Keeps all retrieved chunks, puts them in order, adds neighboring chunks, then uses the summary API to get the answer. Can require several LLM calls. * `all_data` All Data RAG - Like Summary RAG, but includes all document chunks. Uses recursive summarization to overcome LLM context limits. Can require several LLM calls. * `hyde_no_rag_llm_prompt_extension` **(type=string, example=\\\\\\\\nKeep the answer brief, and list the 5 most relevant key words at the end.)** - Add this prompt to every user's prompt, when generating answers to be used for subsequent retrieval during HyDE. Only used when rag_type is `hyde1` or `hyde2`. * `num_neighbor_chunks_to_include` **(type=integer, default=1)** - A number of neighboring chunks to include for every retrieved relevant chunk. It helps to keep surrounding context together. Only enabled for rag_type `rag+`. * `meta_data_to_include` **(type=map)** - A map with flags that indicate whether each piece of document metadata is to be included as part of the context for a chat with a collection. * `name` **(type: boolean, default=True)** * `text` **(type: boolean, default=True)** * `page` **(type: boolean, default=True)** * `captions` **(type: boolean, default=True)** * `uri` **(type: boolean, default=False)** * `connector` **(type: boolean, default=False)** * `original_mtime` **(type: boolean, default=False)** * `age` **(type: boolean, default=False)** * `score` **(type: boolean, default=False)** * `rag_max_chunks` **(type=integer, default=-1)** - Maximum number of document chunks to retrieve for RAG. Actual number depends on rag_type and admin configuration. Set to >0 values to enable. Can be combined with rag_min_chunk_score. * `rag_min_chunk_score` **(type=double, default=0.0)** - Minimum score of document chunks to retrieve for RAG. Set to >0 values to enable. Can be combined with rag_max_chunks. ")
39
40
  include_chat_history: Optional[StrictStr] = Field(default=None, description="Whether to include chat history. Includes previous questions and answers for the current chat session for each new chat request. Disable if require deterministic answers for a given question.")
40
- tags: Optional[List[StrictStr]] = Field(default=None, description="A list of tags from which to pull the context for RAG.")
41
+ tags: Optional[ChatSettingsTags] = None
41
42
  __properties: ClassVar[List[str]] = ["message", "system_prompt", "pre_prompt_query", "prompt_query", "image_batch_final_prompt", "image_batch_image_prompt", "llm", "llm_args", "self_reflection_config", "rag_config", "include_chat_history", "tags"]
42
43
 
43
44
  @field_validator('include_chat_history')
@@ -89,6 +90,9 @@ class ChatCompletionRequest(BaseModel):
89
90
  exclude=excluded_fields,
90
91
  exclude_none=True,
91
92
  )
93
+ # override the default output from pydantic by calling `to_dict()` of tags
94
+ if self.tags:
95
+ _dict['tags'] = self.tags.to_dict()
92
96
  return _dict
93
97
 
94
98
  @classmethod
@@ -112,7 +116,7 @@ class ChatCompletionRequest(BaseModel):
112
116
  "self_reflection_config": obj.get("self_reflection_config"),
113
117
  "rag_config": obj.get("rag_config"),
114
118
  "include_chat_history": obj.get("include_chat_history"),
115
- "tags": obj.get("tags"),
119
+ "tags": ChatSettingsTags.from_dict(obj["tags"]) if obj.get("tags") is not None else None,
116
120
  })
117
121
  return _obj
118
122
 
@@ -19,6 +19,7 @@ import json
19
19
 
20
20
  from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
+ from h2ogpte.rest_sync.models.chat_settings_tags import ChatSettingsTags
22
23
  from typing import Optional, Set
23
24
  from typing_extensions import Self
24
25
 
@@ -31,7 +32,7 @@ class ChatSettings(BaseModel):
31
32
  self_reflection_config: Optional[Dict[str, Any]] = Field(default=None, description="A map with self reflection settings: * `llm_reflection` **(type=string, example=gpt-4-0613)** * `prompt_reflection` **(type=string, example=\\\"\\\"\\\"Prompt:\\\\\\\\n%s\\\\\\\\n\\\"\\\"\\\"\\\\\\\\n\\\\\\\\n\\\"\\\"\\\")** * `system_prompt_reflection` **(type=string)** * `llm_args_reflection` **(type=string, example={})** ")
32
33
  rag_config: Optional[Dict[str, Any]] = Field(default=None, description="A map with arguments to control RAG (retrieval-augmented-generation) types.: * `rag_type` **(type=enum[auto, llm_only, rag, hyde1, hyde2, rag+, all_data])** RAG type options: * `auto` - Automatically select the best rag_type. * `llm_only` LLM Only - Answer the query without any supporting document contexts. Requires 1 LLM call. * `rag` RAG (Retrieval Augmented Generation) - Use supporting document contexts to answer the query. Requires 1 LLM call. * `hyde1` LLM Only + RAG composite - HyDE RAG (Hypothetical Document Embedding). Use 'LLM Only' response to find relevant contexts from a collection for generating a response. Requires 2 LLM calls. * `hyde2` HyDE + RAG composite - Use the 'HyDE RAG' response to find relevant contexts from a collection for generating a response. Requires 3 LLM calls. * `rag+` Summary RAG - Like RAG, but uses more context and recursive summarization to overcome LLM context limits. Keeps all retrieved chunks, puts them in order, adds neighboring chunks, then uses the summary API to get the answer. Can require several LLM calls. * `all_data` All Data RAG - Like Summary RAG, but includes all document chunks. Uses recursive summarization to overcome LLM context limits. Can require several LLM calls. * `hyde_no_rag_llm_prompt_extension` **(type=string, example=\\\\\\\\nKeep the answer brief, and list the 5 most relevant key words at the end.)** - Add this prompt to every user's prompt, when generating answers to be used for subsequent retrieval during HyDE. Only used when rag_type is `hyde1` or `hyde2`. * `num_neighbor_chunks_to_include` **(type=integer, default=1)** - A number of neighboring chunks to include for every retrieved relevant chunk. It helps to keep surrounding context together. Only enabled for rag_type `rag+`. * `meta_data_to_include` **(type=map)** - A map with flags that indicate whether each piece of document metadata is to be included as part of the context for a chat with a collection. * `name` **(type: boolean, default=True)** * `text` **(type: boolean, default=True)** * `page` **(type: boolean, default=True)** * `captions` **(type: boolean, default=True)** * `uri` **(type: boolean, default=False)** * `connector` **(type: boolean, default=False)** * `original_mtime` **(type: boolean, default=False)** * `age` **(type: boolean, default=False)** * `score` **(type: boolean, default=False)** * `rag_max_chunks` **(type=integer, default=-1)** - Maximum number of document chunks to retrieve for RAG. Actual number depends on rag_type and admin configuration. Set to >0 values to enable. Can be combined with rag_min_chunk_score. * `rag_min_chunk_score` **(type=double, default=0.0)** - Minimum score of document chunks to retrieve for RAG. Set to >0 values to enable. Can be combined with rag_max_chunks. ")
33
34
  include_chat_history: Optional[StrictStr] = Field(default=None, description="Whether to include chat history. Includes previous questions and answers for the current chat session for each new chat request. Disable if require deterministic answers for a given question.")
34
- tags: Optional[List[StrictStr]] = Field(default=None, description="A list of tags from which to pull the context for RAG.")
35
+ tags: Optional[ChatSettingsTags] = None
35
36
  __properties: ClassVar[List[str]] = ["llm", "llm_args", "self_reflection_config", "rag_config", "include_chat_history", "tags"]
36
37
 
37
38
  @field_validator('include_chat_history')
@@ -83,6 +84,9 @@ class ChatSettings(BaseModel):
83
84
  exclude=excluded_fields,
84
85
  exclude_none=True,
85
86
  )
87
+ # override the default output from pydantic by calling `to_dict()` of tags
88
+ if self.tags:
89
+ _dict['tags'] = self.tags.to_dict()
86
90
  return _dict
87
91
 
88
92
  @classmethod
@@ -100,7 +104,7 @@ class ChatSettings(BaseModel):
100
104
  "self_reflection_config": obj.get("self_reflection_config"),
101
105
  "rag_config": obj.get("rag_config"),
102
106
  "include_chat_history": obj.get("include_chat_history"),
103
- "tags": obj.get("tags")
107
+ "tags": ChatSettingsTags.from_dict(obj["tags"]) if obj.get("tags") is not None else None
104
108
  })
105
109
  return _obj
106
110
 
@@ -0,0 +1,140 @@
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 json
17
+ import pprint
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
19
+ from typing import Any, List, Optional
20
+ from h2ogpte.rest_sync.models.tag_filter import TagFilter
21
+ from pydantic import StrictStr, Field
22
+ from typing import Union, List, Set, Optional, Dict
23
+ from typing_extensions import Literal, Self
24
+
25
+ CHATSETTINGSTAGS_ONE_OF_SCHEMAS = ["List[str]", "TagFilter"]
26
+
27
+ class ChatSettingsTags(BaseModel):
28
+ """
29
+ Filter documents by tags for RAG context. Supports two formats: - Array format (backward compatible): [\"red\", \"blue\"] includes documents with 'red' OR 'blue' tags - Object format (with exclusions): {\"include\": [\"color\"], \"exclude\": [\"red\", \"blue\"]}
30
+ """
31
+ # data type: List[str]
32
+ oneof_schema_1_validator: Optional[List[StrictStr]] = None
33
+ # data type: TagFilter
34
+ oneof_schema_2_validator: Optional[TagFilter] = None
35
+ actual_instance: Optional[Union[List[str], TagFilter]] = None
36
+ one_of_schemas: Set[str] = { "List[str]", "TagFilter" }
37
+
38
+ model_config = ConfigDict(
39
+ validate_assignment=True,
40
+ protected_namespaces=(),
41
+ )
42
+
43
+
44
+ def __init__(self, *args, **kwargs) -> None:
45
+ if args:
46
+ if len(args) > 1:
47
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
48
+ if kwargs:
49
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
50
+ super().__init__(actual_instance=args[0])
51
+ else:
52
+ super().__init__(**kwargs)
53
+
54
+ @field_validator('actual_instance')
55
+ def actual_instance_must_validate_oneof(cls, v):
56
+ instance = ChatSettingsTags.model_construct()
57
+ error_messages = []
58
+ match = 0
59
+ # validate data type: List[str]
60
+ try:
61
+ instance.oneof_schema_1_validator = v
62
+ match += 1
63
+ except (ValidationError, ValueError) as e:
64
+ error_messages.append(str(e))
65
+ # validate data type: TagFilter
66
+ if not isinstance(v, TagFilter):
67
+ error_messages.append(f"Error! Input type `{type(v)}` is not `TagFilter`")
68
+ else:
69
+ match += 1
70
+ if match > 1:
71
+ # more than 1 match
72
+ raise ValueError("Multiple matches found when setting `actual_instance` in ChatSettingsTags with oneOf schemas: List[str], TagFilter. Details: " + ", ".join(error_messages))
73
+ elif match == 0:
74
+ # no match
75
+ raise ValueError("No match found when setting `actual_instance` in ChatSettingsTags with oneOf schemas: List[str], TagFilter. Details: " + ", ".join(error_messages))
76
+ else:
77
+ return v
78
+
79
+ @classmethod
80
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
81
+ return cls.from_json(json.dumps(obj))
82
+
83
+ @classmethod
84
+ def from_json(cls, json_str: str) -> Self:
85
+ """Returns the object represented by the json string"""
86
+ instance = cls.model_construct()
87
+ error_messages = []
88
+ match = 0
89
+
90
+ # deserialize data into List[str]
91
+ try:
92
+ # validation
93
+ instance.oneof_schema_1_validator = json.loads(json_str)
94
+ # assign value to actual_instance
95
+ instance.actual_instance = instance.oneof_schema_1_validator
96
+ match += 1
97
+ except (ValidationError, ValueError) as e:
98
+ error_messages.append(str(e))
99
+ # deserialize data into TagFilter
100
+ try:
101
+ instance.actual_instance = TagFilter.from_json(json_str)
102
+ match += 1
103
+ except (ValidationError, ValueError) as e:
104
+ error_messages.append(str(e))
105
+
106
+ if match > 1:
107
+ # more than 1 match
108
+ raise ValueError("Multiple matches found when deserializing the JSON string into ChatSettingsTags with oneOf schemas: List[str], TagFilter. Details: " + ", ".join(error_messages))
109
+ elif match == 0:
110
+ # no match
111
+ raise ValueError("No match found when deserializing the JSON string into ChatSettingsTags with oneOf schemas: List[str], TagFilter. Details: " + ", ".join(error_messages))
112
+ else:
113
+ return instance
114
+
115
+ def to_json(self) -> str:
116
+ """Returns the JSON representation of the actual instance"""
117
+ if self.actual_instance is None:
118
+ return "null"
119
+
120
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
121
+ return self.actual_instance.to_json()
122
+ else:
123
+ return json.dumps(self.actual_instance)
124
+
125
+ def to_dict(self) -> Optional[Union[Dict[str, Any], List[str], TagFilter]]:
126
+ """Returns the dict representation of the actual instance"""
127
+ if self.actual_instance is None:
128
+ return None
129
+
130
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
131
+ return self.actual_instance.to_dict()
132
+ else:
133
+ # primitive type
134
+ return self.actual_instance
135
+
136
+ def to_str(self) -> str:
137
+ """Returns the string representation of the actual instance"""
138
+ return pprint.pformat(self.model_dump())
139
+
140
+
@@ -18,8 +18,9 @@ import re # noqa: F401
18
18
  import json
19
19
 
20
20
  from datetime import datetime
21
- from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
22
22
  from typing import Any, ClassVar, Dict, List, Optional
23
+ from h2ogpte.rest_sync.models.guardrails_settings import GuardrailsSettings
23
24
  from typing import Optional, Set
24
25
  from typing_extensions import Self
25
26
 
@@ -31,10 +32,20 @@ class Extractor(BaseModel):
31
32
  description: StrictStr = Field(description="What this extractor does")
32
33
  llm: Optional[StrictStr] = Field(default=None, description="(Optional) Identifier or version of the language model the extractor uses")
33
34
  var_schema: Optional[StrictStr] = Field(default=None, description="(Optional) JSONSchema (or other spec) that the extractor outputs", alias="schema")
35
+ prompt: Optional[StrictStr] = Field(default=None, description="(Optional) Prompt text for the extractor")
36
+ pre_prompt_summary: Optional[StrictStr] = Field(default=None, description="(Optional) Pre-prompt summary text for the extractor")
37
+ keep_intermediate_results: Optional[StrictBool] = Field(default=None, description="(Optional) Flag indicating whether to keep intermediate results during extraction")
38
+ system_prompt: Optional[StrictStr] = Field(default=None, description="(Optional) System prompt text for the extractor")
39
+ max_num_chunks: Optional[StrictInt] = Field(default=None, description="(Optional) Maximum number of chunks to process")
40
+ vision: Optional[StrictStr] = Field(default=None, description="(Optional) Vision mode setting")
41
+ vision_llm: Optional[StrictStr] = Field(default=None, description="(Optional) Vision LLM model identifier")
42
+ image_batch_image_prompt: Optional[StrictStr] = Field(default=None, description="(Optional) Image batch processing prompt")
43
+ image_batch_final_prompt: Optional[StrictStr] = Field(default=None, description="(Optional) Final prompt for image batch processing")
44
+ guardrails_settings: Optional[GuardrailsSettings] = None
34
45
  id: StrictStr = Field(description="Unique identifier of the extractor")
35
46
  is_public: StrictBool = Field(description="Flag indicating if the extractor is public")
36
47
  created_at: datetime = Field(description="When the extractor definition was created")
37
- __properties: ClassVar[List[str]] = ["name", "description", "llm", "schema", "id", "is_public", "created_at"]
48
+ __properties: ClassVar[List[str]] = ["name", "description", "llm", "schema", "prompt", "pre_prompt_summary", "keep_intermediate_results", "system_prompt", "max_num_chunks", "vision", "vision_llm", "image_batch_image_prompt", "image_batch_final_prompt", "guardrails_settings", "id", "is_public", "created_at"]
38
49
 
39
50
  model_config = ConfigDict(
40
51
  populate_by_name=True,
@@ -75,6 +86,9 @@ class Extractor(BaseModel):
75
86
  exclude=excluded_fields,
76
87
  exclude_none=True,
77
88
  )
89
+ # override the default output from pydantic by calling `to_dict()` of guardrails_settings
90
+ if self.guardrails_settings:
91
+ _dict['guardrails_settings'] = self.guardrails_settings.to_dict()
78
92
  return _dict
79
93
 
80
94
  @classmethod
@@ -91,6 +105,16 @@ class Extractor(BaseModel):
91
105
  "description": obj.get("description"),
92
106
  "llm": obj.get("llm"),
93
107
  "schema": obj.get("schema"),
108
+ "prompt": obj.get("prompt"),
109
+ "pre_prompt_summary": obj.get("pre_prompt_summary"),
110
+ "keep_intermediate_results": obj.get("keep_intermediate_results"),
111
+ "system_prompt": obj.get("system_prompt"),
112
+ "max_num_chunks": obj.get("max_num_chunks"),
113
+ "vision": obj.get("vision"),
114
+ "vision_llm": obj.get("vision_llm"),
115
+ "image_batch_image_prompt": obj.get("image_batch_image_prompt"),
116
+ "image_batch_final_prompt": obj.get("image_batch_final_prompt"),
117
+ "guardrails_settings": GuardrailsSettings.from_dict(obj["guardrails_settings"]) if obj.get("guardrails_settings") is not None else None,
94
118
  "id": obj.get("id"),
95
119
  "is_public": obj.get("is_public"),
96
120
  "created_at": obj.get("created_at")
@@ -17,8 +17,9 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
- from typing import Any, ClassVar, Dict, List
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from h2ogpte.rest_sync.models.guardrails_settings import GuardrailsSettings
22
23
  from typing import Optional, Set
23
24
  from typing_extensions import Self
24
25
 
@@ -29,8 +30,18 @@ class ExtractorCreateRequest(BaseModel):
29
30
  name: StrictStr = Field(description="Human-readable name")
30
31
  description: StrictStr = Field(description="What this extractor does")
31
32
  llm: StrictStr = Field(description="Identifier or version of the language model the extractor uses")
32
- var_schema: StrictStr = Field(description="JSONSchema (or other spec) that the extractor outputs", alias="schema")
33
- __properties: ClassVar[List[str]] = ["name", "description", "llm", "schema"]
33
+ var_schema: StrictStr = Field(description="JSONSchema (or other spec) that the extractor outputs. When schema is valid and not empty, the output will be always returned as JSON object.", alias="schema")
34
+ prompt: Optional[StrictStr] = Field(default=None, description="Custom prompt text for the extractor. If empty, default prompt will be used. If combined with schema, prompt can customize the output, but cannot change its format as it will always be JSON object.")
35
+ pre_prompt_summary: Optional[StrictStr] = Field(default=None, description="(Optional) Pre-prompt summary text for the extractor")
36
+ keep_intermediate_results: Optional[StrictBool] = Field(default=None, description="(Optional) Flag indicating whether to keep intermediate results during extraction")
37
+ system_prompt: Optional[StrictStr] = Field(default=None, description="(Optional) System prompt text for the extractor")
38
+ max_num_chunks: Optional[StrictInt] = Field(default=None, description="(Optional) Maximum number of chunks to process")
39
+ vision: Optional[StrictStr] = Field(default=None, description="(Optional) Vision mode setting")
40
+ vision_llm: Optional[StrictStr] = Field(default=None, description="(Optional) Vision LLM model identifier")
41
+ image_batch_image_prompt: Optional[StrictStr] = Field(default=None, description="(Optional) Image batch processing prompt")
42
+ image_batch_final_prompt: Optional[StrictStr] = Field(default=None, description="(Optional) Final prompt for image batch processing")
43
+ guardrails_settings: Optional[GuardrailsSettings] = None
44
+ __properties: ClassVar[List[str]] = ["name", "description", "llm", "schema", "prompt", "pre_prompt_summary", "keep_intermediate_results", "system_prompt", "max_num_chunks", "vision", "vision_llm", "image_batch_image_prompt", "image_batch_final_prompt", "guardrails_settings"]
34
45
 
35
46
  model_config = ConfigDict(
36
47
  populate_by_name=True,
@@ -71,6 +82,9 @@ class ExtractorCreateRequest(BaseModel):
71
82
  exclude=excluded_fields,
72
83
  exclude_none=True,
73
84
  )
85
+ # override the default output from pydantic by calling `to_dict()` of guardrails_settings
86
+ if self.guardrails_settings:
87
+ _dict['guardrails_settings'] = self.guardrails_settings.to_dict()
74
88
  return _dict
75
89
 
76
90
  @classmethod
@@ -86,7 +100,17 @@ class ExtractorCreateRequest(BaseModel):
86
100
  "name": obj.get("name"),
87
101
  "description": obj.get("description"),
88
102
  "llm": obj.get("llm"),
89
- "schema": obj.get("schema")
103
+ "schema": obj.get("schema"),
104
+ "prompt": obj.get("prompt"),
105
+ "pre_prompt_summary": obj.get("pre_prompt_summary"),
106
+ "keep_intermediate_results": obj.get("keep_intermediate_results"),
107
+ "system_prompt": obj.get("system_prompt"),
108
+ "max_num_chunks": obj.get("max_num_chunks"),
109
+ "vision": obj.get("vision"),
110
+ "vision_llm": obj.get("vision_llm"),
111
+ "image_batch_image_prompt": obj.get("image_batch_image_prompt"),
112
+ "image_batch_final_prompt": obj.get("image_batch_final_prompt"),
113
+ "guardrails_settings": GuardrailsSettings.from_dict(obj["guardrails_settings"]) if obj.get("guardrails_settings") is not None else None
90
114
  })
91
115
  return _obj
92
116