Client library for Enterprise h2oGPTe
Project description
H2O H2OGPTE Python Client
Install
pip install h2ogpte
Usage
from h2ogpte import H2OGPTE
client = H2OGPTE(
address='https://h2ogpte.genai.h2o.ai',
api_key='sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
)
# Create a new collection
collection_id = client.create_collection(
name='Contracts',
description='Paper clip supply contracts',
)
# Create documents
# Note: Done for demonstration purposes only (not usually needed)
with open('dunder_mifflin.txt', 'w') as f:
f.write('There were 55 paper clips shipped, 22 to Scranton and 33 to Filmer.')
with open('initech.txt', 'w') as f:
f.write('David Brent did not sign any contract with Initech.')
# Upload documents
# Many file types are supported: text/image/audio documents and archives
with open('dunder_mifflin.txt', 'rb') as f:
dunder_mifflin = client.upload('Dunder Mifflin.txt', f)
with open('initech.txt', 'rb') as f:
initech = client.upload('IniTech.txt', f)
# Ingest documents (Creates previews, chunks and embeddings)
client.ingest_uploads(collection_id, [dunder_mifflin, initech])
# Create a chat session
chat_session_id = client.create_chat_session(collection_id)
# Query the collection
with client.connect(chat_session_id) as session:
reply = session.query(
'How many paper clips were shipped to Scranton?',
timeout=60,
)
print(reply.content)
reply = session.query(
'Did David Brent co-sign the contract with Initech?',
timeout=60,
)
print(reply.content)
# Summarize each document
documents = client.list_documents_in_collection(collection_id, offset=0, limit=99)
for doc in documents:
summary = client.summarize_document(
document_id=doc.id,
timeout=60,
)
print(summary.content)
Project details
Release history Release notifications | RSS feed
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
h2ogpte-1.3.8-py3-none-any.whl
(37.0 kB
view details)
File details
Details for the file h2ogpte-1.3.8-py3-none-any.whl
.
File metadata
- Download URL: h2ogpte-1.3.8-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ead34d80d58d47cee090e0c0d68441f13d8e1239f86137fe9b4d41f58d1992f |
|
MD5 | b4b2f2eec4ec49056079c6b0d02645ba |
|
BLAKE2b-256 | 7c65159f185b0b04f47ef6a96fc9aef7aba4129eae3e2eeb2874889f8b4a7c81 |