Skip to main content

The Python client for H2OGPTe REST API

Project description

h2ogpte_rest_client

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 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
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. Ensure that you are logged into your Enterprise h2oGPTe account.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: v1.0.0
  • Package version: 1.6.14-dev5
  • Generator version: 7.10.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements.

Python 3.8+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import h2ogpte_rest_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import h2ogpte_rest_client

Getting Started

Please follow the installation procedure and then run the following:

import h2ogpte_rest_client
from h2ogpte_rest_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte_rest_client.Configuration(
    host = "https://h2ogpte.genai.h2o.ai/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = h2ogpte_rest_client.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)


# Enter a context with an instance of the API client
with h2ogpte_rest_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte_rest_client.ChatApi(api_client)
    collection_id = 'collection_id_example' # str | Id of collection (optional)

    try:
        # Creates chat session.
        api_response = api_instance.create_chat_session(collection_id=collection_id)
        print("The response of ChatApi->create_chat_session:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling ChatApi->create_chat_session: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://h2ogpte.genai.h2o.ai/api/v1

Class Method HTTP request Description
ChatApi create_chat_session POST /chats Creates chat session.
ChatApi delete_chat_session DELETE /chats/{session_id} Deletes collection.
ChatApi delete_chat_session_collection DELETE /chats/{session_id}/collection Removes a collection reference from the chat session.
ChatApi delete_chat_session_prompt_template DELETE /chats/{session_id}/prompt_template Removes a prompt template reference from the chat session.
ChatApi get_chat_session GET /chats/{session_id} Finds a chat session by id.
ChatApi get_chat_session_count GET /chats/count Counts a number of chat sessions.
ChatApi get_chat_session_messages GET /chats/{session_id}/messages Fetches chat message and metadata for messages in a chat session.
ChatApi get_completion POST /chats/{session_id}/completions
ChatApi get_message_meta GET /messages/{message_id}/meta Fetches chat message meta information.
ChatApi get_message_references GET /messages/{message_id}/references Fetches metadata for references of a chat message.
ChatApi list_chat_sessions GET /chats List chat sessions.
ChatApi list_questions_for_chat_session GET /chats/{session_id}/questions List suggested questions for a given chat session.
ChatApi update_chat_session PATCH /chats/{session_id} Updates the name of a chat session.
ChatApi update_chat_session_collection PUT /chats/{session_id}/collection Updates a collection reference of a chat session.
ChatApi update_chat_session_prompt_template PUT /chats/{session_id}/prompt_template Updates a prompt template reference of a chat session.
CollectionsApi create_collection POST /collections Create a Collection
CollectionsApi delete_collection DELETE /collections/{collection_id} Deletes collection.
CollectionsApi delete_collection_prompt_template DELETE /collections/{collection_id}/prompt_template Removes a prompt template reference from the collection.
CollectionsApi delete_collection_thumbnail DELETE /collections/{collection_id}/thumbnail Deletes collection thumbnail.
CollectionsApi delete_document_from_collection DELETE /collections/{collection_id}/documents/{document_id} Removes the document from the collection.
CollectionsApi get_chat_session_count_for_collection GET /collections/{collection_id}/chats/count Counts a number of chat sessions with the collection.
CollectionsApi get_collection GET /collections/{collection_id} Get a Collection
CollectionsApi get_collection_chat_settings GET /collections/{collection_id}/chat_settings Fetches collection chat settings.
CollectionsApi get_collection_count GET /collections/count Counts a number of collections.
CollectionsApi get_collection_permissions GET /collections/{collection_id}/permissions Returns a list of access permissions for a given collection.
CollectionsApi get_collection_settings GET /collections/{collection_id}/settings Fetches collection settings.
CollectionsApi get_document_count_for_collection GET /collections/{collection_id}/documents/count Counts a number of documents in the collection.
CollectionsApi insert_document_into_collection PUT /collections/{collection_id}/documents/{document_id} Import an already stored document to an existing collection.
CollectionsApi list_chat_sessions_for_collection GET /collections/{collection_id}/chats List chat sessions for a given collection.
CollectionsApi list_collections GET /collections List collections.
CollectionsApi list_documents_for_collection GET /collections/{collection_id}/documents List a Collection's documents
CollectionsApi list_questions_for_collection GET /collections/{collection_id}/questions List suggested questions for a given collection.
CollectionsApi share_collection PUT /collections/{collection_id}/permissions/{username} Shares a collection to a user.
CollectionsApi unshare_collection DELETE /collections/{collection_id}/permissions/{username} Removes sharing of a collection to a user.
CollectionsApi unshare_collection_for_all DELETE /collections/{collection_id}/permissions Removes sharing of a collection to all other users except the original owner.
CollectionsApi update_collection PATCH /collections/{collection_id} Updates attributes of an existing collection.
CollectionsApi update_collection_chat_settings PUT /collections/{collection_id}/chat_settings Updates collection chat settings.
CollectionsApi update_collection_prompt_template PUT /collections/{collection_id}/prompt_template Updates a prompt template reference of a collection.
CollectionsApi update_collection_settings PUT /collections/{collection_id}/settings Updates collection settings.
CollectionsApi update_collection_thumbnail PUT /collections/{collection_id}/thumbnail Updates collection thumbnail.
DocumentIngestionApi ingest_from_azure_blob_storage POST /ingest/azure_blob_storage Adds files from the Azure Blob Storage into a collection.
DocumentIngestionApi ingest_from_file_system POST /ingest/file_system Adds files from the local system into a collection.
DocumentIngestionApi ingest_from_gcs POST /ingest/gcs Adds files from the Google Cloud Storage into a collection.
DocumentIngestionApi ingest_from_plain_text POST /ingest/plain_text Adds plain text to a collection.
DocumentIngestionApi ingest_from_s3 POST /ingest/s3 Adds files from the AWS S3 storage into a collection.
DocumentIngestionApi ingest_from_website POST /ingest/website Crawls and ingest a URL into a collection.
DocumentIngestionApi ingest_upload POST /uploads/{upload_id}/ingest Ingest uploaded document
DocumentIngestionApi upload_file PUT /uploads
DocumentsApi create_tag_on_document POST /documents/{document_id}/tags Assigns a tag to the document.
DocumentsApi delete_document DELETE /documents/{document_id} Deletes a document.
DocumentsApi delete_tag_from_document DELETE /documents/{document_id}/tags/{tag_name} Removes a tag from a document.
DocumentsApi get_chat_session_count_for_document GET /documents/{document_id}/chats/count Counts a number of chat sessions with the document.
DocumentsApi get_document GET /documents/{document_id} Finds a document by id.
DocumentsApi get_document_count GET /documents/count Counts a number of documents.
DocumentsApi list_chat_sessions_for_document GET /documents/{document_id}/chats List chat sessions for a given document.
DocumentsApi list_collections_for_document GET /documents/{document_id}/collections Lists collections for containing a given document.
DocumentsApi list_documents GET /documents List documents.
DocumentsApi update_document PATCH /documents/{document_id} Updates attributes of an existing document.
ModelsApi get_performance_stats_by_model GET /stats/performance_by_model Returns performance statistics grouped by models.
ModelsApi get_usage_stats GET /stats/usage Returns usage statistics for all models.
ModelsApi get_usage_stats_by_model GET /stats/usage_by_model Returns usage statistics grouped by models.
ModelsApi get_usage_stats_by_model_and_user GET /stats/usage_by_model_and_user Returns usage statistics grouped by models and users.
ModelsApi get_usage_stats_by_user GET /stats/usage_by_user Returns usage statistics grouped by users.
ModelsApi list_models GET /models Lists all available large language models.
PermissionsApi assign_permission_to_role PUT /roles/{role_id}/permissions/{permission_name} Assigns permission to a given role.
PermissionsApi assign_role_to_user PUT /users/{user_id}/roles/{role_name} Assigns role to a given user.
PermissionsApi create_role POST /roles Creates a role.
PermissionsApi delete_role DELETE /roles/{role_id} Deletes role for a given unique identifier.
PermissionsApi get_current_user_permissions GET /users/current/permissions Lists permissions of the user calling the endpoint.
PermissionsApi get_current_user_roles GET /users/current/roles Finds roles associated with the user calling the endpoint.
PermissionsApi get_role GET /roles/{role_id} Finds role for a given unique identifier.
PermissionsApi get_role_permissions GET /roles/{role_id}/permissions Lists permissions of a given role.
PermissionsApi get_user GET /users/{user_id} Finds user for a given unique identifier.
PermissionsApi get_user_permissions GET /users/{user_id}/permissions Lists permissions of a given user.
PermissionsApi get_user_roles GET /users/{user_id}/roles Finds roles associated with a given user.
PermissionsApi list_roles GET /roles Returns all roles for in the H2OGPTe instance.
PermissionsApi list_users GET /users Returns a list of all registered users for the system.
PermissionsApi remove_permission_from_role DELETE /roles/{role_id}/permissions/{permission_name} Removes permission from a given role.
PermissionsApi remove_role_from_user DELETE /users/{user_id}/roles/{role_name} Removes role from a given user.
PromptTemplatesApi create_prompt_template POST /prompt_templates Creates a new prompt template.
PromptTemplatesApi delete_prompt_template DELETE /prompt_templates/{prompt_template_id} Deletes a prompt template.
PromptTemplatesApi get_prompt_template GET /prompt_templates/{prompt_template_id} Finds a prompt template by id.
PromptTemplatesApi get_prompt_template_count GET /prompt_templates/count Counts a number of prompt templates.
PromptTemplatesApi get_prompt_template_permissions GET /prompt_templates/{prompt_template_id}/permissions Returns a list of access permissions for a given prompt template.
PromptTemplatesApi list_prompt_templates GET /prompt_templates List prompt templates.
PromptTemplatesApi share_prompt_template PUT /prompt_templates/{prompt_template_id}/permissions/{username} Shares a prompt template to a user.
PromptTemplatesApi unshare_prompt_template DELETE /prompt_templates/{prompt_template_id}/permissions/{username} Removes sharing of a prompt template to a user.
PromptTemplatesApi unshare_prompt_template_for_all DELETE /prompt_templates/{prompt_template_id}/permissions Removes sharing of a prompt template to all other users except the original owner.
PromptTemplatesApi update_prompt_template PATCH /prompt_templates/{prompt_template_id} Updates attributes of a given prompt template.
TagsApi create_tag POST /tags Creates a new tag.
TagsApi get_tag GET /tags/{tag_name} Finds a tag by its name.
TagsApi list_documents_for_tag GET /tags/{tag_name}/documents List documents associated with a tag.
TagsApi list_tags GET /tags List tags.
TagsApi update_tag PATCH /tags/{tag_name} Updates attributes of a tag.

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: Bearer authentication

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

h2ogpte_rest_client-1.6.14.dev5-py3-none-any.whl (256.3 kB view details)

Uploaded Python 3

File details

Details for the file h2ogpte_rest_client-1.6.14.dev5-py3-none-any.whl.

File metadata

File hashes

Hashes for h2ogpte_rest_client-1.6.14.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 1c5cd3934416cf31c751392bd5595a53d35e782706948a190cbdbfca5be4c6d6
MD5 15add639a4e7eff4b9895214f7e973a0
BLAKE2b-256 b7ce6c72813b6510981cd2d43a13dc975ceaea236a8af8b5cceafae6f431a7dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page