Skip to main content
Version: v1.6.1 🚧

Upload a file from your local machine

Overview​

Users can upload a supported file type to a Collection from their local machine. Supported file types:

  • PDF: ['.pdf']
  • Text: ['.txt', '.log', '.c', '.cs', '.cpp', '.java', '.json', '.py', '.rb', '.tex', '.css', '.js', '.sh', '.ts', '.xml', '.php']
  • Rich Text: ['.rtf']
  • Word: ['.doc', '.docx']
  • Excel: ['.xls', '.xlsx', '.csv', '.tsv']
  • Powerpoint: ['.ppt', '.pptx']
  • HTML: ['.html', '.htm', '.xhtml']
  • Image: ['.jpg', '.jpeg', '.png', '.bmp', '.gif', '.tiff', '.pnm', '.pgm', '.pbm', '.ppm', '.pam', '.jpx', '.jp2', '.psd']
  • Document: ['.xps']
  • E-Book: ['.fb2', '.epub', '.mobi', '.cbz']
  • SVG: ['.svg']
  • Markdown: ['.md']
  • reStructuredText: ['.rst']
  • Audio: ['.mp3', '.flac', '.wav', '.m4a', '.aac']
  • Archives: ['.zip', '.tar', '.gz', '.tgz', '.bz2', '.tbz2', '.xz', '.txz']

Example​

from h2ogpte import H2OGPTE

client = H2OGPTE(
address="https://h2ogpte.genai.h2o.ai",
api_key='sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
)

collection_id = client.create_collection(
name="The name of my Collection",
description="The description of my Collection",
)

with open("annual-report.pdf", "rb") as f:
report = client.upload("annual-report.pdf", f)

client.ingest_uploads(
collection_id=collection_id,
upload_ids=[report]
)

Feedback