Skip to main content

A client library for interacting with the Tela API

Project description

Tela Client

A Python client library for interacting with the Tela API.

Installation

pip install tela-client

Overview

Tela Client provides a simple interface for processing documents (particularly PDFs) using Tela's "canvas" workflows. Key features include:

  • Easy integration with Tela API
  • Execute predefined workflows (canvases) with various inputs
  • File upload to Tela's vault storage
  • Batch processing for multiple files
  • Flexible output formats (JSON or Pandas DataFrame)
  • Local response caching for improved performance
  • Lifecycle hooks for customizing execution flow
  • Folder monitoring for automatic processing
  • Utility functions for PDF handling

Basic Usage

from tela_client import TelaClient, file

# Initialize the client
api_key = "your-tela-api-key"
client = TelaClient(api_key)

# Create a canvas instance
canvas_id = "your-canvas-id"
canvas = client.new_canvas(canvas_id, expected_input=['document'])

# Process a file
result = canvas.run(document=file("./example.pdf"))

# Access results
print(result)

Batch Processing

# Prepare multiple inputs
inputs = [
    {'document': file("./doc1.pdf")},
    {'document': file("./doc2.pdf")},
    {'document': file("./doc3.pdf")}
]

# Process all files
results = canvas.run_batch(inputs)

Using Hooks

from tela_client import TelaClient, file, hooks

# Define custom hooks
def on_before_run(input_data):
    print(f"Processing file: {input_data['document'].filename}")
    return input_data

def on_success(result):
    print(f"Successfully processed with score: {result.get('score')}")
    return result

# Apply hooks to canvas
canvas = client.new_canvas("your-canvas-id", expected_input=['document'])
canvas.add_hook(hooks.BEFORE_RUN, on_before_run)
canvas.add_hook(hooks.ON_SUCCESS, on_success)

# Run with hooks
result = canvas.run(document=file("./example.pdf"))

Folder Monitoring

from tela_client import TelaClient, folder_watcher

client = TelaClient("your-api-key")
canvas = client.new_canvas("your-canvas-id", expected_input=['document'])

# Watch a folder and process new files automatically
watcher = folder_watcher.watch(
    "/path/to/watch",
    canvas=canvas,
    input_key="document",
    file_pattern="*.pdf"
)

# Start monitoring (blocking call)
watcher.start()

License

[License information]

Documentation

For more detailed information, refer to the full documentation.

Project details


Download files

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

Source Distribution

tela_client-0.4.6.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

tela_client-0.4.6-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file tela_client-0.4.6.tar.gz.

File metadata

  • Download URL: tela_client-0.4.6.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for tela_client-0.4.6.tar.gz
Algorithm Hash digest
SHA256 9b93e2b57c3d2ef56d094f6ac2eca84625a438ccc772ca857e3eb20470ace8ca
MD5 ce11ff08a92608945ebd5b5c40aeff02
BLAKE2b-256 cdc2d53c954c54389a79ed050cd83ab28bfe46af83641d417a586ca745b0d153

See more details on using hashes here.

File details

Details for the file tela_client-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: tela_client-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for tela_client-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 967083a3b2642ba6a31b5522ea50a227aec28ad15ea2d6a509c925dea5fbbda0
MD5 f34d3142aa61788f1194aa228ac83159
BLAKE2b-256 b38d941e7a9a8215298823727bda6988d32979aaf8ae7ccf4cc1fd20ea58817c

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